objc2_ui_kit/generated/
UINavigationController.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::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// UINavigationController manages a stack of view controllers and a navigation bar.
13/// It performs horizontal view transitions for pushed and popped views while keeping the navigation bar in sync.
14///
15/// Most clients will not need to subclass UINavigationController.
16///
17/// If a navigation controller is nested in a tab bar controller, it uses the title and toolbar attributes of the bottom view controller on the stack.
18///
19/// UINavigationController is rotatable if its top view controller is rotatable.
20/// Navigation between controllers with non-uniform rotatability is currently not supported.
21///
22/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uinavigationcontrolleroperation?language=objc)
23// NS_ENUM
24#[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    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uinavigationcontrollerhideshowbarduration?language=objc)
46    #[cfg(feature = "objc2-core-foundation")]
47    pub static UINavigationControllerHideShowBarDuration: CGFloat;
48}
49
50extern_class!(
51    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uinavigationcontroller?language=objc)
52    #[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        /// # Safety
110        ///
111        /// - `navigation_bar_class` probably has further requirements.
112        /// - `toolbar_class` probably has further requirements.
113        #[unsafe(method(initWithNavigationBarClass:toolbarClass:))]
114        #[unsafe(method_family = init)]
115        pub unsafe fn initWithNavigationBarClass_toolbarClass(
116            this: Allocated<Self>,
117            navigation_bar_class: Option<&AnyClass>,
118            toolbar_class: Option<&AnyClass>,
119        ) -> Retained<Self>;
120
121        #[unsafe(method(initWithRootViewController:))]
122        #[unsafe(method_family = init)]
123        pub fn initWithRootViewController(
124            this: Allocated<Self>,
125            root_view_controller: &UIViewController,
126        ) -> Retained<Self>;
127
128        #[unsafe(method(initWithNibName:bundle:))]
129        #[unsafe(method_family = init)]
130        pub fn initWithNibName_bundle(
131            this: Allocated<Self>,
132            nib_name_or_nil: Option<&NSString>,
133            nib_bundle_or_nil: Option<&NSBundle>,
134        ) -> Retained<Self>;
135
136        /// # Safety
137        ///
138        /// `a_decoder` possibly has further requirements.
139        #[unsafe(method(initWithCoder:))]
140        #[unsafe(method_family = init)]
141        pub unsafe fn initWithCoder(
142            this: Allocated<Self>,
143            a_decoder: &NSCoder,
144        ) -> Option<Retained<Self>>;
145
146        #[unsafe(method(pushViewController:animated:))]
147        #[unsafe(method_family = none)]
148        pub fn pushViewController_animated(
149            &self,
150            view_controller: &UIViewController,
151            animated: bool,
152        );
153
154        #[unsafe(method(popViewControllerAnimated:))]
155        #[unsafe(method_family = none)]
156        pub fn popViewControllerAnimated(
157            &self,
158            animated: bool,
159        ) -> Option<Retained<UIViewController>>;
160
161        #[unsafe(method(popToViewController:animated:))]
162        #[unsafe(method_family = none)]
163        pub fn popToViewController_animated(
164            &self,
165            view_controller: &UIViewController,
166            animated: bool,
167        ) -> Option<Retained<NSArray<UIViewController>>>;
168
169        #[unsafe(method(popToRootViewControllerAnimated:))]
170        #[unsafe(method_family = none)]
171        pub fn popToRootViewControllerAnimated(
172            &self,
173            animated: bool,
174        ) -> Option<Retained<NSArray<UIViewController>>>;
175
176        #[unsafe(method(topViewController))]
177        #[unsafe(method_family = none)]
178        pub fn topViewController(&self) -> Option<Retained<UIViewController>>;
179
180        #[unsafe(method(visibleViewController))]
181        #[unsafe(method_family = none)]
182        pub fn visibleViewController(&self) -> Option<Retained<UIViewController>>;
183
184        #[unsafe(method(viewControllers))]
185        #[unsafe(method_family = none)]
186        pub fn viewControllers(&self) -> Retained<NSArray<UIViewController>>;
187
188        /// Setter for [`viewControllers`][Self::viewControllers].
189        ///
190        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
191        #[unsafe(method(setViewControllers:))]
192        #[unsafe(method_family = none)]
193        pub fn setViewControllers(&self, view_controllers: &NSArray<UIViewController>);
194
195        #[unsafe(method(setViewControllers:animated:))]
196        #[unsafe(method_family = none)]
197        pub fn setViewControllers_animated(
198            &self,
199            view_controllers: &NSArray<UIViewController>,
200            animated: bool,
201        );
202
203        #[unsafe(method(isNavigationBarHidden))]
204        #[unsafe(method_family = none)]
205        pub fn isNavigationBarHidden(&self) -> bool;
206
207        /// Setter for [`isNavigationBarHidden`][Self::isNavigationBarHidden].
208        #[unsafe(method(setNavigationBarHidden:))]
209        #[unsafe(method_family = none)]
210        pub fn setNavigationBarHidden(&self, navigation_bar_hidden: bool);
211
212        #[unsafe(method(setNavigationBarHidden:animated:))]
213        #[unsafe(method_family = none)]
214        pub fn setNavigationBarHidden_animated(&self, hidden: bool, animated: bool);
215
216        #[cfg(all(feature = "UINavigationBar", feature = "UIView"))]
217        #[unsafe(method(navigationBar))]
218        #[unsafe(method_family = none)]
219        pub fn navigationBar(&self) -> Retained<UINavigationBar>;
220
221        #[unsafe(method(isToolbarHidden))]
222        #[unsafe(method_family = none)]
223        pub fn isToolbarHidden(&self) -> bool;
224
225        /// Setter for [`isToolbarHidden`][Self::isToolbarHidden].
226        #[unsafe(method(setToolbarHidden:))]
227        #[unsafe(method_family = none)]
228        pub fn setToolbarHidden(&self, toolbar_hidden: bool);
229
230        #[unsafe(method(setToolbarHidden:animated:))]
231        #[unsafe(method_family = none)]
232        pub fn setToolbarHidden_animated(&self, hidden: bool, animated: bool);
233
234        #[cfg(all(feature = "UIToolbar", feature = "UIView"))]
235        #[unsafe(method(toolbar))]
236        #[unsafe(method_family = none)]
237        pub fn toolbar(&self) -> Option<Retained<UIToolbar>>;
238
239        #[unsafe(method(delegate))]
240        #[unsafe(method_family = none)]
241        pub fn delegate(
242            &self,
243        ) -> Option<Retained<ProtocolObject<dyn UINavigationControllerDelegate>>>;
244
245        /// Setter for [`delegate`][Self::delegate].
246        ///
247        /// This is a [weak property][objc2::topics::weak_property].
248        #[unsafe(method(setDelegate:))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn setDelegate(
251            &self,
252            delegate: Option<&ProtocolObject<dyn UINavigationControllerDelegate>>,
253        );
254
255        #[cfg(feature = "UIGestureRecognizer")]
256        /// The interactive pop gesture recognizes on the leading screen edge and initiates an interactive pop.
257        /// This property should only be used to set up failure requirements with it.
258        #[unsafe(method(interactivePopGestureRecognizer))]
259        #[unsafe(method_family = none)]
260        pub fn interactivePopGestureRecognizer(&self) -> Option<Retained<UIGestureRecognizer>>;
261
262        #[cfg(feature = "UIGestureRecognizer")]
263        /// The interactive content pop gesture recognizes on the entire content area of the navigation controller
264        /// in cases that are not covered by the interactive pop gesture recognizer and initiates an interactive pop.
265        /// This property should only be used to set up failure requirements with it.
266        #[unsafe(method(interactiveContentPopGestureRecognizer))]
267        #[unsafe(method_family = none)]
268        pub fn interactiveContentPopGestureRecognizer(
269            &self,
270        ) -> Option<Retained<UIGestureRecognizer>>;
271
272        /// # Safety
273        ///
274        /// `sender` should be of the correct type.
275        #[unsafe(method(showViewController:sender:))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn showViewController_sender(
278            &self,
279            vc: &UIViewController,
280            sender: Option<&AnyObject>,
281        );
282
283        /// When the keyboard appears, the navigation controller's navigationBar toolbar will be hidden. The bars will remain hidden when the keyboard dismisses, but a tap in the content area will show them.
284        #[unsafe(method(hidesBarsWhenKeyboardAppears))]
285        #[unsafe(method_family = none)]
286        pub fn hidesBarsWhenKeyboardAppears(&self) -> bool;
287
288        /// Setter for [`hidesBarsWhenKeyboardAppears`][Self::hidesBarsWhenKeyboardAppears].
289        #[unsafe(method(setHidesBarsWhenKeyboardAppears:))]
290        #[unsafe(method_family = none)]
291        pub fn setHidesBarsWhenKeyboardAppears(&self, hides_bars_when_keyboard_appears: bool);
292
293        /// When the user swipes, the navigation controller's navigationBar
294        /// &
295        /// toolbar will be hidden (on a swipe up) or shown (on a swipe down). The toolbar only participates if it has items.
296        #[unsafe(method(hidesBarsOnSwipe))]
297        #[unsafe(method_family = none)]
298        pub fn hidesBarsOnSwipe(&self) -> bool;
299
300        /// Setter for [`hidesBarsOnSwipe`][Self::hidesBarsOnSwipe].
301        #[unsafe(method(setHidesBarsOnSwipe:))]
302        #[unsafe(method_family = none)]
303        pub fn setHidesBarsOnSwipe(&self, hides_bars_on_swipe: bool);
304
305        #[cfg(all(feature = "UIGestureRecognizer", feature = "UIPanGestureRecognizer"))]
306        /// The gesture recognizer that triggers if the bars will hide or show due to a swipe. Do not change the delegate or attempt to replace this gesture by overriding this method.
307        #[unsafe(method(barHideOnSwipeGestureRecognizer))]
308        #[unsafe(method_family = none)]
309        pub fn barHideOnSwipeGestureRecognizer(&self) -> Retained<UIPanGestureRecognizer>;
310
311        /// When the UINavigationController's vertical size class is compact, hide the UINavigationBar and UIToolbar. Unhandled taps in the regions that would normally be occupied by these bars will reveal the bars.
312        #[unsafe(method(hidesBarsWhenVerticallyCompact))]
313        #[unsafe(method_family = none)]
314        pub fn hidesBarsWhenVerticallyCompact(&self) -> bool;
315
316        /// Setter for [`hidesBarsWhenVerticallyCompact`][Self::hidesBarsWhenVerticallyCompact].
317        #[unsafe(method(setHidesBarsWhenVerticallyCompact:))]
318        #[unsafe(method_family = none)]
319        pub fn setHidesBarsWhenVerticallyCompact(&self, hides_bars_when_vertically_compact: bool);
320
321        /// When the user taps, the navigation controller's navigationBar
322        /// &
323        /// toolbar will be hidden or shown, depending on the hidden state of the navigationBar. The toolbar will only be shown if it has items to display.
324        #[unsafe(method(hidesBarsOnTap))]
325        #[unsafe(method_family = none)]
326        pub fn hidesBarsOnTap(&self) -> bool;
327
328        /// Setter for [`hidesBarsOnTap`][Self::hidesBarsOnTap].
329        #[unsafe(method(setHidesBarsOnTap:))]
330        #[unsafe(method_family = none)]
331        pub fn setHidesBarsOnTap(&self, hides_bars_on_tap: bool);
332
333        #[cfg(all(feature = "UIGestureRecognizer", feature = "UITapGestureRecognizer"))]
334        /// The gesture recognizer used to recognize if the bars will hide or show due to a tap in content. Do not change the delegate or attempt to replace this gesture by overriding this method.
335        ///
336        /// # Safety
337        ///
338        /// This is not retained internally, you must ensure the object is still alive.
339        #[unsafe(method(barHideOnTapGestureRecognizer))]
340        #[unsafe(method_family = none)]
341        pub unsafe fn barHideOnTapGestureRecognizer(&self) -> Retained<UITapGestureRecognizer>;
342    );
343}
344
345/// Methods declared on superclass `NSObject`.
346#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
347impl UINavigationController {
348    extern_methods!(
349        #[unsafe(method(init))]
350        #[unsafe(method_family = init)]
351        pub fn init(this: Allocated<Self>) -> Retained<Self>;
352
353        #[unsafe(method(new))]
354        #[unsafe(method_family = new)]
355        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
356    );
357}
358
359extern_protocol!(
360    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uinavigationcontrollerdelegate?language=objc)
361    pub unsafe trait UINavigationControllerDelegate:
362        NSObjectProtocol + MainThreadOnly
363    {
364        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
365        #[optional]
366        #[unsafe(method(navigationController:willShowViewController:animated:))]
367        #[unsafe(method_family = none)]
368        fn navigationController_willShowViewController_animated(
369            &self,
370            navigation_controller: &UINavigationController,
371            view_controller: &UIViewController,
372            animated: bool,
373        );
374
375        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
376        #[optional]
377        #[unsafe(method(navigationController:didShowViewController:animated:))]
378        #[unsafe(method_family = none)]
379        fn navigationController_didShowViewController_animated(
380            &self,
381            navigation_controller: &UINavigationController,
382            view_controller: &UIViewController,
383            animated: bool,
384        );
385
386        #[cfg(all(
387            feature = "UIOrientation",
388            feature = "UIResponder",
389            feature = "UIViewController"
390        ))]
391        #[optional]
392        #[unsafe(method(navigationControllerSupportedInterfaceOrientations:))]
393        #[unsafe(method_family = none)]
394        fn navigationControllerSupportedInterfaceOrientations(
395            &self,
396            navigation_controller: &UINavigationController,
397        ) -> UIInterfaceOrientationMask;
398
399        #[cfg(all(
400            feature = "UIOrientation",
401            feature = "UIResponder",
402            feature = "UIViewController"
403        ))]
404        #[optional]
405        #[unsafe(method(navigationControllerPreferredInterfaceOrientationForPresentation:))]
406        #[unsafe(method_family = none)]
407        fn navigationControllerPreferredInterfaceOrientationForPresentation(
408            &self,
409            navigation_controller: &UINavigationController,
410        ) -> UIInterfaceOrientation;
411
412        #[cfg(all(
413            feature = "UIResponder",
414            feature = "UIViewController",
415            feature = "UIViewControllerTransitioning"
416        ))]
417        #[optional]
418        #[unsafe(method(navigationController:interactionControllerForAnimationController:))]
419        #[unsafe(method_family = none)]
420        fn navigationController_interactionControllerForAnimationController(
421            &self,
422            navigation_controller: &UINavigationController,
423            animation_controller: &ProtocolObject<dyn UIViewControllerAnimatedTransitioning>,
424        ) -> Option<Retained<ProtocolObject<dyn UIViewControllerInteractiveTransitioning>>>;
425
426        #[cfg(all(
427            feature = "UIResponder",
428            feature = "UIViewController",
429            feature = "UIViewControllerTransitioning"
430        ))]
431        #[optional]
432        #[unsafe(method(navigationController:animationControllerForOperation:fromViewController:toViewController:))]
433        #[unsafe(method_family = none)]
434        fn navigationController_animationControllerForOperation_fromViewController_toViewController(
435            &self,
436            navigation_controller: &UINavigationController,
437            operation: UINavigationControllerOperation,
438            from_vc: &UIViewController,
439            to_vc: &UIViewController,
440        ) -> Option<Retained<ProtocolObject<dyn UIViewControllerAnimatedTransitioning>>>;
441    }
442);
443
444/// UINavigationControllerItem.
445#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
446impl UIViewController {
447    extern_methods!(
448        #[cfg(feature = "UINavigationItem")]
449        #[unsafe(method(navigationItem))]
450        #[unsafe(method_family = none)]
451        pub fn navigationItem(&self) -> Retained<UINavigationItem>;
452
453        #[unsafe(method(hidesBottomBarWhenPushed))]
454        #[unsafe(method_family = none)]
455        pub fn hidesBottomBarWhenPushed(&self) -> bool;
456
457        /// Setter for [`hidesBottomBarWhenPushed`][Self::hidesBottomBarWhenPushed].
458        #[unsafe(method(setHidesBottomBarWhenPushed:))]
459        #[unsafe(method_family = none)]
460        pub fn setHidesBottomBarWhenPushed(&self, hides_bottom_bar_when_pushed: bool);
461
462        #[unsafe(method(navigationController))]
463        #[unsafe(method_family = none)]
464        pub fn navigationController(&self) -> Option<Retained<UINavigationController>>;
465    );
466}
467
468/// UINavigationControllerContextualToolbarItems.
469#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
470impl UIViewController {
471    extern_methods!(
472        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
473        #[unsafe(method(toolbarItems))]
474        #[unsafe(method_family = none)]
475        pub fn toolbarItems(&self) -> Option<Retained<NSArray<UIBarButtonItem>>>;
476
477        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
478        /// Setter for [`toolbarItems`][Self::toolbarItems].
479        #[unsafe(method(setToolbarItems:))]
480        #[unsafe(method_family = none)]
481        pub fn setToolbarItems(&self, toolbar_items: Option<&NSArray<UIBarButtonItem>>);
482
483        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
484        #[unsafe(method(setToolbarItems:animated:))]
485        #[unsafe(method_family = none)]
486        pub fn setToolbarItems_animated(
487            &self,
488            toolbar_items: Option<&NSArray<UIBarButtonItem>>,
489            animated: bool,
490        );
491    );
492}