1use 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 UITabBarControllerMode(pub NSInteger);
15impl UITabBarControllerMode {
16 #[doc(alias = "UITabBarControllerModeAutomatic")]
20 pub const Automatic: Self = Self(0);
21 #[doc(alias = "UITabBarControllerModeTabBar")]
23 pub const TabBar: Self = Self(1);
24 #[doc(alias = "UITabBarControllerModeTabSidebar")]
26 pub const TabSidebar: Self = Self(2);
27}
28
29unsafe impl Encode for UITabBarControllerMode {
30 const ENCODING: Encoding = NSInteger::ENCODING;
31}
32
33unsafe impl RefEncode for UITabBarControllerMode {
34 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
35}
36
37#[repr(transparent)]
40#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
41pub struct UITabBarMinimizeBehavior(pub NSInteger);
42impl UITabBarMinimizeBehavior {
43 #[doc(alias = "UITabBarMinimizeBehaviorAutomatic")]
45 pub const Automatic: Self = Self(0);
46 #[doc(alias = "UITabBarMinimizeBehaviorNever")]
48 pub const Never: Self = Self(1);
49 #[doc(alias = "UITabBarMinimizeBehaviorOnScrollDown")]
51 pub const OnScrollDown: Self = Self(2);
52 #[doc(alias = "UITabBarMinimizeBehaviorOnScrollUp")]
55 pub const OnScrollUp: Self = Self(3);
56}
57
58unsafe impl Encode for UITabBarMinimizeBehavior {
59 const ENCODING: Encoding = NSInteger::ENCODING;
60}
61
62unsafe impl RefEncode for UITabBarMinimizeBehavior {
63 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
64}
65
66extern_class!(
67 #[unsafe(super(UIViewController, UIResponder, NSObject))]
79 #[thread_kind = MainThreadOnly]
80 #[derive(Debug, PartialEq, Eq, Hash)]
81 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
82 pub struct UITabBarController;
83);
84
85#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
86extern_conformance!(
87 unsafe impl NSCoding for UITabBarController {}
88);
89
90#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
91extern_conformance!(
92 unsafe impl NSObjectProtocol for UITabBarController {}
93);
94
95#[cfg(all(
96 feature = "UIAppearance",
97 feature = "UIResponder",
98 feature = "UIViewController"
99))]
100extern_conformance!(
101 unsafe impl UIAppearanceContainer for UITabBarController {}
102);
103
104#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
105extern_conformance!(
106 unsafe impl UIContentContainer for UITabBarController {}
107);
108
109#[cfg(all(
110 feature = "UIFocus",
111 feature = "UIResponder",
112 feature = "UIViewController"
113))]
114extern_conformance!(
115 unsafe impl UIFocusEnvironment for UITabBarController {}
116);
117
118#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
119extern_conformance!(
120 unsafe impl UIResponderStandardEditActions for UITabBarController {}
121);
122
123#[cfg(all(
124 feature = "UIResponder",
125 feature = "UITabBar",
126 feature = "UIViewController"
127))]
128extern_conformance!(
129 unsafe impl UITabBarDelegate for UITabBarController {}
130);
131
132#[cfg(all(
133 feature = "UIResponder",
134 feature = "UITraitCollection",
135 feature = "UIViewController"
136))]
137extern_conformance!(
138 unsafe impl UITraitEnvironment for UITabBarController {}
139);
140
141#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
142impl UITabBarController {
143 extern_methods!(
144 #[unsafe(method(delegate))]
148 #[unsafe(method_family = none)]
149 pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn UITabBarControllerDelegate>>>;
150
151 #[unsafe(method(setDelegate:))]
155 #[unsafe(method_family = none)]
156 pub fn setDelegate(
157 &self,
158 delegate: Option<&ProtocolObject<dyn UITabBarControllerDelegate>>,
159 );
160
161 #[unsafe(method(mode))]
165 #[unsafe(method_family = none)]
166 pub fn mode(&self) -> UITabBarControllerMode;
167
168 #[unsafe(method(setMode:))]
170 #[unsafe(method_family = none)]
171 pub fn setMode(&self, mode: UITabBarControllerMode);
172
173 #[cfg(feature = "UITabBarControllerSidebar")]
174 #[unsafe(method(sidebar))]
176 #[unsafe(method_family = none)]
177 pub fn sidebar(&self) -> Retained<UITabBarControllerSidebar>;
178
179 #[unsafe(method(customizationIdentifier))]
184 #[unsafe(method_family = none)]
185 pub fn customizationIdentifier(&self) -> Option<Retained<NSString>>;
186
187 #[unsafe(method(setCustomizationIdentifier:))]
191 #[unsafe(method_family = none)]
192 pub fn setCustomizationIdentifier(&self, customization_identifier: Option<&NSString>);
193
194 #[unsafe(method(compactTabIdentifiers))]
198 #[unsafe(method_family = none)]
199 pub fn compactTabIdentifiers(&self) -> Option<Retained<NSArray<NSString>>>;
200
201 #[unsafe(method(setCompactTabIdentifiers:))]
205 #[unsafe(method_family = none)]
206 pub fn setCompactTabIdentifiers(&self, compact_tab_identifiers: Option<&NSArray<NSString>>);
207
208 #[cfg(feature = "UITab")]
209 #[unsafe(method(selectedTab))]
213 #[unsafe(method_family = none)]
214 pub fn selectedTab(&self) -> Option<Retained<UITab>>;
215
216 #[cfg(feature = "UITab")]
217 #[unsafe(method(setSelectedTab:))]
219 #[unsafe(method_family = none)]
220 pub fn setSelectedTab(&self, selected_tab: Option<&UITab>);
221
222 #[cfg(feature = "UITab")]
223 #[unsafe(method(tabs))]
227 #[unsafe(method_family = none)]
228 pub fn tabs(&self) -> Retained<NSArray<UITab>>;
229
230 #[cfg(feature = "UITab")]
231 #[unsafe(method(setTabs:))]
235 #[unsafe(method_family = none)]
236 pub fn setTabs(&self, tabs: &NSArray<UITab>);
237
238 #[cfg(feature = "UITab")]
239 #[unsafe(method(setTabs:animated:))]
241 #[unsafe(method_family = none)]
242 pub fn setTabs_animated(&self, tabs: &NSArray<UITab>, animated: bool);
243
244 #[cfg(feature = "UITab")]
245 #[unsafe(method(tabForIdentifier:))]
247 #[unsafe(method_family = none)]
248 pub fn tabForIdentifier(&self, identifier: &NSString) -> Option<Retained<UITab>>;
249
250 #[cfg(feature = "UITab")]
251 #[unsafe(method(initWithTabs:))]
253 #[unsafe(method_family = init)]
254 pub fn initWithTabs(this: Allocated<Self>, tabs: &NSArray<UITab>) -> Retained<Self>;
255
256 #[unsafe(method(tabBarMinimizeBehavior))]
260 #[unsafe(method_family = none)]
261 pub fn tabBarMinimizeBehavior(&self) -> UITabBarMinimizeBehavior;
262
263 #[unsafe(method(setTabBarMinimizeBehavior:))]
265 #[unsafe(method_family = none)]
266 pub fn setTabBarMinimizeBehavior(
267 &self,
268 tab_bar_minimize_behavior: UITabBarMinimizeBehavior,
269 );
270
271 #[unsafe(method(isTabBarHidden))]
275 #[unsafe(method_family = none)]
276 pub fn isTabBarHidden(&self) -> bool;
277
278 #[unsafe(method(setTabBarHidden:))]
280 #[unsafe(method_family = none)]
281 pub fn setTabBarHidden(&self, tab_bar_hidden: bool);
282
283 #[unsafe(method(setTabBarHidden:animated:))]
285 #[unsafe(method_family = none)]
286 pub fn setTabBarHidden_animated(&self, hidden: bool, animated: bool);
287
288 #[cfg(feature = "UILayoutGuide")]
289 #[unsafe(method(contentLayoutGuide))]
291 #[unsafe(method_family = none)]
292 pub fn contentLayoutGuide(&self) -> Retained<UILayoutGuide>;
293
294 #[cfg(feature = "UITabAccessory")]
295 #[unsafe(method(bottomAccessory))]
299 #[unsafe(method_family = none)]
300 pub fn bottomAccessory(&self) -> Option<Retained<UITabAccessory>>;
301
302 #[cfg(feature = "UITabAccessory")]
303 #[unsafe(method(setBottomAccessory:))]
305 #[unsafe(method_family = none)]
306 pub fn setBottomAccessory(&self, bottom_accessory: Option<&UITabAccessory>);
307
308 #[cfg(feature = "UITabAccessory")]
309 #[unsafe(method(setBottomAccessory:animated:))]
311 #[unsafe(method_family = none)]
312 pub fn setBottomAccessory_animated(
313 &self,
314 bottom_accessory: Option<&UITabAccessory>,
315 animated: bool,
316 );
317
318 #[unsafe(method(viewControllers))]
319 #[unsafe(method_family = none)]
320 pub fn viewControllers(&self) -> Option<Retained<NSArray<UIViewController>>>;
321
322 #[unsafe(method(setViewControllers:))]
326 #[unsafe(method_family = none)]
327 pub fn setViewControllers(&self, view_controllers: Option<&NSArray<UIViewController>>);
328
329 #[unsafe(method(setViewControllers:animated:))]
330 #[unsafe(method_family = none)]
331 pub fn setViewControllers_animated(
332 &self,
333 view_controllers: Option<&NSArray<UIViewController>>,
334 animated: bool,
335 );
336
337 #[unsafe(method(selectedViewController))]
341 #[unsafe(method_family = none)]
342 pub unsafe fn selectedViewController(&self) -> Option<Retained<UIViewController>>;
343
344 #[unsafe(method(setSelectedViewController:))]
350 #[unsafe(method_family = none)]
351 pub unsafe fn setSelectedViewController(
352 &self,
353 selected_view_controller: Option<&UIViewController>,
354 );
355
356 #[unsafe(method(selectedIndex))]
357 #[unsafe(method_family = none)]
358 pub fn selectedIndex(&self) -> NSUInteger;
359
360 #[unsafe(method(setSelectedIndex:))]
362 #[unsafe(method_family = none)]
363 pub fn setSelectedIndex(&self, selected_index: NSUInteger);
364
365 #[cfg(feature = "UINavigationController")]
366 #[unsafe(method(moreNavigationController))]
367 #[unsafe(method_family = none)]
368 pub fn moreNavigationController(&self) -> Retained<UINavigationController>;
369
370 #[unsafe(method(customizableViewControllers))]
371 #[unsafe(method_family = none)]
372 pub fn customizableViewControllers(&self) -> Option<Retained<NSArray<UIViewController>>>;
373
374 #[unsafe(method(setCustomizableViewControllers:))]
378 #[unsafe(method_family = none)]
379 pub fn setCustomizableViewControllers(
380 &self,
381 customizable_view_controllers: Option<&NSArray<UIViewController>>,
382 );
383
384 #[cfg(all(feature = "UITabBar", feature = "UIView"))]
385 #[unsafe(method(tabBar))]
386 #[unsafe(method_family = none)]
387 pub fn tabBar(&self) -> Retained<UITabBar>;
388 );
389}
390
391#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
393impl UITabBarController {
394 extern_methods!(
395 #[unsafe(method(initWithNibName:bundle:))]
396 #[unsafe(method_family = init)]
397 pub fn initWithNibName_bundle(
398 this: Allocated<Self>,
399 nib_name_or_nil: Option<&NSString>,
400 nib_bundle_or_nil: Option<&NSBundle>,
401 ) -> Retained<Self>;
402
403 #[unsafe(method(initWithCoder:))]
407 #[unsafe(method_family = init)]
408 pub unsafe fn initWithCoder(
409 this: Allocated<Self>,
410 coder: &NSCoder,
411 ) -> Option<Retained<Self>>;
412 );
413}
414
415#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
417impl UITabBarController {
418 extern_methods!(
419 #[unsafe(method(init))]
420 #[unsafe(method_family = init)]
421 pub fn init(this: Allocated<Self>) -> Retained<Self>;
422
423 #[unsafe(method(new))]
424 #[unsafe(method_family = new)]
425 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
426 );
427}
428
429extern_protocol!(
430 pub unsafe trait UITabBarControllerDelegate: NSObjectProtocol + MainThreadOnly {
432 #[cfg(all(
433 feature = "UIResponder",
434 feature = "UITab",
435 feature = "UIViewController"
436 ))]
437 #[optional]
444 #[unsafe(method(tabBarController:shouldSelectTab:))]
445 #[unsafe(method_family = none)]
446 fn tabBarController_shouldSelectTab(
447 &self,
448 tab_bar_controller: &UITabBarController,
449 tab: &UITab,
450 ) -> bool;
451
452 #[cfg(all(
453 feature = "UIResponder",
454 feature = "UITab",
455 feature = "UIViewController"
456 ))]
457 #[optional]
463 #[unsafe(method(tabBarController:didSelectTab:previousTab:))]
464 #[unsafe(method_family = none)]
465 fn tabBarController_didSelectTab_previousTab(
466 &self,
467 tab_bar_controller: &UITabBarController,
468 selected_tab: &UITab,
469 previous_tab: Option<&UITab>,
470 );
471
472 #[cfg(all(
473 feature = "UIDragSession",
474 feature = "UIDropInteraction",
475 feature = "UIResponder",
476 feature = "UITab",
477 feature = "UIViewController"
478 ))]
479 #[optional]
484 #[unsafe(method(tabBarController:tab:operationForAcceptingItemsFromDropSession:))]
485 #[unsafe(method_family = none)]
486 fn tabBarController_tab_operationForAcceptingItemsFromDropSession(
487 &self,
488 tab_bar_controller: &UITabBarController,
489 tab: &UITab,
490 session: &ProtocolObject<dyn UIDropSession>,
491 ) -> UIDropOperation;
492
493 #[cfg(all(
494 feature = "UIDragSession",
495 feature = "UIResponder",
496 feature = "UITab",
497 feature = "UIViewController"
498 ))]
499 #[optional]
504 #[unsafe(method(tabBarController:tab:acceptItemsFromDropSession:))]
505 #[unsafe(method_family = none)]
506 fn tabBarController_tab_acceptItemsFromDropSession(
507 &self,
508 tab_bar_controller: &UITabBarController,
509 tab: &UITab,
510 session: &ProtocolObject<dyn UIDropSession>,
511 );
512
513 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
514 #[optional]
516 #[unsafe(method(tabBarControllerWillBeginEditing:))]
517 #[unsafe(method_family = none)]
518 fn tabBarControllerWillBeginEditing(&self, tab_bar_controller: &UITabBarController);
519
520 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
521 #[optional]
523 #[unsafe(method(tabBarControllerDidEndEditing:))]
524 #[unsafe(method_family = none)]
525 fn tabBarControllerDidEndEditing(&self, tab_bar_controller: &UITabBarController);
526
527 #[cfg(all(
528 feature = "UIResponder",
529 feature = "UITab",
530 feature = "UIViewController"
531 ))]
532 #[optional]
534 #[unsafe(method(tabBarController:visibilityDidChangeForTabs:))]
535 #[unsafe(method_family = none)]
536 fn tabBarController_visibilityDidChangeForTabs(
537 &self,
538 tab_bar_controller: &UITabBarController,
539 tabs: &NSArray<UITab>,
540 );
541
542 #[cfg(all(
543 feature = "UIResponder",
544 feature = "UITab",
545 feature = "UITabGroup",
546 feature = "UIViewController"
547 ))]
548 #[optional]
550 #[unsafe(method(tabBarController:displayOrderDidChangeForGroup:))]
551 #[unsafe(method_family = none)]
552 fn tabBarController_displayOrderDidChangeForGroup(
553 &self,
554 tab_bar_controller: &UITabBarController,
555 group: &UITabGroup,
556 );
557
558 #[cfg(all(
559 feature = "UIResponder",
560 feature = "UITab",
561 feature = "UIViewController"
562 ))]
563 #[optional]
579 #[unsafe(method(tabBarController:displayedViewControllersForTab:proposedViewControllers:))]
580 #[unsafe(method_family = none)]
581 fn tabBarController_displayedViewControllersForTab_proposedViewControllers(
582 &self,
583 tab_bar_controller: &UITabBarController,
584 tab: &UITab,
585 proposed_view_controllers: &NSArray<UIViewController>,
586 ) -> Retained<NSArray<UIViewController>>;
587
588 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
589 #[optional]
590 #[unsafe(method(tabBarController:shouldSelectViewController:))]
591 #[unsafe(method_family = none)]
592 fn tabBarController_shouldSelectViewController(
593 &self,
594 tab_bar_controller: &UITabBarController,
595 view_controller: &UIViewController,
596 ) -> bool;
597
598 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
599 #[optional]
600 #[unsafe(method(tabBarController:didSelectViewController:))]
601 #[unsafe(method_family = none)]
602 fn tabBarController_didSelectViewController(
603 &self,
604 tab_bar_controller: &UITabBarController,
605 view_controller: &UIViewController,
606 );
607
608 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
609 #[optional]
610 #[unsafe(method(tabBarController:willBeginCustomizingViewControllers:))]
611 #[unsafe(method_family = none)]
612 fn tabBarController_willBeginCustomizingViewControllers(
613 &self,
614 tab_bar_controller: &UITabBarController,
615 view_controllers: &NSArray<UIViewController>,
616 );
617
618 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
619 #[optional]
620 #[unsafe(method(tabBarController:willEndCustomizingViewControllers:changed:))]
621 #[unsafe(method_family = none)]
622 fn tabBarController_willEndCustomizingViewControllers_changed(
623 &self,
624 tab_bar_controller: &UITabBarController,
625 view_controllers: &NSArray<UIViewController>,
626 changed: bool,
627 );
628
629 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
630 #[optional]
631 #[unsafe(method(tabBarController:didEndCustomizingViewControllers:changed:))]
632 #[unsafe(method_family = none)]
633 fn tabBarController_didEndCustomizingViewControllers_changed(
634 &self,
635 tab_bar_controller: &UITabBarController,
636 view_controllers: &NSArray<UIViewController>,
637 changed: bool,
638 );
639
640 #[cfg(all(
641 feature = "UIOrientation",
642 feature = "UIResponder",
643 feature = "UIViewController"
644 ))]
645 #[optional]
646 #[unsafe(method(tabBarControllerSupportedInterfaceOrientations:))]
647 #[unsafe(method_family = none)]
648 fn tabBarControllerSupportedInterfaceOrientations(
649 &self,
650 tab_bar_controller: &UITabBarController,
651 ) -> UIInterfaceOrientationMask;
652
653 #[cfg(all(
654 feature = "UIOrientation",
655 feature = "UIResponder",
656 feature = "UIViewController"
657 ))]
658 #[optional]
659 #[unsafe(method(tabBarControllerPreferredInterfaceOrientationForPresentation:))]
660 #[unsafe(method_family = none)]
661 fn tabBarControllerPreferredInterfaceOrientationForPresentation(
662 &self,
663 tab_bar_controller: &UITabBarController,
664 ) -> UIInterfaceOrientation;
665
666 #[cfg(all(
667 feature = "UIResponder",
668 feature = "UIViewController",
669 feature = "UIViewControllerTransitioning"
670 ))]
671 #[optional]
672 #[unsafe(method(tabBarController:interactionControllerForAnimationController:))]
673 #[unsafe(method_family = none)]
674 fn tabBarController_interactionControllerForAnimationController(
675 &self,
676 tab_bar_controller: &UITabBarController,
677 animation_controller: &ProtocolObject<dyn UIViewControllerAnimatedTransitioning>,
678 ) -> Option<Retained<ProtocolObject<dyn UIViewControllerInteractiveTransitioning>>>;
679
680 #[cfg(all(
681 feature = "UIResponder",
682 feature = "UIViewController",
683 feature = "UIViewControllerTransitioning"
684 ))]
685 #[optional]
686 #[unsafe(method(tabBarController:animationControllerForTransitionFromViewController:toViewController:))]
687 #[unsafe(method_family = none)]
688 fn tabBarController_animationControllerForTransitionFromViewController_toViewController(
689 &self,
690 tab_bar_controller: &UITabBarController,
691 from_vc: &UIViewController,
692 to_vc: &UIViewController,
693 ) -> Option<Retained<ProtocolObject<dyn UIViewControllerAnimatedTransitioning>>>;
694 }
695);
696
697#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
699impl UIViewController {
700 extern_methods!(
701 #[cfg(all(feature = "UIBarItem", feature = "UITabBarItem"))]
702 #[unsafe(method(tabBarItem))]
703 #[unsafe(method_family = none)]
704 pub fn tabBarItem(&self) -> Option<Retained<UITabBarItem>>;
705
706 #[cfg(all(feature = "UIBarItem", feature = "UITabBarItem"))]
707 #[unsafe(method(setTabBarItem:))]
713 #[unsafe(method_family = none)]
714 pub unsafe fn setTabBarItem(&self, tab_bar_item: Option<&UITabBarItem>);
715
716 #[unsafe(method(tabBarController))]
717 #[unsafe(method_family = none)]
718 pub fn tabBarController(&self) -> Option<Retained<UITabBarController>>;
719
720 #[cfg(all(feature = "UIScrollView", feature = "UIView"))]
721 #[deprecated = "Use -setContentScrollView:forEdge: instead."]
722 #[unsafe(method(tabBarObservedScrollView))]
723 #[unsafe(method_family = none)]
724 pub fn tabBarObservedScrollView(&self) -> Option<Retained<UIScrollView>>;
725
726 #[cfg(all(feature = "UIScrollView", feature = "UIView"))]
727 #[deprecated = "Use -setContentScrollView:forEdge: instead."]
729 #[unsafe(method(setTabBarObservedScrollView:))]
730 #[unsafe(method_family = none)]
731 pub fn setTabBarObservedScrollView(
732 &self,
733 tab_bar_observed_scroll_view: Option<&UIScrollView>,
734 );
735 );
736}