objc2_ui_kit/generated/
UITab.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/uitabplacement?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct UITabPlacement(pub NSInteger);
15impl UITabPlacement {
16    /// Resolves to `.default` for root-level tabs, and `.optional` for all others.
17    #[doc(alias = "UITabPlacementAutomatic")]
18    pub const Automatic: Self = Self(0);
19    /// The tab can be added or removed from the tab bar, and appears by default.
20    #[doc(alias = "UITabPlacementDefault")]
21    pub const Default: Self = Self(1);
22    /// The tab can be added or removed from the tab bar, but does NOT appear by default.
23    #[doc(alias = "UITabPlacementOptional")]
24    pub const Optional: Self = Self(2);
25    /// The tab cannot be removed from the tab bar, but can be moved within.
26    #[doc(alias = "UITabPlacementMovable")]
27    pub const Movable: Self = Self(3);
28    /// The tab is always available and visible in the tab bar.
29    /// Pinned items are placed at the trailing side of the bar.
30    #[doc(alias = "UITabPlacementPinned")]
31    pub const Pinned: Self = Self(4);
32    /// The tab cannot be moved or removed from the tab bar, and is displayed before
33    /// all customizable tabs.
34    #[doc(alias = "UITabPlacementFixed")]
35    pub const Fixed: Self = Self(5);
36    /// The tab cannot be added to the tab bar.
37    #[doc(alias = "UITabPlacementSidebarOnly")]
38    pub const SidebarOnly: Self = Self(6);
39}
40
41unsafe impl Encode for UITabPlacement {
42    const ENCODING: Encoding = NSInteger::ENCODING;
43}
44
45unsafe impl RefEncode for UITabPlacement {
46    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
47}
48
49extern_class!(
50    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitab?language=objc)
51    #[unsafe(super(NSObject))]
52    #[thread_kind = MainThreadOnly]
53    #[derive(Debug, PartialEq, Eq, Hash)]
54    pub struct UITab;
55);
56
57extern_conformance!(
58    unsafe impl NSObjectProtocol for UITab {}
59);
60
61impl UITab {
62    extern_methods!(
63        /// The identifier associated with the tab, must be unique across the tab bar controller.
64        #[unsafe(method(identifier))]
65        #[unsafe(method_family = none)]
66        pub unsafe fn identifier(&self) -> Retained<NSString>;
67
68        /// Determines if the tab is enabled. When NO, tabs will have a disabled appearance and cannot be selected by the user.
69        /// Default is YES.
70        #[unsafe(method(isEnabled))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn isEnabled(&self) -> bool;
73
74        /// Setter for [`isEnabled`][Self::isEnabled].
75        #[unsafe(method(setEnabled:))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn setEnabled(&self, enabled: bool);
78
79        /// The title of the tab.
80        #[unsafe(method(title))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn title(&self) -> Retained<NSString>;
83
84        /// Setter for [`title`][Self::title].
85        #[unsafe(method(setTitle:))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn setTitle(&self, title: &NSString);
88
89        #[cfg(feature = "UIImage")]
90        /// The image of the tab. Default is nil.
91        #[unsafe(method(image))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn image(&self) -> Option<Retained<UIImage>>;
94
95        #[cfg(feature = "UIImage")]
96        /// Setter for [`image`][Self::image].
97        #[unsafe(method(setImage:))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn setImage(&self, image: Option<&UIImage>);
100
101        /// The subtitle of the tab. This is displayed only in certain contexts, like the sidebar. Default is nil.
102        #[unsafe(method(subtitle))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn subtitle(&self) -> Option<Retained<NSString>>;
105
106        /// Setter for [`subtitle`][Self::subtitle].
107        #[unsafe(method(setSubtitle:))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn setSubtitle(&self, subtitle: Option<&NSString>);
110
111        /// The badge value of the tab. Default is nil.
112        #[unsafe(method(badgeValue))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn badgeValue(&self) -> Option<Retained<NSString>>;
115
116        /// Setter for [`badgeValue`][Self::badgeValue].
117        #[unsafe(method(setBadgeValue:))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn setBadgeValue(&self, badge_value: Option<&NSString>);
120
121        /// The preferred placement for the tab in the contexts that allow for different tab placements.
122        /// Default is `UITabPlacementAutomatic` which resolves its placement based on context.
123        #[unsafe(method(preferredPlacement))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn preferredPlacement(&self) -> UITabPlacement;
126
127        /// Setter for [`preferredPlacement`][Self::preferredPlacement].
128        #[unsafe(method(setPreferredPlacement:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn setPreferredPlacement(&self, preferred_placement: UITabPlacement);
131
132        /// A custom object associated with the tab. Default is nil.
133        #[unsafe(method(userInfo))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn userInfo(&self) -> Option<Retained<AnyObject>>;
136
137        /// Setter for [`userInfo`][Self::userInfo].
138        #[unsafe(method(setUserInfo:))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn setUserInfo(&self, user_info: Option<&AnyObject>);
141
142        #[cfg(feature = "UITabGroup")]
143        /// The parent group of the tab. This is only non-nil if the tab is part of a parent group, and returns nil otherwise.
144        #[unsafe(method(parent))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn parent(&self) -> Option<Retained<UITabGroup>>;
147
148        #[cfg(all(
149            feature = "UIResponder",
150            feature = "UITabBarController",
151            feature = "UIViewController"
152        ))]
153        /// The tab bar controller managing the tab. This is non-nil when the tab
154        /// or any of its ancestors is added to a UITabBarController; and is nil
155        /// otherwise.
156        #[unsafe(method(tabBarController))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn tabBarController(&self) -> Option<Retained<UITabBarController>>;
159
160        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
161        /// The view controller owned by the tab. The view controller provider is used to resolve the view controller
162        /// if it is currently nil. For root level tabs, the view controller for the tab must be non-nil.
163        #[unsafe(method(viewController))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn viewController(&self) -> Option<Retained<UIViewController>>;
166
167        #[cfg(feature = "UITabGroup")]
168        /// The managing tab group for the tab. This returns the rootmost `UITabGroup` in the tab's parent hierarchy with an
169        /// active `managingNavigationController`. This can be different to `parent` if the tab is nested in multiple
170        /// levels of tab groups. If the tab does not belong to a hierarchy with a managing navigation controller, then this
171        /// will return nil. Default is nil.
172        #[unsafe(method(managingTabGroup))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn managingTabGroup(&self) -> Option<Retained<UITabGroup>>;
175
176        /// Determines if the tab is currently hidden. Default is NO.
177        /// Hidden tabs cannot be accessed from the sidebar.
178        #[unsafe(method(isHidden))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn isHidden(&self) -> bool;
181
182        /// Setter for [`isHidden`][Self::isHidden].
183        #[unsafe(method(setHidden:))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn setHidden(&self, hidden: bool);
186
187        /// The default hidden state. When the user resets their customization, `UITab.hidden` will be set to the value
188        /// of this property. Default is NO.
189        #[unsafe(method(isHiddenByDefault))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn isHiddenByDefault(&self) -> bool;
192
193        /// Setter for [`isHiddenByDefault`][Self::isHiddenByDefault].
194        #[unsafe(method(setHiddenByDefault:))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn setHiddenByDefault(&self, hidden_by_default: bool);
197
198        /// Determines if the tab's visibility can be changed by the user while editing. Default is NO.
199        #[unsafe(method(allowsHiding))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn allowsHiding(&self) -> bool;
202
203        /// Setter for [`allowsHiding`][Self::allowsHiding].
204        #[unsafe(method(setAllowsHiding:))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn setAllowsHiding(&self, allows_hiding: bool);
207
208        /// Determines if the tab has a visible placement. Returns YES if the tab is visible in a tab bar
209        /// that supports different tab placements. Otherwise returns NO.
210        #[unsafe(method(hasVisiblePlacement))]
211        #[unsafe(method_family = none)]
212        pub unsafe fn hasVisiblePlacement(&self) -> bool;
213
214        #[cfg(all(
215            feature = "UIImage",
216            feature = "UIResponder",
217            feature = "UIViewController",
218            feature = "block2"
219        ))]
220        /// Creates a tab with the specified identifier, title, image, and view controller provider.
221        /// The view controller provider is called when a view controller is requested and is currently nil.
222        /// For root level tabs on `UITabBarController`, the resolved view controller must be non-nil.
223        #[unsafe(method(initWithTitle:image:identifier:viewControllerProvider:))]
224        #[unsafe(method_family = init)]
225        pub unsafe fn initWithTitle_image_identifier_viewControllerProvider(
226            this: Allocated<Self>,
227            title: &NSString,
228            image: Option<&UIImage>,
229            identifier: &NSString,
230            view_controller_provider: Option<
231                &block2::DynBlock<dyn Fn(NonNull<UITab>) -> NonNull<UIViewController>>,
232            >,
233        ) -> Retained<Self>;
234
235        #[unsafe(method(init))]
236        #[unsafe(method_family = init)]
237        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
238
239        #[unsafe(method(new))]
240        #[unsafe(method_family = new)]
241        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
242    );
243}
244
245/// UIPopoverPresentationControllerSourceItem.
246impl UITab {
247    extern_methods!();
248}
249
250#[cfg(feature = "UIPopoverPresentationControllerSourceItem")]
251extern_conformance!(
252    unsafe impl UIPopoverPresentationControllerSourceItem for UITab {}
253);
254
255/// UISpringLoadedInteractionSupporting.
256impl UITab {
257    extern_methods!();
258}
259
260#[cfg(feature = "UISpringLoadedInteractionSupporting")]
261extern_conformance!(
262    unsafe impl UISpringLoadedInteractionSupporting for UITab {}
263);
264
265/// UIAccessibility.
266impl UITab {
267    extern_methods!();
268}
269
270#[cfg(feature = "UIAccessibilityIdentification")]
271extern_conformance!(
272    unsafe impl UIAccessibilityIdentification for UITab {}
273);
274
275/// UITab.
276#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
277impl UIViewController {
278    extern_methods!(
279        /// The `UITab` instance that was used to create the receiver, and represents the view controller. Default is nil.
280        #[unsafe(method(tab))]
281        #[unsafe(method_family = none)]
282        pub unsafe fn tab(&self) -> Option<Retained<UITab>>;
283    );
284}