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 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 fn isEnabled(&self) -> bool;
73
74        /// Setter for [`isEnabled`][Self::isEnabled].
75        #[unsafe(method(setEnabled:))]
76        #[unsafe(method_family = none)]
77        pub fn setEnabled(&self, enabled: bool);
78
79        /// The title of the tab.
80        #[unsafe(method(title))]
81        #[unsafe(method_family = none)]
82        pub fn title(&self) -> Retained<NSString>;
83
84        /// Setter for [`title`][Self::title].
85        ///
86        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
87        #[unsafe(method(setTitle:))]
88        #[unsafe(method_family = none)]
89        pub fn setTitle(&self, title: &NSString);
90
91        #[cfg(feature = "UIImage")]
92        /// The image of the tab. Default is nil.
93        #[unsafe(method(image))]
94        #[unsafe(method_family = none)]
95        pub fn image(&self) -> Option<Retained<UIImage>>;
96
97        #[cfg(feature = "UIImage")]
98        /// Setter for [`image`][Self::image].
99        #[unsafe(method(setImage:))]
100        #[unsafe(method_family = none)]
101        pub fn setImage(&self, image: Option<&UIImage>);
102
103        /// The subtitle of the tab. This is displayed only in certain contexts, like the sidebar. Default is nil.
104        #[unsafe(method(subtitle))]
105        #[unsafe(method_family = none)]
106        pub fn subtitle(&self) -> Option<Retained<NSString>>;
107
108        /// Setter for [`subtitle`][Self::subtitle].
109        ///
110        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
111        #[unsafe(method(setSubtitle:))]
112        #[unsafe(method_family = none)]
113        pub fn setSubtitle(&self, subtitle: Option<&NSString>);
114
115        /// The badge value of the tab. Default is nil.
116        #[unsafe(method(badgeValue))]
117        #[unsafe(method_family = none)]
118        pub fn badgeValue(&self) -> Option<Retained<NSString>>;
119
120        /// Setter for [`badgeValue`][Self::badgeValue].
121        ///
122        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
123        #[unsafe(method(setBadgeValue:))]
124        #[unsafe(method_family = none)]
125        pub fn setBadgeValue(&self, badge_value: Option<&NSString>);
126
127        /// The preferred placement for the tab in the contexts that allow for different tab placements.
128        /// Default is `UITabPlacementAutomatic` which resolves its placement based on context.
129        #[unsafe(method(preferredPlacement))]
130        #[unsafe(method_family = none)]
131        pub fn preferredPlacement(&self) -> UITabPlacement;
132
133        /// Setter for [`preferredPlacement`][Self::preferredPlacement].
134        #[unsafe(method(setPreferredPlacement:))]
135        #[unsafe(method_family = none)]
136        pub fn setPreferredPlacement(&self, preferred_placement: UITabPlacement);
137
138        /// A custom object associated with the tab. Default is nil.
139        #[unsafe(method(userInfo))]
140        #[unsafe(method_family = none)]
141        pub fn userInfo(&self) -> Option<Retained<AnyObject>>;
142
143        /// Setter for [`userInfo`][Self::userInfo].
144        ///
145        /// # Safety
146        ///
147        /// `user_info` should be of the correct type.
148        #[unsafe(method(setUserInfo:))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn setUserInfo(&self, user_info: Option<&AnyObject>);
151
152        #[cfg(feature = "UITabGroup")]
153        /// The parent group of the tab. This is only non-nil if the tab is part of a parent group, and returns nil otherwise.
154        #[unsafe(method(parent))]
155        #[unsafe(method_family = none)]
156        pub fn parent(&self) -> Option<Retained<UITabGroup>>;
157
158        #[cfg(all(
159            feature = "UIResponder",
160            feature = "UITabBarController",
161            feature = "UIViewController"
162        ))]
163        /// The tab bar controller managing the tab. This is non-nil when the tab
164        /// or any of its ancestors is added to a UITabBarController; and is nil
165        /// otherwise.
166        #[unsafe(method(tabBarController))]
167        #[unsafe(method_family = none)]
168        pub fn tabBarController(&self) -> Option<Retained<UITabBarController>>;
169
170        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
171        /// The view controller owned by the tab. The view controller provider is used to resolve the view controller
172        /// if it is currently nil. For root level tabs, the view controller for the tab must be non-nil.
173        #[unsafe(method(viewController))]
174        #[unsafe(method_family = none)]
175        pub fn viewController(&self) -> Option<Retained<UIViewController>>;
176
177        #[cfg(feature = "UITabGroup")]
178        /// The managing tab group for the tab. This returns the root-most `UITabGroup` in the tab's parent hierarchy with an
179        /// active `managingNavigationController`. This can be different to `parent` if the tab is nested in multiple
180        /// levels of tab groups. If the tab does not belong to a hierarchy with a managing navigation controller, then this
181        /// will return nil. Default is nil.
182        #[unsafe(method(managingTabGroup))]
183        #[unsafe(method_family = none)]
184        pub fn managingTabGroup(&self) -> Option<Retained<UITabGroup>>;
185
186        /// Determines if the tab is currently hidden. Default is NO.
187        /// Hidden tabs cannot be accessed from the sidebar.
188        #[unsafe(method(isHidden))]
189        #[unsafe(method_family = none)]
190        pub fn isHidden(&self) -> bool;
191
192        /// Setter for [`isHidden`][Self::isHidden].
193        #[unsafe(method(setHidden:))]
194        #[unsafe(method_family = none)]
195        pub fn setHidden(&self, hidden: bool);
196
197        /// The default hidden state. When the user resets their customization, `UITab.hidden` will be set to the value
198        /// of this property. Default is NO.
199        #[unsafe(method(isHiddenByDefault))]
200        #[unsafe(method_family = none)]
201        pub fn isHiddenByDefault(&self) -> bool;
202
203        /// Setter for [`isHiddenByDefault`][Self::isHiddenByDefault].
204        #[unsafe(method(setHiddenByDefault:))]
205        #[unsafe(method_family = none)]
206        pub fn setHiddenByDefault(&self, hidden_by_default: bool);
207
208        /// Determines if the tab's visibility can be changed by the user while editing. Default is NO.
209        #[unsafe(method(allowsHiding))]
210        #[unsafe(method_family = none)]
211        pub fn allowsHiding(&self) -> bool;
212
213        /// Setter for [`allowsHiding`][Self::allowsHiding].
214        #[unsafe(method(setAllowsHiding:))]
215        #[unsafe(method_family = none)]
216        pub fn setAllowsHiding(&self, allows_hiding: bool);
217
218        /// Determines if the tab has a visible placement. Returns YES if the tab is visible in a tab bar
219        /// that supports different tab placements. Otherwise returns NO.
220        #[unsafe(method(hasVisiblePlacement))]
221        #[unsafe(method_family = none)]
222        pub fn hasVisiblePlacement(&self) -> bool;
223
224        #[cfg(all(
225            feature = "UIImage",
226            feature = "UIResponder",
227            feature = "UIViewController",
228            feature = "block2"
229        ))]
230        /// Creates a tab with the specified identifier, title, image, and view controller provider.
231        /// The view controller provider is called when a view controller is requested and is currently nil.
232        /// For root level tabs on `UITabBarController`, the resolved view controller must be non-nil.
233        ///
234        /// # Safety
235        ///
236        /// `view_controller_provider` block's return must be a valid pointer.
237        #[unsafe(method(initWithTitle:image:identifier:viewControllerProvider:))]
238        #[unsafe(method_family = init)]
239        pub unsafe fn initWithTitle_image_identifier_viewControllerProvider(
240            this: Allocated<Self>,
241            title: &NSString,
242            image: Option<&UIImage>,
243            identifier: &NSString,
244            view_controller_provider: Option<
245                &block2::DynBlock<dyn Fn(NonNull<UITab>) -> NonNull<UIViewController>>,
246            >,
247        ) -> Retained<Self>;
248
249        #[unsafe(method(init))]
250        #[unsafe(method_family = init)]
251        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
252
253        #[unsafe(method(new))]
254        #[unsafe(method_family = new)]
255        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
256    );
257}
258
259/// UIPopoverPresentationControllerSourceItem.
260impl UITab {
261    extern_methods!();
262}
263
264#[cfg(feature = "UIPopoverPresentationControllerSourceItem")]
265extern_conformance!(
266    unsafe impl UIPopoverPresentationControllerSourceItem for UITab {}
267);
268
269/// UISpringLoadedInteractionSupporting.
270impl UITab {
271    extern_methods!();
272}
273
274#[cfg(feature = "UISpringLoadedInteractionSupporting")]
275extern_conformance!(
276    unsafe impl UISpringLoadedInteractionSupporting for UITab {}
277);
278
279/// UIAccessibility.
280impl UITab {
281    extern_methods!();
282}
283
284#[cfg(feature = "UIAccessibilityIdentification")]
285extern_conformance!(
286    unsafe impl UIAccessibilityIdentification for UITab {}
287);
288
289/// UITab.
290#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
291impl UIViewController {
292    extern_methods!(
293        /// The `UITab` instance that was used to create the receiver, and represents the view controller. Default is nil.
294        #[unsafe(method(tab))]
295        #[unsafe(method_family = none)]
296        pub fn tab(&self) -> Option<Retained<UITab>>;
297    );
298}