objc2_ui_kit/generated/
UIAlertController.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/uialertactionstyle?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct UIAlertActionStyle(pub NSInteger);
15impl UIAlertActionStyle {
16    #[doc(alias = "UIAlertActionStyleDefault")]
17    pub const Default: Self = Self(0);
18    #[doc(alias = "UIAlertActionStyleCancel")]
19    pub const Cancel: Self = Self(1);
20    #[doc(alias = "UIAlertActionStyleDestructive")]
21    pub const Destructive: Self = Self(2);
22}
23
24unsafe impl Encode for UIAlertActionStyle {
25    const ENCODING: Encoding = NSInteger::ENCODING;
26}
27
28unsafe impl RefEncode for UIAlertActionStyle {
29    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uialertcontrollerstyle?language=objc)
33// NS_ENUM
34#[repr(transparent)]
35#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
36pub struct UIAlertControllerStyle(pub NSInteger);
37impl UIAlertControllerStyle {
38    #[doc(alias = "UIAlertControllerStyleActionSheet")]
39    pub const ActionSheet: Self = Self(0);
40    #[doc(alias = "UIAlertControllerStyleAlert")]
41    pub const Alert: Self = Self(1);
42}
43
44unsafe impl Encode for UIAlertControllerStyle {
45    const ENCODING: Encoding = NSInteger::ENCODING;
46}
47
48unsafe impl RefEncode for UIAlertControllerStyle {
49    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
50}
51
52/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uialertcontrollerseverity?language=objc)
53// NS_ENUM
54#[repr(transparent)]
55#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
56pub struct UIAlertControllerSeverity(pub NSInteger);
57impl UIAlertControllerSeverity {
58    #[doc(alias = "UIAlertControllerSeverityDefault")]
59    pub const Default: Self = Self(0);
60    #[doc(alias = "UIAlertControllerSeverityCritical")]
61    pub const Critical: Self = Self(1);
62}
63
64unsafe impl Encode for UIAlertControllerSeverity {
65    const ENCODING: Encoding = NSInteger::ENCODING;
66}
67
68unsafe impl RefEncode for UIAlertControllerSeverity {
69    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
70}
71
72extern_class!(
73    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uialertaction?language=objc)
74    #[unsafe(super(NSObject))]
75    #[thread_kind = MainThreadOnly]
76    #[derive(Debug, PartialEq, Eq, Hash)]
77    pub struct UIAlertAction;
78);
79
80extern_conformance!(
81    unsafe impl NSCopying for UIAlertAction {}
82);
83
84unsafe impl CopyingHelper for UIAlertAction {
85    type Result = Self;
86}
87
88extern_conformance!(
89    unsafe impl NSObjectProtocol for UIAlertAction {}
90);
91
92impl UIAlertAction {
93    extern_methods!(
94        #[cfg(feature = "block2")]
95        #[unsafe(method(actionWithTitle:style:handler:))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn actionWithTitle_style_handler(
98            title: Option<&NSString>,
99            style: UIAlertActionStyle,
100            handler: Option<&block2::DynBlock<dyn Fn(NonNull<UIAlertAction>)>>,
101            mtm: MainThreadMarker,
102        ) -> Retained<Self>;
103
104        #[unsafe(method(title))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn title(&self) -> Option<Retained<NSString>>;
107
108        #[unsafe(method(style))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn style(&self) -> UIAlertActionStyle;
111
112        #[unsafe(method(isEnabled))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn isEnabled(&self) -> bool;
115
116        /// Setter for [`isEnabled`][Self::isEnabled].
117        #[unsafe(method(setEnabled:))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn setEnabled(&self, enabled: bool);
120    );
121}
122
123/// Methods declared on superclass `NSObject`.
124impl UIAlertAction {
125    extern_methods!(
126        #[unsafe(method(init))]
127        #[unsafe(method_family = init)]
128        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
129
130        #[unsafe(method(new))]
131        #[unsafe(method_family = new)]
132        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
133    );
134}
135
136extern_class!(
137    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uialertcontroller?language=objc)
138    #[unsafe(super(UIViewController, UIResponder, NSObject))]
139    #[thread_kind = MainThreadOnly]
140    #[derive(Debug, PartialEq, Eq, Hash)]
141    #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
142    pub struct UIAlertController;
143);
144
145#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
146extern_conformance!(
147    unsafe impl NSCoding for UIAlertController {}
148);
149
150#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
151extern_conformance!(
152    unsafe impl NSObjectProtocol for UIAlertController {}
153);
154
155#[cfg(all(
156    feature = "UIAppearance",
157    feature = "UIResponder",
158    feature = "UIViewController"
159))]
160extern_conformance!(
161    unsafe impl UIAppearanceContainer for UIAlertController {}
162);
163
164#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
165extern_conformance!(
166    unsafe impl UIContentContainer for UIAlertController {}
167);
168
169#[cfg(all(
170    feature = "UIFocus",
171    feature = "UIResponder",
172    feature = "UIViewController"
173))]
174extern_conformance!(
175    unsafe impl UIFocusEnvironment for UIAlertController {}
176);
177
178#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
179extern_conformance!(
180    unsafe impl UIResponderStandardEditActions for UIAlertController {}
181);
182
183#[cfg(all(
184    feature = "UIResponder",
185    feature = "UITraitCollection",
186    feature = "UIViewController"
187))]
188extern_conformance!(
189    unsafe impl UITraitEnvironment for UIAlertController {}
190);
191
192#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
193impl UIAlertController {
194    extern_methods!(
195        #[unsafe(method(alertControllerWithTitle:message:preferredStyle:))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn alertControllerWithTitle_message_preferredStyle(
198            title: Option<&NSString>,
199            message: Option<&NSString>,
200            preferred_style: UIAlertControllerStyle,
201            mtm: MainThreadMarker,
202        ) -> Retained<Self>;
203
204        #[unsafe(method(addAction:))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn addAction(&self, action: &UIAlertAction);
207
208        #[unsafe(method(actions))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn actions(&self) -> Retained<NSArray<UIAlertAction>>;
211
212        #[unsafe(method(preferredAction))]
213        #[unsafe(method_family = none)]
214        pub unsafe fn preferredAction(&self) -> Option<Retained<UIAlertAction>>;
215
216        /// Setter for [`preferredAction`][Self::preferredAction].
217        #[unsafe(method(setPreferredAction:))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn setPreferredAction(&self, preferred_action: Option<&UIAlertAction>);
220
221        #[cfg(all(
222            feature = "UIControl",
223            feature = "UITextField",
224            feature = "UIView",
225            feature = "block2"
226        ))]
227        #[unsafe(method(addTextFieldWithConfigurationHandler:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn addTextFieldWithConfigurationHandler(
230            &self,
231            configuration_handler: Option<&block2::DynBlock<dyn Fn(NonNull<UITextField>)>>,
232        );
233
234        #[cfg(all(feature = "UIControl", feature = "UITextField", feature = "UIView"))]
235        #[unsafe(method(textFields))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn textFields(&self) -> Option<Retained<NSArray<UITextField>>>;
238
239        #[unsafe(method(title))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn title(&self) -> Option<Retained<NSString>>;
242
243        /// Setter for [`title`][Self::title].
244        #[unsafe(method(setTitle:))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn setTitle(&self, title: Option<&NSString>);
247
248        #[unsafe(method(message))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn message(&self) -> Option<Retained<NSString>>;
251
252        /// Setter for [`message`][Self::message].
253        #[unsafe(method(setMessage:))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn setMessage(&self, message: Option<&NSString>);
256
257        #[unsafe(method(preferredStyle))]
258        #[unsafe(method_family = none)]
259        pub unsafe fn preferredStyle(&self) -> UIAlertControllerStyle;
260
261        #[unsafe(method(severity))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn severity(&self) -> UIAlertControllerSeverity;
264
265        /// Setter for [`severity`][Self::severity].
266        #[unsafe(method(setSeverity:))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn setSeverity(&self, severity: UIAlertControllerSeverity);
269    );
270}
271
272/// Methods declared on superclass `UIViewController`.
273#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
274impl UIAlertController {
275    extern_methods!(
276        #[unsafe(method(initWithNibName:bundle:))]
277        #[unsafe(method_family = init)]
278        pub unsafe fn initWithNibName_bundle(
279            this: Allocated<Self>,
280            nib_name_or_nil: Option<&NSString>,
281            nib_bundle_or_nil: Option<&NSBundle>,
282        ) -> Retained<Self>;
283
284        #[unsafe(method(initWithCoder:))]
285        #[unsafe(method_family = init)]
286        pub unsafe fn initWithCoder(
287            this: Allocated<Self>,
288            coder: &NSCoder,
289        ) -> Option<Retained<Self>>;
290    );
291}
292
293/// Methods declared on superclass `NSObject`.
294#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
295impl UIAlertController {
296    extern_methods!(
297        #[unsafe(method(init))]
298        #[unsafe(method_family = init)]
299        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
300
301        #[unsafe(method(new))]
302        #[unsafe(method_family = new)]
303        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
304    );
305}
306
307/// SpringLoading.
308#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
309impl UIAlertController {
310    extern_methods!();
311}
312
313#[cfg(all(
314    feature = "UIResponder",
315    feature = "UISpringLoadedInteractionSupporting",
316    feature = "UIViewController"
317))]
318extern_conformance!(
319    unsafe impl UISpringLoadedInteractionSupporting for UIAlertController {}
320);