objc2_ui_kit/generated/
UITabGroup.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitabgroupsidebarappearance?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct UITabGroupSidebarAppearance(pub NSUInteger);
15impl UITabGroupSidebarAppearance {
16    /// The default appearance showing the group and its children appropriately depending
17    /// on the group level it is in.
18    #[doc(alias = "UITabGroupSidebarAppearanceAutomatic")]
19    pub const Automatic: Self = Self(0);
20    /// Displays only the children alongside the group's siblings.
21    #[doc(alias = "UITabGroupSidebarAppearanceInline")]
22    pub const Inline: Self = Self(1);
23    /// Displays the group and its children as a top-level group of the sidebar.
24    #[doc(alias = "UITabGroupSidebarAppearanceRootSection")]
25    pub const RootSection: Self = Self(2);
26}
27
28unsafe impl Encode for UITabGroupSidebarAppearance {
29    const ENCODING: Encoding = NSUInteger::ENCODING;
30}
31
32unsafe impl RefEncode for UITabGroupSidebarAppearance {
33    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36extern_class!(
37    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitabgroup?language=objc)
38    #[unsafe(super(UITab, NSObject))]
39    #[thread_kind = MainThreadOnly]
40    #[derive(Debug, PartialEq, Eq, Hash)]
41    #[cfg(feature = "UITab")]
42    pub struct UITabGroup;
43);
44
45#[cfg(feature = "UITab")]
46unsafe impl NSObjectProtocol for UITabGroup {}
47
48#[cfg(feature = "UITab")]
49impl UITabGroup {
50    extern_methods!(
51        /// The currently selected tab. The tab must be part of `children`.
52        #[unsafe(method(selectedChild))]
53        #[unsafe(method_family = none)]
54        pub unsafe fn selectedChild(&self) -> Option<Retained<UITab>>;
55
56        /// Setter for [`selectedChild`][Self::selectedChild].
57        #[unsafe(method(setSelectedChild:))]
58        #[unsafe(method_family = none)]
59        pub unsafe fn setSelectedChild(&self, selected_child: Option<&UITab>);
60
61        /// The default child tab to select for when a selection is required and `selectedChild` is nil.
62        /// If this is nil, then the default selected element is the first element of `children`. Default is nil.
63        #[unsafe(method(defaultChildIdentifier))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn defaultChildIdentifier(&self) -> Option<Retained<NSString>>;
66
67        /// Setter for [`defaultChildIdentifier`][Self::defaultChildIdentifier].
68        #[unsafe(method(setDefaultChildIdentifier:))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn setDefaultChildIdentifier(&self, default_child_identifier: Option<&NSString>);
71
72        /// Child tabs of the tab group. Default is an empty array.
73        #[unsafe(method(children))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn children(&self) -> Retained<NSArray<UITab>>;
76
77        /// Setter for [`children`][Self::children].
78        #[unsafe(method(setChildren:))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn setChildren(&self, children: &NSArray<UITab>);
81
82        /// The display order of the children, represented by the identifiers. Default is empty.
83        /// Any tab in `children` not contained in `displayOrderIdentifiers` will be appended after
84        /// sorted items. Identifiers that do not match tabs in `children` will be ignored.
85        #[unsafe(method(displayOrderIdentifiers))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn displayOrderIdentifiers(&self) -> Retained<NSArray<NSString>>;
88
89        /// Setter for [`displayOrderIdentifiers`][Self::displayOrderIdentifiers].
90        #[unsafe(method(setDisplayOrderIdentifiers:))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn setDisplayOrderIdentifiers(
93            &self,
94            display_order_identifiers: &NSArray<NSString>,
95        );
96
97        /// Determines if elements in `children` can be reordered from the sidebar. Default is NO.
98        /// Changes in the display order are notified via `tabBarController:didCustomizeDisplayOrderForGroup:`
99        /// in `UITabBarControllerDelegate`.
100        #[unsafe(method(allowsReordering))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn allowsReordering(&self) -> bool;
103
104        /// Setter for [`allowsReordering`][Self::allowsReordering].
105        #[unsafe(method(setAllowsReordering:))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn setAllowsReordering(&self, allows_reordering: bool);
108
109        /// Returns the `children` array sorted by `displayOrderIdentifiers` if it is specified.
110        /// Any tab in `children` not contained in the identifiers will be appended after
111        /// sorted items. Identifiers that do not match tabs in `children` will be ignored.
112        #[unsafe(method(displayOrder))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn displayOrder(&self) -> Retained<NSArray<UITab>>;
115
116        /// Returns the `tab` matching the specified `identifier` in the group's children and its descendants.
117        /// Returns nil if no tab is found matching the `identifier`.
118        #[unsafe(method(tabForIdentifier:))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn tabForIdentifier(&self, identifier: &NSString) -> Option<Retained<UITab>>;
121
122        #[cfg(all(
123            feature = "UINavigationController",
124            feature = "UIResponder",
125            feature = "UIViewController"
126        ))]
127        /// A navigation controller used to automatically manage the view controller hierarchy of the group.
128        /// Set a `UINavigationController` to allow the tab group to manage the hierarchy automatically.
129        /// The navigation stack of the managing navigation controller will be managed by the tab group based on
130        /// the selected tab of the group. When multiple navigation controllers are set on nested groups, the rootmost
131        /// controller is used. Default is nil.
132        ///
133        /// By default, the navigation stack is represented by the view controller of each tab of the selected tree, if a
134        /// view controller is provided for that level. If no view controller is provided for that level, then it will be ignored.
135        ///
136        /// To customize the displayed view controllers per tab level of selection, implement the delegate method
137        /// `tabBarController:displayedViewControllersForTab:proposedViewControllers:`
138        /// on `UITabBarControllerDelegate`, which will propose a set of view controllers per level.
139        #[unsafe(method(managingNavigationController))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn managingNavigationController(
142            &self,
143        ) -> Option<Retained<UINavigationController>>;
144
145        #[cfg(all(
146            feature = "UINavigationController",
147            feature = "UIResponder",
148            feature = "UIViewController"
149        ))]
150        /// Setter for [`managingNavigationController`][Self::managingNavigationController].
151        #[unsafe(method(setManagingNavigationController:))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn setManagingNavigationController(
154            &self,
155            managing_navigation_controller: Option<&UINavigationController>,
156        );
157
158        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
159        /// Actions to display in the sidebar, after all tabs. Default is nil.
160        #[unsafe(method(sidebarActions))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn sidebarActions(&self) -> Retained<NSArray<UIAction>>;
163
164        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
165        /// Setter for [`sidebarActions`][Self::sidebarActions].
166        #[unsafe(method(setSidebarActions:))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn setSidebarActions(&self, sidebar_actions: &NSArray<UIAction>);
169
170        /// The preferred appearance of the group and its children in the sidebar. Default is `automatic`
171        #[unsafe(method(sidebarAppearance))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn sidebarAppearance(&self) -> UITabGroupSidebarAppearance;
174
175        /// Setter for [`sidebarAppearance`][Self::sidebarAppearance].
176        #[unsafe(method(setSidebarAppearance:))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn setSidebarAppearance(&self, sidebar_appearance: UITabGroupSidebarAppearance);
179
180        #[cfg(all(
181            feature = "UIImage",
182            feature = "UIResponder",
183            feature = "UIViewController",
184            feature = "block2"
185        ))]
186        /// Creates a `UITabGroup` using the specified parameters.
187        #[unsafe(method(initWithTitle:image:identifier:children:viewControllerProvider:))]
188        #[unsafe(method_family = init)]
189        pub unsafe fn initWithTitle_image_identifier_children_viewControllerProvider(
190            this: Allocated<Self>,
191            title: &NSString,
192            image: Option<&UIImage>,
193            identifier: &NSString,
194            children: &NSArray<UITab>,
195            view_controller_provider: Option<
196                &block2::Block<dyn Fn(NonNull<UITab>) -> NonNull<UIViewController>>,
197            >,
198        ) -> Retained<Self>;
199    );
200}
201
202/// Methods declared on superclass `UITab`.
203#[cfg(feature = "UITab")]
204impl UITabGroup {
205    extern_methods!(
206        #[cfg(all(
207            feature = "UIImage",
208            feature = "UIResponder",
209            feature = "UIViewController",
210            feature = "block2"
211        ))]
212        /// Creates a tab with the specified identifier, title, image, and view controller provider.
213        /// The view controller provider is called when a view controller is requested and is currently nil.
214        /// For root level tabs on `UITabBarController`, the resolved view controller must be non-nil.
215        #[unsafe(method(initWithTitle:image:identifier:viewControllerProvider:))]
216        #[unsafe(method_family = init)]
217        pub unsafe fn initWithTitle_image_identifier_viewControllerProvider(
218            this: Allocated<Self>,
219            title: &NSString,
220            image: Option<&UIImage>,
221            identifier: &NSString,
222            view_controller_provider: Option<
223                &block2::Block<dyn Fn(NonNull<UITab>) -> NonNull<UIViewController>>,
224            >,
225        ) -> Retained<Self>;
226
227        #[unsafe(method(init))]
228        #[unsafe(method_family = init)]
229        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
230
231        #[unsafe(method(new))]
232        #[unsafe(method_family = new)]
233        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
234    );
235}