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"))]
60unsafe impl NSCoding for UINavigationController {}
61
62#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
63unsafe impl NSObjectProtocol for UINavigationController {}
64
65#[cfg(all(
66    feature = "UIAppearance",
67    feature = "UIResponder",
68    feature = "UIViewController"
69))]
70unsafe impl UIAppearanceContainer for UINavigationController {}
71
72#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
73unsafe impl UIContentContainer for UINavigationController {}
74
75#[cfg(all(
76    feature = "UIFocus",
77    feature = "UIResponder",
78    feature = "UIViewController"
79))]
80unsafe impl UIFocusEnvironment for UINavigationController {}
81
82#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
83unsafe impl UIResponderStandardEditActions for UINavigationController {}
84
85#[cfg(all(
86    feature = "UIResponder",
87    feature = "UITraitCollection",
88    feature = "UIViewController"
89))]
90unsafe impl UITraitEnvironment for UINavigationController {}
91
92#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
93impl UINavigationController {
94    extern_methods!(
95        #[unsafe(method(initWithNavigationBarClass:toolbarClass:))]
96        #[unsafe(method_family = init)]
97        pub unsafe fn initWithNavigationBarClass_toolbarClass(
98            this: Allocated<Self>,
99            navigation_bar_class: Option<&AnyClass>,
100            toolbar_class: Option<&AnyClass>,
101        ) -> Retained<Self>;
102
103        #[unsafe(method(initWithRootViewController:))]
104        #[unsafe(method_family = init)]
105        pub unsafe fn initWithRootViewController(
106            this: Allocated<Self>,
107            root_view_controller: &UIViewController,
108        ) -> Retained<Self>;
109
110        #[unsafe(method(initWithNibName:bundle:))]
111        #[unsafe(method_family = init)]
112        pub unsafe fn initWithNibName_bundle(
113            this: Allocated<Self>,
114            nib_name_or_nil: Option<&NSString>,
115            nib_bundle_or_nil: Option<&NSBundle>,
116        ) -> Retained<Self>;
117
118        #[unsafe(method(initWithCoder:))]
119        #[unsafe(method_family = init)]
120        pub unsafe fn initWithCoder(
121            this: Allocated<Self>,
122            a_decoder: &NSCoder,
123        ) -> Option<Retained<Self>>;
124
125        #[unsafe(method(pushViewController:animated:))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn pushViewController_animated(
128            &self,
129            view_controller: &UIViewController,
130            animated: bool,
131        );
132
133        #[unsafe(method(popViewControllerAnimated:))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn popViewControllerAnimated(
136            &self,
137            animated: bool,
138        ) -> Option<Retained<UIViewController>>;
139
140        #[unsafe(method(popToViewController:animated:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn popToViewController_animated(
143            &self,
144            view_controller: &UIViewController,
145            animated: bool,
146        ) -> Option<Retained<NSArray<UIViewController>>>;
147
148        #[unsafe(method(popToRootViewControllerAnimated:))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn popToRootViewControllerAnimated(
151            &self,
152            animated: bool,
153        ) -> Option<Retained<NSArray<UIViewController>>>;
154
155        #[unsafe(method(topViewController))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn topViewController(&self) -> Option<Retained<UIViewController>>;
158
159        #[unsafe(method(visibleViewController))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn visibleViewController(&self) -> Option<Retained<UIViewController>>;
162
163        #[unsafe(method(viewControllers))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn viewControllers(&self) -> Retained<NSArray<UIViewController>>;
166
167        /// Setter for [`viewControllers`][Self::viewControllers].
168        #[unsafe(method(setViewControllers:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn setViewControllers(&self, view_controllers: &NSArray<UIViewController>);
171
172        #[unsafe(method(setViewControllers:animated:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn setViewControllers_animated(
175            &self,
176            view_controllers: &NSArray<UIViewController>,
177            animated: bool,
178        );
179
180        #[unsafe(method(isNavigationBarHidden))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn isNavigationBarHidden(&self) -> bool;
183
184        /// Setter for [`isNavigationBarHidden`][Self::isNavigationBarHidden].
185        #[unsafe(method(setNavigationBarHidden:))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn setNavigationBarHidden(&self, navigation_bar_hidden: bool);
188
189        #[unsafe(method(setNavigationBarHidden:animated:))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn setNavigationBarHidden_animated(&self, hidden: bool, animated: bool);
192
193        #[cfg(all(feature = "UINavigationBar", feature = "UIView"))]
194        #[unsafe(method(navigationBar))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn navigationBar(&self) -> Retained<UINavigationBar>;
197
198        #[unsafe(method(isToolbarHidden))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn isToolbarHidden(&self) -> bool;
201
202        /// Setter for [`isToolbarHidden`][Self::isToolbarHidden].
203        #[unsafe(method(setToolbarHidden:))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn setToolbarHidden(&self, toolbar_hidden: bool);
206
207        #[unsafe(method(setToolbarHidden:animated:))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn setToolbarHidden_animated(&self, hidden: bool, animated: bool);
210
211        #[cfg(all(feature = "UIToolbar", feature = "UIView"))]
212        #[unsafe(method(toolbar))]
213        #[unsafe(method_family = none)]
214        pub unsafe fn toolbar(&self) -> Option<Retained<UIToolbar>>;
215
216        #[unsafe(method(delegate))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn delegate(
219            &self,
220        ) -> Option<Retained<ProtocolObject<dyn UINavigationControllerDelegate>>>;
221
222        /// This is a [weak property][objc2::topics::weak_property].
223        /// Setter for [`delegate`][Self::delegate].
224        #[unsafe(method(setDelegate:))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn setDelegate(
227            &self,
228            delegate: Option<&ProtocolObject<dyn UINavigationControllerDelegate>>,
229        );
230
231        #[cfg(feature = "UIGestureRecognizer")]
232        #[unsafe(method(interactivePopGestureRecognizer))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn interactivePopGestureRecognizer(
235            &self,
236        ) -> Option<Retained<UIGestureRecognizer>>;
237
238        #[unsafe(method(showViewController:sender:))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn showViewController_sender(
241            &self,
242            vc: &UIViewController,
243            sender: Option<&AnyObject>,
244        );
245
246        /// 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.
247        #[unsafe(method(hidesBarsWhenKeyboardAppears))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn hidesBarsWhenKeyboardAppears(&self) -> bool;
250
251        /// Setter for [`hidesBarsWhenKeyboardAppears`][Self::hidesBarsWhenKeyboardAppears].
252        #[unsafe(method(setHidesBarsWhenKeyboardAppears:))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn setHidesBarsWhenKeyboardAppears(
255            &self,
256            hides_bars_when_keyboard_appears: bool,
257        );
258
259        /// When the user swipes, the navigation controller's navigationBar
260        /// &
261        /// toolbar will be hidden (on a swipe up) or shown (on a swipe down). The toolbar only participates if it has items.
262        #[unsafe(method(hidesBarsOnSwipe))]
263        #[unsafe(method_family = none)]
264        pub unsafe fn hidesBarsOnSwipe(&self) -> bool;
265
266        /// Setter for [`hidesBarsOnSwipe`][Self::hidesBarsOnSwipe].
267        #[unsafe(method(setHidesBarsOnSwipe:))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn setHidesBarsOnSwipe(&self, hides_bars_on_swipe: bool);
270
271        #[cfg(all(feature = "UIGestureRecognizer", feature = "UIPanGestureRecognizer"))]
272        /// 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.
273        #[unsafe(method(barHideOnSwipeGestureRecognizer))]
274        #[unsafe(method_family = none)]
275        pub unsafe fn barHideOnSwipeGestureRecognizer(&self) -> Retained<UIPanGestureRecognizer>;
276
277        /// 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.
278        #[unsafe(method(hidesBarsWhenVerticallyCompact))]
279        #[unsafe(method_family = none)]
280        pub unsafe fn hidesBarsWhenVerticallyCompact(&self) -> bool;
281
282        /// Setter for [`hidesBarsWhenVerticallyCompact`][Self::hidesBarsWhenVerticallyCompact].
283        #[unsafe(method(setHidesBarsWhenVerticallyCompact:))]
284        #[unsafe(method_family = none)]
285        pub unsafe fn setHidesBarsWhenVerticallyCompact(
286            &self,
287            hides_bars_when_vertically_compact: bool,
288        );
289
290        /// When the user taps, the navigation controller's navigationBar
291        /// &
292        /// 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.
293        #[unsafe(method(hidesBarsOnTap))]
294        #[unsafe(method_family = none)]
295        pub unsafe fn hidesBarsOnTap(&self) -> bool;
296
297        /// Setter for [`hidesBarsOnTap`][Self::hidesBarsOnTap].
298        #[unsafe(method(setHidesBarsOnTap:))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn setHidesBarsOnTap(&self, hides_bars_on_tap: bool);
301
302        #[cfg(all(feature = "UIGestureRecognizer", feature = "UITapGestureRecognizer"))]
303        /// 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.
304        #[unsafe(method(barHideOnTapGestureRecognizer))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn barHideOnTapGestureRecognizer(&self) -> Retained<UITapGestureRecognizer>;
307    );
308}
309
310/// Methods declared on superclass `NSObject`.
311#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
312impl UINavigationController {
313    extern_methods!(
314        #[unsafe(method(init))]
315        #[unsafe(method_family = init)]
316        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
317
318        #[unsafe(method(new))]
319        #[unsafe(method_family = new)]
320        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
321    );
322}
323
324extern_protocol!(
325    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uinavigationcontrollerdelegate?language=objc)
326    pub unsafe trait UINavigationControllerDelegate:
327        NSObjectProtocol + MainThreadOnly
328    {
329        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
330        #[optional]
331        #[unsafe(method(navigationController:willShowViewController:animated:))]
332        #[unsafe(method_family = none)]
333        unsafe fn navigationController_willShowViewController_animated(
334            &self,
335            navigation_controller: &UINavigationController,
336            view_controller: &UIViewController,
337            animated: bool,
338        );
339
340        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
341        #[optional]
342        #[unsafe(method(navigationController:didShowViewController:animated:))]
343        #[unsafe(method_family = none)]
344        unsafe fn navigationController_didShowViewController_animated(
345            &self,
346            navigation_controller: &UINavigationController,
347            view_controller: &UIViewController,
348            animated: bool,
349        );
350
351        #[cfg(all(
352            feature = "UIOrientation",
353            feature = "UIResponder",
354            feature = "UIViewController"
355        ))]
356        #[optional]
357        #[unsafe(method(navigationControllerSupportedInterfaceOrientations:))]
358        #[unsafe(method_family = none)]
359        unsafe fn navigationControllerSupportedInterfaceOrientations(
360            &self,
361            navigation_controller: &UINavigationController,
362        ) -> UIInterfaceOrientationMask;
363
364        #[cfg(all(
365            feature = "UIOrientation",
366            feature = "UIResponder",
367            feature = "UIViewController"
368        ))]
369        #[optional]
370        #[unsafe(method(navigationControllerPreferredInterfaceOrientationForPresentation:))]
371        #[unsafe(method_family = none)]
372        unsafe fn navigationControllerPreferredInterfaceOrientationForPresentation(
373            &self,
374            navigation_controller: &UINavigationController,
375        ) -> UIInterfaceOrientation;
376
377        #[cfg(all(
378            feature = "UIResponder",
379            feature = "UIViewController",
380            feature = "UIViewControllerTransitioning"
381        ))]
382        #[optional]
383        #[unsafe(method(navigationController:interactionControllerForAnimationController:))]
384        #[unsafe(method_family = none)]
385        unsafe fn navigationController_interactionControllerForAnimationController(
386            &self,
387            navigation_controller: &UINavigationController,
388            animation_controller: &ProtocolObject<dyn UIViewControllerAnimatedTransitioning>,
389        ) -> Option<Retained<ProtocolObject<dyn UIViewControllerInteractiveTransitioning>>>;
390
391        #[cfg(all(
392            feature = "UIResponder",
393            feature = "UIViewController",
394            feature = "UIViewControllerTransitioning"
395        ))]
396        #[optional]
397        #[unsafe(method(navigationController:animationControllerForOperation:fromViewController:toViewController:))]
398        #[unsafe(method_family = none)]
399        unsafe fn navigationController_animationControllerForOperation_fromViewController_toViewController(
400            &self,
401            navigation_controller: &UINavigationController,
402            operation: UINavigationControllerOperation,
403            from_vc: &UIViewController,
404            to_vc: &UIViewController,
405        ) -> Option<Retained<ProtocolObject<dyn UIViewControllerAnimatedTransitioning>>>;
406    }
407);
408
409/// UINavigationControllerItem.
410#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
411impl UIViewController {
412    extern_methods!(
413        #[cfg(feature = "UINavigationItem")]
414        #[unsafe(method(navigationItem))]
415        #[unsafe(method_family = none)]
416        pub unsafe fn navigationItem(&self) -> Retained<UINavigationItem>;
417
418        #[unsafe(method(hidesBottomBarWhenPushed))]
419        #[unsafe(method_family = none)]
420        pub unsafe fn hidesBottomBarWhenPushed(&self) -> bool;
421
422        /// Setter for [`hidesBottomBarWhenPushed`][Self::hidesBottomBarWhenPushed].
423        #[unsafe(method(setHidesBottomBarWhenPushed:))]
424        #[unsafe(method_family = none)]
425        pub unsafe fn setHidesBottomBarWhenPushed(&self, hides_bottom_bar_when_pushed: bool);
426
427        #[unsafe(method(navigationController))]
428        #[unsafe(method_family = none)]
429        pub unsafe fn navigationController(&self) -> Option<Retained<UINavigationController>>;
430    );
431}
432
433/// UINavigationControllerContextualToolbarItems.
434#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
435impl UIViewController {
436    extern_methods!(
437        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
438        #[unsafe(method(toolbarItems))]
439        #[unsafe(method_family = none)]
440        pub unsafe fn toolbarItems(&self) -> Option<Retained<NSArray<UIBarButtonItem>>>;
441
442        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
443        /// Setter for [`toolbarItems`][Self::toolbarItems].
444        #[unsafe(method(setToolbarItems:))]
445        #[unsafe(method_family = none)]
446        pub unsafe fn setToolbarItems(&self, toolbar_items: Option<&NSArray<UIBarButtonItem>>);
447
448        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
449        #[unsafe(method(setToolbarItems:animated:))]
450        #[unsafe(method_family = none)]
451        pub unsafe fn setToolbarItems_animated(
452            &self,
453            toolbar_items: Option<&NSArray<UIBarButtonItem>>,
454            animated: bool,
455        );
456    );
457}