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