objc2_ui_kit/generated/
UIAlertController.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10#[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#[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#[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 #[unsafe(super(NSObject))]
75 #[thread_kind = MainThreadOnly]
76 #[derive(Debug, PartialEq, Eq, Hash)]
77 pub struct UIAlertAction;
78);
79
80unsafe impl NSCopying for UIAlertAction {}
81
82unsafe impl CopyingHelper for UIAlertAction {
83 type Result = Self;
84}
85
86unsafe impl NSObjectProtocol for UIAlertAction {}
87
88impl UIAlertAction {
89 extern_methods!(
90 #[cfg(feature = "block2")]
91 #[unsafe(method(actionWithTitle:style:handler:))]
92 #[unsafe(method_family = none)]
93 pub unsafe fn actionWithTitle_style_handler(
94 title: Option<&NSString>,
95 style: UIAlertActionStyle,
96 handler: Option<&block2::Block<dyn Fn(NonNull<UIAlertAction>)>>,
97 mtm: MainThreadMarker,
98 ) -> Retained<Self>;
99
100 #[unsafe(method(title))]
101 #[unsafe(method_family = none)]
102 pub unsafe fn title(&self) -> Option<Retained<NSString>>;
103
104 #[unsafe(method(style))]
105 #[unsafe(method_family = none)]
106 pub unsafe fn style(&self) -> UIAlertActionStyle;
107
108 #[unsafe(method(isEnabled))]
109 #[unsafe(method_family = none)]
110 pub unsafe fn isEnabled(&self) -> bool;
111
112 #[unsafe(method(setEnabled:))]
114 #[unsafe(method_family = none)]
115 pub unsafe fn setEnabled(&self, enabled: bool);
116 );
117}
118
119impl UIAlertAction {
121 extern_methods!(
122 #[unsafe(method(init))]
123 #[unsafe(method_family = init)]
124 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
125
126 #[unsafe(method(new))]
127 #[unsafe(method_family = new)]
128 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
129 );
130}
131
132extern_class!(
133 #[unsafe(super(UIViewController, UIResponder, NSObject))]
135 #[thread_kind = MainThreadOnly]
136 #[derive(Debug, PartialEq, Eq, Hash)]
137 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
138 pub struct UIAlertController;
139);
140
141#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
142unsafe impl NSCoding for UIAlertController {}
143
144#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
145unsafe impl NSObjectProtocol for UIAlertController {}
146
147#[cfg(all(
148 feature = "UIAppearance",
149 feature = "UIResponder",
150 feature = "UIViewController"
151))]
152unsafe impl UIAppearanceContainer for UIAlertController {}
153
154#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
155unsafe impl UIContentContainer for UIAlertController {}
156
157#[cfg(all(
158 feature = "UIFocus",
159 feature = "UIResponder",
160 feature = "UIViewController"
161))]
162unsafe impl UIFocusEnvironment for UIAlertController {}
163
164#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
165unsafe impl UIResponderStandardEditActions for UIAlertController {}
166
167#[cfg(all(
168 feature = "UIResponder",
169 feature = "UITraitCollection",
170 feature = "UIViewController"
171))]
172unsafe impl UITraitEnvironment for UIAlertController {}
173
174#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
175impl UIAlertController {
176 extern_methods!(
177 #[unsafe(method(alertControllerWithTitle:message:preferredStyle:))]
178 #[unsafe(method_family = none)]
179 pub unsafe fn alertControllerWithTitle_message_preferredStyle(
180 title: Option<&NSString>,
181 message: Option<&NSString>,
182 preferred_style: UIAlertControllerStyle,
183 mtm: MainThreadMarker,
184 ) -> Retained<Self>;
185
186 #[unsafe(method(addAction:))]
187 #[unsafe(method_family = none)]
188 pub unsafe fn addAction(&self, action: &UIAlertAction);
189
190 #[unsafe(method(actions))]
191 #[unsafe(method_family = none)]
192 pub unsafe fn actions(&self) -> Retained<NSArray<UIAlertAction>>;
193
194 #[unsafe(method(preferredAction))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn preferredAction(&self) -> Option<Retained<UIAlertAction>>;
197
198 #[unsafe(method(setPreferredAction:))]
200 #[unsafe(method_family = none)]
201 pub unsafe fn setPreferredAction(&self, preferred_action: Option<&UIAlertAction>);
202
203 #[cfg(all(
204 feature = "UIControl",
205 feature = "UITextField",
206 feature = "UIView",
207 feature = "block2"
208 ))]
209 #[unsafe(method(addTextFieldWithConfigurationHandler:))]
210 #[unsafe(method_family = none)]
211 pub unsafe fn addTextFieldWithConfigurationHandler(
212 &self,
213 configuration_handler: Option<&block2::Block<dyn Fn(NonNull<UITextField>)>>,
214 );
215
216 #[cfg(all(feature = "UIControl", feature = "UITextField", feature = "UIView"))]
217 #[unsafe(method(textFields))]
218 #[unsafe(method_family = none)]
219 pub unsafe fn textFields(&self) -> Option<Retained<NSArray<UITextField>>>;
220
221 #[unsafe(method(title))]
222 #[unsafe(method_family = none)]
223 pub unsafe fn title(&self) -> Option<Retained<NSString>>;
224
225 #[unsafe(method(setTitle:))]
227 #[unsafe(method_family = none)]
228 pub unsafe fn setTitle(&self, title: Option<&NSString>);
229
230 #[unsafe(method(message))]
231 #[unsafe(method_family = none)]
232 pub unsafe fn message(&self) -> Option<Retained<NSString>>;
233
234 #[unsafe(method(setMessage:))]
236 #[unsafe(method_family = none)]
237 pub unsafe fn setMessage(&self, message: Option<&NSString>);
238
239 #[unsafe(method(preferredStyle))]
240 #[unsafe(method_family = none)]
241 pub unsafe fn preferredStyle(&self) -> UIAlertControllerStyle;
242
243 #[unsafe(method(severity))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn severity(&self) -> UIAlertControllerSeverity;
246
247 #[unsafe(method(setSeverity:))]
249 #[unsafe(method_family = none)]
250 pub unsafe fn setSeverity(&self, severity: UIAlertControllerSeverity);
251 );
252}
253
254#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
256impl UIAlertController {
257 extern_methods!(
258 #[unsafe(method(initWithNibName:bundle:))]
259 #[unsafe(method_family = init)]
260 pub unsafe fn initWithNibName_bundle(
261 this: Allocated<Self>,
262 nib_name_or_nil: Option<&NSString>,
263 nib_bundle_or_nil: Option<&NSBundle>,
264 ) -> Retained<Self>;
265
266 #[unsafe(method(initWithCoder:))]
267 #[unsafe(method_family = init)]
268 pub unsafe fn initWithCoder(
269 this: Allocated<Self>,
270 coder: &NSCoder,
271 ) -> Option<Retained<Self>>;
272 );
273}
274
275#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
277impl UIAlertController {
278 extern_methods!(
279 #[unsafe(method(init))]
280 #[unsafe(method_family = init)]
281 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
282
283 #[unsafe(method(new))]
284 #[unsafe(method_family = new)]
285 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
286 );
287}
288
289#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
291impl UIAlertController {
292 extern_methods!();
293}
294
295#[cfg(all(
296 feature = "UIResponder",
297 feature = "UISpringLoadedInteractionSupporting",
298 feature = "UIViewController"
299))]
300unsafe impl UISpringLoadedInteractionSupporting for UIAlertController {}