1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12#[repr(transparent)]
25#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
26pub struct UINavigationControllerOperation(pub NSInteger);
27impl UINavigationControllerOperation {
28 #[doc(alias = "UINavigationControllerOperationNone")]
29 pub const None: Self = Self(0);
30 #[doc(alias = "UINavigationControllerOperationPush")]
31 pub const Push: Self = Self(1);
32 #[doc(alias = "UINavigationControllerOperationPop")]
33 pub const Pop: Self = Self(2);
34}
35
36unsafe impl Encode for UINavigationControllerOperation {
37 const ENCODING: Encoding = NSInteger::ENCODING;
38}
39
40unsafe impl RefEncode for UINavigationControllerOperation {
41 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
42}
43
44extern "C" {
45 #[cfg(feature = "objc2-core-foundation")]
47 pub static UINavigationControllerHideShowBarDuration: CGFloat;
48}
49
50extern_class!(
51 #[unsafe(super(UIViewController, UIResponder, NSObject))]
53 #[thread_kind = MainThreadOnly]
54 #[derive(Debug, PartialEq, Eq, Hash)]
55 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
56 pub struct UINavigationController;
57);
58
59#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
60extern_conformance!(
61 unsafe impl NSCoding for UINavigationController {}
62);
63
64#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
65extern_conformance!(
66 unsafe impl NSObjectProtocol for UINavigationController {}
67);
68
69#[cfg(all(
70 feature = "UIAppearance",
71 feature = "UIResponder",
72 feature = "UIViewController"
73))]
74extern_conformance!(
75 unsafe impl UIAppearanceContainer for UINavigationController {}
76);
77
78#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
79extern_conformance!(
80 unsafe impl UIContentContainer for UINavigationController {}
81);
82
83#[cfg(all(
84 feature = "UIFocus",
85 feature = "UIResponder",
86 feature = "UIViewController"
87))]
88extern_conformance!(
89 unsafe impl UIFocusEnvironment for UINavigationController {}
90);
91
92#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
93extern_conformance!(
94 unsafe impl UIResponderStandardEditActions for UINavigationController {}
95);
96
97#[cfg(all(
98 feature = "UIResponder",
99 feature = "UITraitCollection",
100 feature = "UIViewController"
101))]
102extern_conformance!(
103 unsafe impl UITraitEnvironment for UINavigationController {}
104);
105
106#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
107impl UINavigationController {
108 extern_methods!(
109 #[unsafe(method(initWithNavigationBarClass:toolbarClass:))]
110 #[unsafe(method_family = init)]
111 pub unsafe fn initWithNavigationBarClass_toolbarClass(
112 this: Allocated<Self>,
113 navigation_bar_class: Option<&AnyClass>,
114 toolbar_class: Option<&AnyClass>,
115 ) -> Retained<Self>;
116
117 #[unsafe(method(initWithRootViewController:))]
118 #[unsafe(method_family = init)]
119 pub unsafe fn initWithRootViewController(
120 this: Allocated<Self>,
121 root_view_controller: &UIViewController,
122 ) -> Retained<Self>;
123
124 #[unsafe(method(initWithNibName:bundle:))]
125 #[unsafe(method_family = init)]
126 pub unsafe fn initWithNibName_bundle(
127 this: Allocated<Self>,
128 nib_name_or_nil: Option<&NSString>,
129 nib_bundle_or_nil: Option<&NSBundle>,
130 ) -> Retained<Self>;
131
132 #[unsafe(method(initWithCoder:))]
133 #[unsafe(method_family = init)]
134 pub unsafe fn initWithCoder(
135 this: Allocated<Self>,
136 a_decoder: &NSCoder,
137 ) -> Option<Retained<Self>>;
138
139 #[unsafe(method(pushViewController:animated:))]
140 #[unsafe(method_family = none)]
141 pub unsafe fn pushViewController_animated(
142 &self,
143 view_controller: &UIViewController,
144 animated: bool,
145 );
146
147 #[unsafe(method(popViewControllerAnimated:))]
148 #[unsafe(method_family = none)]
149 pub unsafe fn popViewControllerAnimated(
150 &self,
151 animated: bool,
152 ) -> Option<Retained<UIViewController>>;
153
154 #[unsafe(method(popToViewController:animated:))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn popToViewController_animated(
157 &self,
158 view_controller: &UIViewController,
159 animated: bool,
160 ) -> Option<Retained<NSArray<UIViewController>>>;
161
162 #[unsafe(method(popToRootViewControllerAnimated:))]
163 #[unsafe(method_family = none)]
164 pub unsafe fn popToRootViewControllerAnimated(
165 &self,
166 animated: bool,
167 ) -> Option<Retained<NSArray<UIViewController>>>;
168
169 #[unsafe(method(topViewController))]
170 #[unsafe(method_family = none)]
171 pub unsafe fn topViewController(&self) -> Option<Retained<UIViewController>>;
172
173 #[unsafe(method(visibleViewController))]
174 #[unsafe(method_family = none)]
175 pub unsafe fn visibleViewController(&self) -> Option<Retained<UIViewController>>;
176
177 #[unsafe(method(viewControllers))]
178 #[unsafe(method_family = none)]
179 pub unsafe fn viewControllers(&self) -> Retained<NSArray<UIViewController>>;
180
181 #[unsafe(method(setViewControllers:))]
183 #[unsafe(method_family = none)]
184 pub unsafe fn setViewControllers(&self, view_controllers: &NSArray<UIViewController>);
185
186 #[unsafe(method(setViewControllers:animated:))]
187 #[unsafe(method_family = none)]
188 pub unsafe fn setViewControllers_animated(
189 &self,
190 view_controllers: &NSArray<UIViewController>,
191 animated: bool,
192 );
193
194 #[unsafe(method(isNavigationBarHidden))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn isNavigationBarHidden(&self) -> bool;
197
198 #[unsafe(method(setNavigationBarHidden:))]
200 #[unsafe(method_family = none)]
201 pub unsafe fn setNavigationBarHidden(&self, navigation_bar_hidden: bool);
202
203 #[unsafe(method(setNavigationBarHidden:animated:))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn setNavigationBarHidden_animated(&self, hidden: bool, animated: bool);
206
207 #[cfg(all(feature = "UINavigationBar", feature = "UIView"))]
208 #[unsafe(method(navigationBar))]
209 #[unsafe(method_family = none)]
210 pub unsafe fn navigationBar(&self) -> Retained<UINavigationBar>;
211
212 #[unsafe(method(isToolbarHidden))]
213 #[unsafe(method_family = none)]
214 pub unsafe fn isToolbarHidden(&self) -> bool;
215
216 #[unsafe(method(setToolbarHidden:))]
218 #[unsafe(method_family = none)]
219 pub unsafe fn setToolbarHidden(&self, toolbar_hidden: bool);
220
221 #[unsafe(method(setToolbarHidden:animated:))]
222 #[unsafe(method_family = none)]
223 pub unsafe fn setToolbarHidden_animated(&self, hidden: bool, animated: bool);
224
225 #[cfg(all(feature = "UIToolbar", feature = "UIView"))]
226 #[unsafe(method(toolbar))]
227 #[unsafe(method_family = none)]
228 pub unsafe fn toolbar(&self) -> Option<Retained<UIToolbar>>;
229
230 #[unsafe(method(delegate))]
231 #[unsafe(method_family = none)]
232 pub unsafe fn delegate(
233 &self,
234 ) -> Option<Retained<ProtocolObject<dyn UINavigationControllerDelegate>>>;
235
236 #[unsafe(method(setDelegate:))]
239 #[unsafe(method_family = none)]
240 pub unsafe fn setDelegate(
241 &self,
242 delegate: Option<&ProtocolObject<dyn UINavigationControllerDelegate>>,
243 );
244
245 #[cfg(feature = "UIGestureRecognizer")]
246 #[unsafe(method(interactivePopGestureRecognizer))]
247 #[unsafe(method_family = none)]
248 pub unsafe fn interactivePopGestureRecognizer(
249 &self,
250 ) -> Option<Retained<UIGestureRecognizer>>;
251
252 #[unsafe(method(showViewController:sender:))]
253 #[unsafe(method_family = none)]
254 pub unsafe fn showViewController_sender(
255 &self,
256 vc: &UIViewController,
257 sender: Option<&AnyObject>,
258 );
259
260 #[unsafe(method(hidesBarsWhenKeyboardAppears))]
262 #[unsafe(method_family = none)]
263 pub unsafe fn hidesBarsWhenKeyboardAppears(&self) -> bool;
264
265 #[unsafe(method(setHidesBarsWhenKeyboardAppears:))]
267 #[unsafe(method_family = none)]
268 pub unsafe fn setHidesBarsWhenKeyboardAppears(
269 &self,
270 hides_bars_when_keyboard_appears: bool,
271 );
272
273 #[unsafe(method(hidesBarsOnSwipe))]
277 #[unsafe(method_family = none)]
278 pub unsafe fn hidesBarsOnSwipe(&self) -> bool;
279
280 #[unsafe(method(setHidesBarsOnSwipe:))]
282 #[unsafe(method_family = none)]
283 pub unsafe fn setHidesBarsOnSwipe(&self, hides_bars_on_swipe: bool);
284
285 #[cfg(all(feature = "UIGestureRecognizer", feature = "UIPanGestureRecognizer"))]
286 #[unsafe(method(barHideOnSwipeGestureRecognizer))]
288 #[unsafe(method_family = none)]
289 pub unsafe fn barHideOnSwipeGestureRecognizer(&self) -> Retained<UIPanGestureRecognizer>;
290
291 #[unsafe(method(hidesBarsWhenVerticallyCompact))]
293 #[unsafe(method_family = none)]
294 pub unsafe fn hidesBarsWhenVerticallyCompact(&self) -> bool;
295
296 #[unsafe(method(setHidesBarsWhenVerticallyCompact:))]
298 #[unsafe(method_family = none)]
299 pub unsafe fn setHidesBarsWhenVerticallyCompact(
300 &self,
301 hides_bars_when_vertically_compact: bool,
302 );
303
304 #[unsafe(method(hidesBarsOnTap))]
308 #[unsafe(method_family = none)]
309 pub unsafe fn hidesBarsOnTap(&self) -> bool;
310
311 #[unsafe(method(setHidesBarsOnTap:))]
313 #[unsafe(method_family = none)]
314 pub unsafe fn setHidesBarsOnTap(&self, hides_bars_on_tap: bool);
315
316 #[cfg(all(feature = "UIGestureRecognizer", feature = "UITapGestureRecognizer"))]
317 #[unsafe(method(barHideOnTapGestureRecognizer))]
319 #[unsafe(method_family = none)]
320 pub unsafe fn barHideOnTapGestureRecognizer(&self) -> Retained<UITapGestureRecognizer>;
321 );
322}
323
324#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
326impl UINavigationController {
327 extern_methods!(
328 #[unsafe(method(init))]
329 #[unsafe(method_family = init)]
330 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
331
332 #[unsafe(method(new))]
333 #[unsafe(method_family = new)]
334 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
335 );
336}
337
338extern_protocol!(
339 pub unsafe trait UINavigationControllerDelegate:
341 NSObjectProtocol + MainThreadOnly
342 {
343 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
344 #[optional]
345 #[unsafe(method(navigationController:willShowViewController:animated:))]
346 #[unsafe(method_family = none)]
347 unsafe fn navigationController_willShowViewController_animated(
348 &self,
349 navigation_controller: &UINavigationController,
350 view_controller: &UIViewController,
351 animated: bool,
352 );
353
354 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
355 #[optional]
356 #[unsafe(method(navigationController:didShowViewController:animated:))]
357 #[unsafe(method_family = none)]
358 unsafe fn navigationController_didShowViewController_animated(
359 &self,
360 navigation_controller: &UINavigationController,
361 view_controller: &UIViewController,
362 animated: bool,
363 );
364
365 #[cfg(all(
366 feature = "UIOrientation",
367 feature = "UIResponder",
368 feature = "UIViewController"
369 ))]
370 #[optional]
371 #[unsafe(method(navigationControllerSupportedInterfaceOrientations:))]
372 #[unsafe(method_family = none)]
373 unsafe fn navigationControllerSupportedInterfaceOrientations(
374 &self,
375 navigation_controller: &UINavigationController,
376 ) -> UIInterfaceOrientationMask;
377
378 #[cfg(all(
379 feature = "UIOrientation",
380 feature = "UIResponder",
381 feature = "UIViewController"
382 ))]
383 #[optional]
384 #[unsafe(method(navigationControllerPreferredInterfaceOrientationForPresentation:))]
385 #[unsafe(method_family = none)]
386 unsafe fn navigationControllerPreferredInterfaceOrientationForPresentation(
387 &self,
388 navigation_controller: &UINavigationController,
389 ) -> UIInterfaceOrientation;
390
391 #[cfg(all(
392 feature = "UIResponder",
393 feature = "UIViewController",
394 feature = "UIViewControllerTransitioning"
395 ))]
396 #[optional]
397 #[unsafe(method(navigationController:interactionControllerForAnimationController:))]
398 #[unsafe(method_family = none)]
399 unsafe fn navigationController_interactionControllerForAnimationController(
400 &self,
401 navigation_controller: &UINavigationController,
402 animation_controller: &ProtocolObject<dyn UIViewControllerAnimatedTransitioning>,
403 ) -> Option<Retained<ProtocolObject<dyn UIViewControllerInteractiveTransitioning>>>;
404
405 #[cfg(all(
406 feature = "UIResponder",
407 feature = "UIViewController",
408 feature = "UIViewControllerTransitioning"
409 ))]
410 #[optional]
411 #[unsafe(method(navigationController:animationControllerForOperation:fromViewController:toViewController:))]
412 #[unsafe(method_family = none)]
413 unsafe fn navigationController_animationControllerForOperation_fromViewController_toViewController(
414 &self,
415 navigation_controller: &UINavigationController,
416 operation: UINavigationControllerOperation,
417 from_vc: &UIViewController,
418 to_vc: &UIViewController,
419 ) -> Option<Retained<ProtocolObject<dyn UIViewControllerAnimatedTransitioning>>>;
420 }
421);
422
423#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
425impl UIViewController {
426 extern_methods!(
427 #[cfg(feature = "UINavigationItem")]
428 #[unsafe(method(navigationItem))]
429 #[unsafe(method_family = none)]
430 pub unsafe fn navigationItem(&self) -> Retained<UINavigationItem>;
431
432 #[unsafe(method(hidesBottomBarWhenPushed))]
433 #[unsafe(method_family = none)]
434 pub unsafe fn hidesBottomBarWhenPushed(&self) -> bool;
435
436 #[unsafe(method(setHidesBottomBarWhenPushed:))]
438 #[unsafe(method_family = none)]
439 pub unsafe fn setHidesBottomBarWhenPushed(&self, hides_bottom_bar_when_pushed: bool);
440
441 #[unsafe(method(navigationController))]
442 #[unsafe(method_family = none)]
443 pub unsafe fn navigationController(&self) -> Option<Retained<UINavigationController>>;
444 );
445}
446
447#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
449impl UIViewController {
450 extern_methods!(
451 #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
452 #[unsafe(method(toolbarItems))]
453 #[unsafe(method_family = none)]
454 pub unsafe fn toolbarItems(&self) -> Option<Retained<NSArray<UIBarButtonItem>>>;
455
456 #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
457 #[unsafe(method(setToolbarItems:))]
459 #[unsafe(method_family = none)]
460 pub unsafe fn setToolbarItems(&self, toolbar_items: Option<&NSArray<UIBarButtonItem>>);
461
462 #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
463 #[unsafe(method(setToolbarItems:animated:))]
464 #[unsafe(method_family = none)]
465 pub unsafe fn setToolbarItems_animated(
466 &self,
467 toolbar_items: Option<&NSArray<UIBarButtonItem>>,
468 animated: bool,
469 );
470 );
471}