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
37extern_class!(
38 #[unsafe(super(UIViewController, UIResponder, NSObject))]
50 #[thread_kind = MainThreadOnly]
51 #[derive(Debug, PartialEq, Eq, Hash)]
52 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
53 pub struct UITabBarController;
54);
55
56#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
57extern_conformance!(
58 unsafe impl NSCoding for UITabBarController {}
59);
60
61#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
62extern_conformance!(
63 unsafe impl NSObjectProtocol for UITabBarController {}
64);
65
66#[cfg(all(
67 feature = "UIAppearance",
68 feature = "UIResponder",
69 feature = "UIViewController"
70))]
71extern_conformance!(
72 unsafe impl UIAppearanceContainer for UITabBarController {}
73);
74
75#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
76extern_conformance!(
77 unsafe impl UIContentContainer for UITabBarController {}
78);
79
80#[cfg(all(
81 feature = "UIFocus",
82 feature = "UIResponder",
83 feature = "UIViewController"
84))]
85extern_conformance!(
86 unsafe impl UIFocusEnvironment for UITabBarController {}
87);
88
89#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
90extern_conformance!(
91 unsafe impl UIResponderStandardEditActions for UITabBarController {}
92);
93
94#[cfg(all(
95 feature = "UIResponder",
96 feature = "UITabBar",
97 feature = "UIViewController"
98))]
99extern_conformance!(
100 unsafe impl UITabBarDelegate for UITabBarController {}
101);
102
103#[cfg(all(
104 feature = "UIResponder",
105 feature = "UITraitCollection",
106 feature = "UIViewController"
107))]
108extern_conformance!(
109 unsafe impl UITraitEnvironment for UITabBarController {}
110);
111
112#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
113impl UITabBarController {
114 extern_methods!(
115 #[unsafe(method(delegate))]
117 #[unsafe(method_family = none)]
118 pub unsafe fn delegate(
119 &self,
120 ) -> Option<Retained<ProtocolObject<dyn UITabBarControllerDelegate>>>;
121
122 #[unsafe(method(setDelegate:))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn setDelegate(
127 &self,
128 delegate: Option<&ProtocolObject<dyn UITabBarControllerDelegate>>,
129 );
130
131 #[unsafe(method(mode))]
133 #[unsafe(method_family = none)]
134 pub unsafe fn mode(&self) -> UITabBarControllerMode;
135
136 #[unsafe(method(setMode:))]
138 #[unsafe(method_family = none)]
139 pub unsafe fn setMode(&self, mode: UITabBarControllerMode);
140
141 #[cfg(feature = "UITabBarControllerSidebar")]
142 #[unsafe(method(sidebar))]
144 #[unsafe(method_family = none)]
145 pub unsafe fn sidebar(&self) -> Retained<UITabBarControllerSidebar>;
146
147 #[unsafe(method(customizationIdentifier))]
150 #[unsafe(method_family = none)]
151 pub unsafe fn customizationIdentifier(&self) -> Option<Retained<NSString>>;
152
153 #[unsafe(method(setCustomizationIdentifier:))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn setCustomizationIdentifier(
157 &self,
158 customization_identifier: Option<&NSString>,
159 );
160
161 #[unsafe(method(compactTabIdentifiers))]
163 #[unsafe(method_family = none)]
164 pub unsafe fn compactTabIdentifiers(&self) -> Option<Retained<NSArray<NSString>>>;
165
166 #[unsafe(method(setCompactTabIdentifiers:))]
168 #[unsafe(method_family = none)]
169 pub unsafe fn setCompactTabIdentifiers(
170 &self,
171 compact_tab_identifiers: Option<&NSArray<NSString>>,
172 );
173
174 #[cfg(feature = "UITab")]
175 #[unsafe(method(selectedTab))]
177 #[unsafe(method_family = none)]
178 pub unsafe fn selectedTab(&self) -> Option<Retained<UITab>>;
179
180 #[cfg(feature = "UITab")]
181 #[unsafe(method(setSelectedTab:))]
183 #[unsafe(method_family = none)]
184 pub unsafe fn setSelectedTab(&self, selected_tab: Option<&UITab>);
185
186 #[cfg(feature = "UITab")]
187 #[unsafe(method(tabs))]
190 #[unsafe(method_family = none)]
191 pub unsafe fn tabs(&self) -> Retained<NSArray<UITab>>;
192
193 #[cfg(feature = "UITab")]
194 #[unsafe(method(setTabs:))]
196 #[unsafe(method_family = none)]
197 pub unsafe fn setTabs(&self, tabs: &NSArray<UITab>);
198
199 #[cfg(feature = "UITab")]
200 #[unsafe(method(setTabs:animated:))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn setTabs_animated(&self, tabs: &NSArray<UITab>, animated: bool);
204
205 #[cfg(feature = "UITab")]
206 #[unsafe(method(tabForIdentifier:))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn tabForIdentifier(&self, identifier: &NSString) -> Option<Retained<UITab>>;
210
211 #[cfg(feature = "UITab")]
212 #[unsafe(method(initWithTabs:))]
214 #[unsafe(method_family = init)]
215 pub unsafe fn initWithTabs(this: Allocated<Self>, tabs: &NSArray<UITab>) -> Retained<Self>;
216
217 #[unsafe(method(isTabBarHidden))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn isTabBarHidden(&self) -> bool;
221
222 #[unsafe(method(setTabBarHidden:))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn setTabBarHidden(&self, tab_bar_hidden: bool);
226
227 #[unsafe(method(setTabBarHidden:animated:))]
229 #[unsafe(method_family = none)]
230 pub unsafe fn setTabBarHidden_animated(&self, hidden: bool, animated: bool);
231
232 #[unsafe(method(viewControllers))]
233 #[unsafe(method_family = none)]
234 pub unsafe fn viewControllers(&self) -> Option<Retained<NSArray<UIViewController>>>;
235
236 #[unsafe(method(setViewControllers:))]
238 #[unsafe(method_family = none)]
239 pub unsafe fn setViewControllers(
240 &self,
241 view_controllers: Option<&NSArray<UIViewController>>,
242 );
243
244 #[unsafe(method(setViewControllers:animated:))]
245 #[unsafe(method_family = none)]
246 pub unsafe fn setViewControllers_animated(
247 &self,
248 view_controllers: Option<&NSArray<UIViewController>>,
249 animated: bool,
250 );
251
252 #[unsafe(method(selectedViewController))]
253 #[unsafe(method_family = none)]
254 pub unsafe fn selectedViewController(&self) -> Option<Retained<UIViewController>>;
255
256 #[unsafe(method(setSelectedViewController:))]
258 #[unsafe(method_family = none)]
259 pub unsafe fn setSelectedViewController(
260 &self,
261 selected_view_controller: Option<&UIViewController>,
262 );
263
264 #[unsafe(method(selectedIndex))]
265 #[unsafe(method_family = none)]
266 pub unsafe fn selectedIndex(&self) -> NSUInteger;
267
268 #[unsafe(method(setSelectedIndex:))]
270 #[unsafe(method_family = none)]
271 pub unsafe fn setSelectedIndex(&self, selected_index: NSUInteger);
272
273 #[cfg(feature = "UINavigationController")]
274 #[unsafe(method(moreNavigationController))]
275 #[unsafe(method_family = none)]
276 pub unsafe fn moreNavigationController(&self) -> Retained<UINavigationController>;
277
278 #[unsafe(method(customizableViewControllers))]
279 #[unsafe(method_family = none)]
280 pub unsafe fn customizableViewControllers(
281 &self,
282 ) -> Option<Retained<NSArray<UIViewController>>>;
283
284 #[unsafe(method(setCustomizableViewControllers:))]
286 #[unsafe(method_family = none)]
287 pub unsafe fn setCustomizableViewControllers(
288 &self,
289 customizable_view_controllers: Option<&NSArray<UIViewController>>,
290 );
291
292 #[cfg(all(feature = "UITabBar", feature = "UIView"))]
293 #[unsafe(method(tabBar))]
294 #[unsafe(method_family = none)]
295 pub unsafe fn tabBar(&self) -> Retained<UITabBar>;
296 );
297}
298
299#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
301impl UITabBarController {
302 extern_methods!(
303 #[unsafe(method(initWithNibName:bundle:))]
304 #[unsafe(method_family = init)]
305 pub unsafe fn initWithNibName_bundle(
306 this: Allocated<Self>,
307 nib_name_or_nil: Option<&NSString>,
308 nib_bundle_or_nil: Option<&NSBundle>,
309 ) -> Retained<Self>;
310
311 #[unsafe(method(initWithCoder:))]
312 #[unsafe(method_family = init)]
313 pub unsafe fn initWithCoder(
314 this: Allocated<Self>,
315 coder: &NSCoder,
316 ) -> Option<Retained<Self>>;
317 );
318}
319
320#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
322impl UITabBarController {
323 extern_methods!(
324 #[unsafe(method(init))]
325 #[unsafe(method_family = init)]
326 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
327
328 #[unsafe(method(new))]
329 #[unsafe(method_family = new)]
330 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
331 );
332}
333
334extern_protocol!(
335 pub unsafe trait UITabBarControllerDelegate: NSObjectProtocol + MainThreadOnly {
337 #[cfg(all(
338 feature = "UIResponder",
339 feature = "UITab",
340 feature = "UIViewController"
341 ))]
342 #[optional]
344 #[unsafe(method(tabBarController:shouldSelectTab:))]
345 #[unsafe(method_family = none)]
346 unsafe fn tabBarController_shouldSelectTab(
347 &self,
348 tab_bar_controller: &UITabBarController,
349 tab: &UITab,
350 ) -> bool;
351
352 #[cfg(all(
353 feature = "UIResponder",
354 feature = "UITab",
355 feature = "UIViewController"
356 ))]
357 #[optional]
359 #[unsafe(method(tabBarController:didSelectTab:previousTab:))]
360 #[unsafe(method_family = none)]
361 unsafe fn tabBarController_didSelectTab_previousTab(
362 &self,
363 tab_bar_controller: &UITabBarController,
364 selected_tab: &UITab,
365 previous_tab: Option<&UITab>,
366 );
367
368 #[cfg(all(
369 feature = "UIDragSession",
370 feature = "UIDropInteraction",
371 feature = "UIResponder",
372 feature = "UITab",
373 feature = "UIViewController"
374 ))]
375 #[optional]
379 #[unsafe(method(tabBarController:tab:operationForAcceptingItemsFromDropSession:))]
380 #[unsafe(method_family = none)]
381 unsafe fn tabBarController_tab_operationForAcceptingItemsFromDropSession(
382 &self,
383 tab_bar_controller: &UITabBarController,
384 tab: &UITab,
385 session: &ProtocolObject<dyn UIDropSession>,
386 ) -> UIDropOperation;
387
388 #[cfg(all(
389 feature = "UIDragSession",
390 feature = "UIResponder",
391 feature = "UITab",
392 feature = "UIViewController"
393 ))]
394 #[optional]
397 #[unsafe(method(tabBarController:tab:acceptItemsFromDropSession:))]
398 #[unsafe(method_family = none)]
399 unsafe fn tabBarController_tab_acceptItemsFromDropSession(
400 &self,
401 tab_bar_controller: &UITabBarController,
402 tab: &UITab,
403 session: &ProtocolObject<dyn UIDropSession>,
404 );
405
406 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
407 #[optional]
409 #[unsafe(method(tabBarControllerWillBeginEditing:))]
410 #[unsafe(method_family = none)]
411 unsafe fn tabBarControllerWillBeginEditing(&self, tab_bar_controller: &UITabBarController);
412
413 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
414 #[optional]
416 #[unsafe(method(tabBarControllerDidEndEditing:))]
417 #[unsafe(method_family = none)]
418 unsafe fn tabBarControllerDidEndEditing(&self, tab_bar_controller: &UITabBarController);
419
420 #[cfg(all(
421 feature = "UIResponder",
422 feature = "UITab",
423 feature = "UIViewController"
424 ))]
425 #[optional]
427 #[unsafe(method(tabBarController:visibilityDidChangeForTabs:))]
428 #[unsafe(method_family = none)]
429 unsafe fn tabBarController_visibilityDidChangeForTabs(
430 &self,
431 tab_bar_controller: &UITabBarController,
432 tabs: &NSArray<UITab>,
433 );
434
435 #[cfg(all(
436 feature = "UIResponder",
437 feature = "UITab",
438 feature = "UITabGroup",
439 feature = "UIViewController"
440 ))]
441 #[optional]
443 #[unsafe(method(tabBarController:displayOrderDidChangeForGroup:))]
444 #[unsafe(method_family = none)]
445 unsafe fn tabBarController_displayOrderDidChangeForGroup(
446 &self,
447 tab_bar_controller: &UITabBarController,
448 group: &UITabGroup,
449 );
450
451 #[cfg(all(
452 feature = "UIResponder",
453 feature = "UITab",
454 feature = "UIViewController"
455 ))]
456 #[optional]
472 #[unsafe(method(tabBarController:displayedViewControllersForTab:proposedViewControllers:))]
473 #[unsafe(method_family = none)]
474 unsafe fn tabBarController_displayedViewControllersForTab_proposedViewControllers(
475 &self,
476 tab_bar_controller: &UITabBarController,
477 tab: &UITab,
478 proposed_view_controllers: &NSArray<UIViewController>,
479 ) -> Retained<NSArray<UIViewController>>;
480
481 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
482 #[optional]
483 #[unsafe(method(tabBarController:shouldSelectViewController:))]
484 #[unsafe(method_family = none)]
485 unsafe fn tabBarController_shouldSelectViewController(
486 &self,
487 tab_bar_controller: &UITabBarController,
488 view_controller: &UIViewController,
489 ) -> bool;
490
491 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
492 #[optional]
493 #[unsafe(method(tabBarController:didSelectViewController:))]
494 #[unsafe(method_family = none)]
495 unsafe fn tabBarController_didSelectViewController(
496 &self,
497 tab_bar_controller: &UITabBarController,
498 view_controller: &UIViewController,
499 );
500
501 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
502 #[optional]
503 #[unsafe(method(tabBarController:willBeginCustomizingViewControllers:))]
504 #[unsafe(method_family = none)]
505 unsafe fn tabBarController_willBeginCustomizingViewControllers(
506 &self,
507 tab_bar_controller: &UITabBarController,
508 view_controllers: &NSArray<UIViewController>,
509 );
510
511 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
512 #[optional]
513 #[unsafe(method(tabBarController:willEndCustomizingViewControllers:changed:))]
514 #[unsafe(method_family = none)]
515 unsafe fn tabBarController_willEndCustomizingViewControllers_changed(
516 &self,
517 tab_bar_controller: &UITabBarController,
518 view_controllers: &NSArray<UIViewController>,
519 changed: bool,
520 );
521
522 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
523 #[optional]
524 #[unsafe(method(tabBarController:didEndCustomizingViewControllers:changed:))]
525 #[unsafe(method_family = none)]
526 unsafe fn tabBarController_didEndCustomizingViewControllers_changed(
527 &self,
528 tab_bar_controller: &UITabBarController,
529 view_controllers: &NSArray<UIViewController>,
530 changed: bool,
531 );
532
533 #[cfg(all(
534 feature = "UIOrientation",
535 feature = "UIResponder",
536 feature = "UIViewController"
537 ))]
538 #[optional]
539 #[unsafe(method(tabBarControllerSupportedInterfaceOrientations:))]
540 #[unsafe(method_family = none)]
541 unsafe fn tabBarControllerSupportedInterfaceOrientations(
542 &self,
543 tab_bar_controller: &UITabBarController,
544 ) -> UIInterfaceOrientationMask;
545
546 #[cfg(all(
547 feature = "UIOrientation",
548 feature = "UIResponder",
549 feature = "UIViewController"
550 ))]
551 #[optional]
552 #[unsafe(method(tabBarControllerPreferredInterfaceOrientationForPresentation:))]
553 #[unsafe(method_family = none)]
554 unsafe fn tabBarControllerPreferredInterfaceOrientationForPresentation(
555 &self,
556 tab_bar_controller: &UITabBarController,
557 ) -> UIInterfaceOrientation;
558
559 #[cfg(all(
560 feature = "UIResponder",
561 feature = "UIViewController",
562 feature = "UIViewControllerTransitioning"
563 ))]
564 #[optional]
565 #[unsafe(method(tabBarController:interactionControllerForAnimationController:))]
566 #[unsafe(method_family = none)]
567 unsafe fn tabBarController_interactionControllerForAnimationController(
568 &self,
569 tab_bar_controller: &UITabBarController,
570 animation_controller: &ProtocolObject<dyn UIViewControllerAnimatedTransitioning>,
571 ) -> Option<Retained<ProtocolObject<dyn UIViewControllerInteractiveTransitioning>>>;
572
573 #[cfg(all(
574 feature = "UIResponder",
575 feature = "UIViewController",
576 feature = "UIViewControllerTransitioning"
577 ))]
578 #[optional]
579 #[unsafe(method(tabBarController:animationControllerForTransitionFromViewController:toViewController:))]
580 #[unsafe(method_family = none)]
581 unsafe fn tabBarController_animationControllerForTransitionFromViewController_toViewController(
582 &self,
583 tab_bar_controller: &UITabBarController,
584 from_vc: &UIViewController,
585 to_vc: &UIViewController,
586 ) -> Option<Retained<ProtocolObject<dyn UIViewControllerAnimatedTransitioning>>>;
587 }
588);
589
590#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
592impl UIViewController {
593 extern_methods!(
594 #[cfg(all(feature = "UIBarItem", feature = "UITabBarItem"))]
595 #[unsafe(method(tabBarItem))]
596 #[unsafe(method_family = none)]
597 pub unsafe fn tabBarItem(&self) -> Option<Retained<UITabBarItem>>;
598
599 #[cfg(all(feature = "UIBarItem", feature = "UITabBarItem"))]
600 #[unsafe(method(setTabBarItem:))]
602 #[unsafe(method_family = none)]
603 pub unsafe fn setTabBarItem(&self, tab_bar_item: Option<&UITabBarItem>);
604
605 #[unsafe(method(tabBarController))]
606 #[unsafe(method_family = none)]
607 pub unsafe fn tabBarController(&self) -> Option<Retained<UITabBarController>>;
608
609 #[cfg(all(feature = "UIScrollView", feature = "UIView"))]
610 #[deprecated = "Use -setContentScrollView:forEdge: instead."]
611 #[unsafe(method(tabBarObservedScrollView))]
612 #[unsafe(method_family = none)]
613 pub unsafe fn tabBarObservedScrollView(&self) -> Option<Retained<UIScrollView>>;
614
615 #[cfg(all(feature = "UIScrollView", feature = "UIView"))]
616 #[deprecated = "Use -setContentScrollView:forEdge: instead."]
618 #[unsafe(method(setTabBarObservedScrollView:))]
619 #[unsafe(method_family = none)]
620 pub unsafe fn setTabBarObservedScrollView(
621 &self,
622 tab_bar_observed_scroll_view: Option<&UIScrollView>,
623 );
624 );
625}