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")]
46extern_conformance!(
47    unsafe impl NSObjectProtocol for UITabGroup {}
48);
49
50#[cfg(feature = "UITab")]
51impl UITabGroup {
52    extern_methods!(
53        /// The currently selected tab. The tab must be part of `children`.
54        #[unsafe(method(selectedChild))]
55        #[unsafe(method_family = none)]
56        pub fn selectedChild(&self) -> Option<Retained<UITab>>;
57
58        /// Setter for [`selectedChild`][Self::selectedChild].
59        #[unsafe(method(setSelectedChild:))]
60        #[unsafe(method_family = none)]
61        pub fn setSelectedChild(&self, selected_child: Option<&UITab>);
62
63        /// The default child tab to select for when a selection is required and `selectedChild` is nil.
64        /// If this is nil, then the default selected element is the first element of `children`. Default is nil.
65        #[unsafe(method(defaultChildIdentifier))]
66        #[unsafe(method_family = none)]
67        pub fn defaultChildIdentifier(&self) -> Option<Retained<NSString>>;
68
69        /// Setter for [`defaultChildIdentifier`][Self::defaultChildIdentifier].
70        ///
71        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
72        #[unsafe(method(setDefaultChildIdentifier:))]
73        #[unsafe(method_family = none)]
74        pub fn setDefaultChildIdentifier(&self, default_child_identifier: Option<&NSString>);
75
76        /// Child tabs of the tab group. Default is an empty array.
77        #[unsafe(method(children))]
78        #[unsafe(method_family = none)]
79        pub fn children(&self) -> Retained<NSArray<UITab>>;
80
81        /// Setter for [`children`][Self::children].
82        ///
83        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
84        #[unsafe(method(setChildren:))]
85        #[unsafe(method_family = none)]
86        pub fn setChildren(&self, children: &NSArray<UITab>);
87
88        /// The display order of the children, represented by the identifiers. Default is empty.
89        /// Any tab in `children` not contained in `displayOrderIdentifiers` will be appended after
90        /// sorted items. Identifiers that do not match tabs in `children` will be ignored.
91        #[unsafe(method(displayOrderIdentifiers))]
92        #[unsafe(method_family = none)]
93        pub fn displayOrderIdentifiers(&self) -> Retained<NSArray<NSString>>;
94
95        /// Setter for [`displayOrderIdentifiers`][Self::displayOrderIdentifiers].
96        ///
97        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
98        #[unsafe(method(setDisplayOrderIdentifiers:))]
99        #[unsafe(method_family = none)]
100        pub fn setDisplayOrderIdentifiers(&self, display_order_identifiers: &NSArray<NSString>);
101
102        /// Determines if elements in `children` can be reordered from the sidebar. Default is NO.
103        /// Changes in the display order are notified via `tabBarController:didCustomizeDisplayOrderForGroup:`
104        /// in `UITabBarControllerDelegate`.
105        #[unsafe(method(allowsReordering))]
106        #[unsafe(method_family = none)]
107        pub fn allowsReordering(&self) -> bool;
108
109        /// Setter for [`allowsReordering`][Self::allowsReordering].
110        #[unsafe(method(setAllowsReordering:))]
111        #[unsafe(method_family = none)]
112        pub fn setAllowsReordering(&self, allows_reordering: bool);
113
114        /// Returns the `children` array sorted by `displayOrderIdentifiers` if it is specified.
115        /// Any tab in `children` not contained in the identifiers will be appended after
116        /// sorted items. Identifiers that do not match tabs in `children` will be ignored.
117        #[unsafe(method(displayOrder))]
118        #[unsafe(method_family = none)]
119        pub fn displayOrder(&self) -> Retained<NSArray<UITab>>;
120
121        /// Returns the `tab` matching the specified `identifier` in the group's children and its descendants.
122        /// Returns nil if no tab is found matching the `identifier`.
123        #[unsafe(method(tabForIdentifier:))]
124        #[unsafe(method_family = none)]
125        pub fn tabForIdentifier(&self, identifier: &NSString) -> Option<Retained<UITab>>;
126
127        #[cfg(all(
128            feature = "UINavigationController",
129            feature = "UIResponder",
130            feature = "UIViewController"
131        ))]
132        /// A navigation controller used to automatically manage the view controller hierarchy of the group.
133        /// Set a `UINavigationController` to allow the tab group to manage the hierarchy automatically.
134        /// The navigation stack of the managing navigation controller will be managed by the tab group based on
135        /// the selected tab of the group. When multiple navigation controllers are set on nested groups, the root-most
136        /// controller is used. Default is nil.
137        ///
138        /// By default, the navigation stack is represented by the view controller of each tab of the selected tree, if a
139        /// view controller is provided for that level. If no view controller is provided for that level, then it will be ignored.
140        ///
141        /// To customize the displayed view controllers per tab level of selection, implement the delegate method
142        /// `tabBarController:displayedViewControllersForTab:proposedViewControllers:`
143        /// on `UITabBarControllerDelegate`, which will propose a set of view controllers per level.
144        #[unsafe(method(managingNavigationController))]
145        #[unsafe(method_family = none)]
146        pub fn managingNavigationController(&self) -> Option<Retained<UINavigationController>>;
147
148        #[cfg(all(
149            feature = "UINavigationController",
150            feature = "UIResponder",
151            feature = "UIViewController"
152        ))]
153        /// Setter for [`managingNavigationController`][Self::managingNavigationController].
154        #[unsafe(method(setManagingNavigationController:))]
155        #[unsafe(method_family = none)]
156        pub fn setManagingNavigationController(
157            &self,
158            managing_navigation_controller: Option<&UINavigationController>,
159        );
160
161        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
162        /// Actions to display in the sidebar, after all tabs. Default is nil.
163        #[unsafe(method(sidebarActions))]
164        #[unsafe(method_family = none)]
165        pub fn sidebarActions(&self) -> Retained<NSArray<UIAction>>;
166
167        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
168        /// Setter for [`sidebarActions`][Self::sidebarActions].
169        ///
170        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
171        #[unsafe(method(setSidebarActions:))]
172        #[unsafe(method_family = none)]
173        pub fn setSidebarActions(&self, sidebar_actions: &NSArray<UIAction>);
174
175        /// The preferred appearance of the group and its children in the sidebar. Default is `automatic`
176        #[unsafe(method(sidebarAppearance))]
177        #[unsafe(method_family = none)]
178        pub fn sidebarAppearance(&self) -> UITabGroupSidebarAppearance;
179
180        /// Setter for [`sidebarAppearance`][Self::sidebarAppearance].
181        #[unsafe(method(setSidebarAppearance:))]
182        #[unsafe(method_family = none)]
183        pub fn setSidebarAppearance(&self, sidebar_appearance: UITabGroupSidebarAppearance);
184
185        #[cfg(all(
186            feature = "UIImage",
187            feature = "UIResponder",
188            feature = "UIViewController",
189            feature = "block2"
190        ))]
191        /// Creates a `UITabGroup` using the specified parameters.
192        ///
193        /// # Safety
194        ///
195        /// `view_controller_provider` block's return must be a valid pointer.
196        #[unsafe(method(initWithTitle:image:identifier:children:viewControllerProvider:))]
197        #[unsafe(method_family = init)]
198        pub unsafe fn initWithTitle_image_identifier_children_viewControllerProvider(
199            this: Allocated<Self>,
200            title: &NSString,
201            image: Option<&UIImage>,
202            identifier: &NSString,
203            children: &NSArray<UITab>,
204            view_controller_provider: Option<
205                &block2::DynBlock<dyn Fn(NonNull<UITab>) -> NonNull<UIViewController>>,
206            >,
207        ) -> Retained<Self>;
208    );
209}
210
211/// Methods declared on superclass `UITab`.
212#[cfg(feature = "UITab")]
213impl UITabGroup {
214    extern_methods!(
215        #[cfg(all(
216            feature = "UIImage",
217            feature = "UIResponder",
218            feature = "UIViewController",
219            feature = "block2"
220        ))]
221        /// Creates a tab with the specified identifier, title, image, and view controller provider.
222        /// The view controller provider is called when a view controller is requested and is currently nil.
223        /// For root level tabs on `UITabBarController`, the resolved view controller must be non-nil.
224        ///
225        /// # Safety
226        ///
227        /// `view_controller_provider` block's return must be a valid pointer.
228        #[unsafe(method(initWithTitle:image:identifier:viewControllerProvider:))]
229        #[unsafe(method_family = init)]
230        pub unsafe fn initWithTitle_image_identifier_viewControllerProvider(
231            this: Allocated<Self>,
232            title: &NSString,
233            image: Option<&UIImage>,
234            identifier: &NSString,
235            view_controller_provider: Option<
236                &block2::DynBlock<dyn Fn(NonNull<UITab>) -> NonNull<UIViewController>>,
237            >,
238        ) -> Retained<Self>;
239
240        #[unsafe(method(init))]
241        #[unsafe(method_family = init)]
242        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
243
244        #[unsafe(method(new))]
245        #[unsafe(method_family = new)]
246        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
247    );
248}