objc2_ui_kit/generated/
UIContextualAction.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextualactionhandler?language=objc)
11#[cfg(all(feature = "UIResponder", feature = "UIView", feature = "block2"))]
12pub type UIContextualActionHandler = *mut block2::DynBlock<
13    dyn Fn(NonNull<UIContextualAction>, NonNull<UIView>, NonNull<block2::DynBlock<dyn Fn(Bool)>>),
14>;
15
16/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextualactionstyle?language=objc)
17// NS_ENUM
18#[repr(transparent)]
19#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
20pub struct UIContextualActionStyle(pub NSInteger);
21impl UIContextualActionStyle {
22    #[doc(alias = "UIContextualActionStyleNormal")]
23    pub const Normal: Self = Self(0);
24    #[doc(alias = "UIContextualActionStyleDestructive")]
25    pub const Destructive: Self = Self(1);
26}
27
28unsafe impl Encode for UIContextualActionStyle {
29    const ENCODING: Encoding = NSInteger::ENCODING;
30}
31
32unsafe impl RefEncode for UIContextualActionStyle {
33    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36extern_class!(
37    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextualaction?language=objc)
38    #[unsafe(super(NSObject))]
39    #[thread_kind = MainThreadOnly]
40    #[derive(Debug, PartialEq, Eq, Hash)]
41    pub struct UIContextualAction;
42);
43
44extern_conformance!(
45    unsafe impl NSObjectProtocol for UIContextualAction {}
46);
47
48impl UIContextualAction {
49    extern_methods!(
50        #[cfg(all(feature = "UIResponder", feature = "UIView", feature = "block2"))]
51        /// # Safety
52        ///
53        /// `handler` must be a valid pointer.
54        #[unsafe(method(contextualActionWithStyle:title:handler:))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn contextualActionWithStyle_title_handler(
57            style: UIContextualActionStyle,
58            title: Option<&NSString>,
59            handler: UIContextualActionHandler,
60            mtm: MainThreadMarker,
61        ) -> Retained<Self>;
62
63        #[unsafe(method(style))]
64        #[unsafe(method_family = none)]
65        pub fn style(&self) -> UIContextualActionStyle;
66
67        #[cfg(all(feature = "UIResponder", feature = "UIView", feature = "block2"))]
68        /// # Safety
69        ///
70        /// - The returned block's argument 1 must be a valid pointer.
71        /// - The returned block's argument 2 must be a valid pointer.
72        /// - The returned block's argument 3 must be a valid pointer.
73        #[unsafe(method(handler))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn handler(&self) -> UIContextualActionHandler;
76
77        #[unsafe(method(title))]
78        #[unsafe(method_family = none)]
79        pub fn title(&self) -> Option<Retained<NSString>>;
80
81        /// Setter for [`title`][Self::title].
82        ///
83        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
84        #[unsafe(method(setTitle:))]
85        #[unsafe(method_family = none)]
86        pub fn setTitle(&self, title: Option<&NSString>);
87
88        #[cfg(feature = "UIColor")]
89        #[unsafe(method(backgroundColor))]
90        #[unsafe(method_family = none)]
91        pub fn backgroundColor(&self) -> Retained<UIColor>;
92
93        #[cfg(feature = "UIColor")]
94        /// Setter for [`backgroundColor`][Self::backgroundColor].
95        ///
96        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
97        #[unsafe(method(setBackgroundColor:))]
98        #[unsafe(method_family = none)]
99        pub fn setBackgroundColor(&self, background_color: Option<&UIColor>);
100
101        #[cfg(feature = "UIImage")]
102        #[unsafe(method(image))]
103        #[unsafe(method_family = none)]
104        pub fn image(&self) -> Option<Retained<UIImage>>;
105
106        #[cfg(feature = "UIImage")]
107        /// Setter for [`image`][Self::image].
108        ///
109        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
110        #[unsafe(method(setImage:))]
111        #[unsafe(method_family = none)]
112        pub fn setImage(&self, image: Option<&UIImage>);
113    );
114}
115
116/// Methods declared on superclass `NSObject`.
117impl UIContextualAction {
118    extern_methods!(
119        #[unsafe(method(init))]
120        #[unsafe(method_family = init)]
121        pub fn init(this: Allocated<Self>) -> Retained<Self>;
122
123        #[unsafe(method(new))]
124        #[unsafe(method_family = new)]
125        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
126    );
127}