objc2_ui_kit/generated/
UITabBarControllerSidebar.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::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitabbarcontrollersidebarlayout?language=objc)
10// NS_ENUM
11#[repr(transparent)]
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct UITabBarControllerSidebarLayout(pub NSInteger);
14impl UITabBarControllerSidebarLayout {
15    /// On iOS, this resolves to `overlap`.
16    /// On macOS and visionOS, this resolves to `tile`.
17    #[doc(alias = "UITabBarControllerSidebarLayoutAutomatic")]
18    pub const Automatic: Self = Self(0);
19    /// When the sidebar is displayed, it will overlap the selected view controller,
20    /// allowing the selected view controller to render underneath the sidebar. Anchor
21    /// the view's content to the `layoutMarginsGuide` or `safeAreaLayoutGuide` to avoid
22    /// being occluded by the sidebar.
23    #[doc(alias = "UITabBarControllerSidebarLayoutOverlap")]
24    pub const Overlap: Self = Self(1);
25    /// When the sidebar is displayed, the selected view controller is resized and shifted
26    /// to display alongside the sidebar. The selected view controller is not occluded by
27    /// the sidebar, cannot render underneath the sidebar.
28    #[doc(alias = "UITabBarControllerSidebarLayoutTile")]
29    pub const Tile: Self = Self(2);
30}
31
32unsafe impl Encode for UITabBarControllerSidebarLayout {
33    const ENCODING: Encoding = NSInteger::ENCODING;
34}
35
36unsafe impl RefEncode for UITabBarControllerSidebarLayout {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40extern_class!(
41    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitabsidebarscrolltarget?language=objc)
42    #[unsafe(super(NSObject))]
43    #[thread_kind = MainThreadOnly]
44    #[derive(Debug, PartialEq, Eq, Hash)]
45    pub struct UITabSidebarScrollTarget;
46);
47
48unsafe impl NSObjectProtocol for UITabSidebarScrollTarget {}
49
50impl UITabSidebarScrollTarget {
51    extern_methods!(
52        /// Scrolls to the `headerContentConfiguration` if it is set.
53        #[unsafe(method(targetForHeader))]
54        #[unsafe(method_family = none)]
55        pub unsafe fn targetForHeader(mtm: MainThreadMarker) -> Retained<Self>;
56
57        /// Scrolls to the `footerContentConfiguration` if it is set.
58        #[unsafe(method(targetForFooter))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn targetForFooter(mtm: MainThreadMarker) -> Retained<Self>;
61
62        #[cfg(feature = "UITab")]
63        /// Scrolls to the item representing the tab if it exists.
64        #[unsafe(method(targetForTab:))]
65        #[unsafe(method_family = none)]
66        pub unsafe fn targetForTab(tab: &UITab) -> Retained<Self>;
67    );
68}
69
70/// Methods declared on superclass `NSObject`.
71impl UITabSidebarScrollTarget {
72    extern_methods!(
73        #[unsafe(method(init))]
74        #[unsafe(method_family = init)]
75        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
76
77        #[unsafe(method(new))]
78        #[unsafe(method_family = new)]
79        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
80    );
81}
82
83extern_class!(
84    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitabbarcontrollersidebar?language=objc)
85    #[unsafe(super(NSObject))]
86    #[thread_kind = MainThreadOnly]
87    #[derive(Debug, PartialEq, Eq, Hash)]
88    pub struct UITabBarControllerSidebar;
89);
90
91unsafe impl NSObjectProtocol for UITabBarControllerSidebar {}
92
93impl UITabBarControllerSidebar {
94    extern_methods!(
95        /// The object managing the delegate of the sidebar.
96        #[unsafe(method(delegate))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn delegate(
99            &self,
100        ) -> Option<Retained<ProtocolObject<dyn UITabBarControllerSidebarDelegate>>>;
101
102        /// This is a [weak property][objc2::topics::weak_property].
103        /// Setter for [`delegate`][Self::delegate].
104        #[unsafe(method(setDelegate:))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn setDelegate(
107            &self,
108            delegate: Option<&ProtocolObject<dyn UITabBarControllerSidebarDelegate>>,
109        );
110
111        /// Determines if the sidebar is currently hidden.
112        #[unsafe(method(isHidden))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn isHidden(&self) -> bool;
115
116        /// Setter for [`isHidden`][Self::isHidden].
117        #[unsafe(method(setHidden:))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn setHidden(&self, hidden: bool);
120
121        /// The preferred layout for how the sidebar lays out with the tab bar controller's
122        /// content. Default is `.automatic`
123        #[unsafe(method(preferredLayout))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn preferredLayout(&self) -> UITabBarControllerSidebarLayout;
126
127        /// Setter for [`preferredLayout`][Self::preferredLayout].
128        #[unsafe(method(setPreferredLayout:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn setPreferredLayout(&self, preferred_layout: UITabBarControllerSidebarLayout);
131
132        #[cfg(feature = "UIContentConfiguration")]
133        /// Content configuration for an optional header to display in the sidebar.
134        /// The header is displayed above all tab content in the sidebar.
135        #[unsafe(method(headerContentConfiguration))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn headerContentConfiguration(
138            &self,
139        ) -> Option<Retained<ProtocolObject<dyn UIContentConfiguration>>>;
140
141        #[cfg(feature = "UIContentConfiguration")]
142        /// Setter for [`headerContentConfiguration`][Self::headerContentConfiguration].
143        #[unsafe(method(setHeaderContentConfiguration:))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn setHeaderContentConfiguration(
146            &self,
147            header_content_configuration: Option<&ProtocolObject<dyn UIContentConfiguration>>,
148        );
149
150        #[cfg(feature = "UIContentConfiguration")]
151        /// Content configuration for an optional header to display in the sidebar.
152        /// The footer is displayed below all tab content in the sidebar.
153        #[unsafe(method(footerContentConfiguration))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn footerContentConfiguration(
156            &self,
157        ) -> Option<Retained<ProtocolObject<dyn UIContentConfiguration>>>;
158
159        #[cfg(feature = "UIContentConfiguration")]
160        /// Setter for [`footerContentConfiguration`][Self::footerContentConfiguration].
161        #[unsafe(method(setFooterContentConfiguration:))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn setFooterContentConfiguration(
164            &self,
165            footer_content_configuration: Option<&ProtocolObject<dyn UIContentConfiguration>>,
166        );
167
168        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
169        /// A view to display at the bottom of the sidebar, like a UIToolbar. The width of this view
170        /// will be managed by the sidebar itself, and its height will be set to the value it returns
171        /// from `systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:`
172        /// Default is nil.
173        #[unsafe(method(bottomBarView))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn bottomBarView(&self) -> Option<Retained<UIView>>;
176
177        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
178        /// Setter for [`bottomBarView`][Self::bottomBarView].
179        #[unsafe(method(setBottomBarView:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn setBottomBarView(&self, bottom_bar_view: Option<&UIView>);
182
183        /// Scrolls to the specified target in the sidebar with an option to animate the change.
184        #[unsafe(method(scrollToTarget:animated:))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn scrollToTarget_animated(
187            &self,
188            target: &UITabSidebarScrollTarget,
189            animated: bool,
190        );
191
192        #[cfg(feature = "UITab")]
193        /// Requests the sidebar reconfigure the item representing the specified tab. This method has no effect if the `tab` is not
194        /// currently displayed in the sidebar.
195        #[unsafe(method(reconfigureItemForTab:))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn reconfigureItemForTab(&self, tab: &UITab);
198
199        #[unsafe(method(init))]
200        #[unsafe(method_family = init)]
201        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
202
203        #[unsafe(method(new))]
204        #[unsafe(method_family = new)]
205        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
206    );
207}
208
209extern_protocol!(
210    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitabbarcontrollersidebaranimating?language=objc)
211    pub unsafe trait UITabBarControllerSidebarAnimating:
212        NSObjectProtocol + MainThreadOnly
213    {
214        #[cfg(feature = "block2")]
215        #[unsafe(method(addAnimations:))]
216        #[unsafe(method_family = none)]
217        unsafe fn addAnimations(&self, animations: &block2::Block<dyn Fn()>);
218
219        #[cfg(feature = "block2")]
220        #[unsafe(method(addCompletion:))]
221        #[unsafe(method_family = none)]
222        unsafe fn addCompletion(&self, completion: &block2::Block<dyn Fn()>);
223    }
224);
225
226extern_protocol!(
227    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitabbarcontrollersidebardelegate?language=objc)
228    pub unsafe trait UITabBarControllerSidebarDelegate: NSObjectProtocol {
229        #[cfg(all(
230            feature = "UIResponder",
231            feature = "UITabBarController",
232            feature = "UIViewController"
233        ))]
234        /// Notifies the delegate when the visibility of the sidebar is about to change when `sidebar.isHidden` changes.
235        /// Add animations to the animator to run alongside the visibility update. Alongside animations and completions will run immediately
236        /// if the sidebar visibility is changed without animation.
237        #[optional]
238        #[unsafe(method(tabBarController:sidebarVisibilityWillChange:animator:))]
239        #[unsafe(method_family = none)]
240        unsafe fn tabBarController_sidebarVisibilityWillChange_animator(
241            &self,
242            tab_bar_controller: &UITabBarController,
243            sidebar: &UITabBarControllerSidebar,
244            animator: &ProtocolObject<dyn UITabBarControllerSidebarAnimating>,
245        );
246
247        #[cfg(all(
248            feature = "UIResponder",
249            feature = "UITabBarController",
250            feature = "UITabSidebarItem",
251            feature = "UIViewController"
252        ))]
253        /// Return a `UITabSidebarItem` for the specified item request. When created, the item will be preconfigured
254        /// to the appropriate defaults for its given content. If this method is not implemented, a default sidebar
255        /// item will be provided for the request.
256        #[optional]
257        #[unsafe(method(tabBarController:sidebar:itemForRequest:))]
258        #[unsafe(method_family = none)]
259        unsafe fn tabBarController_sidebar_itemForRequest(
260            &self,
261            tab_bar_controller: &UITabBarController,
262            sidebar: &UITabBarControllerSidebar,
263            request: &UITabSidebarItemRequest,
264        ) -> Retained<UITabSidebarItem>;
265
266        #[cfg(all(
267            feature = "UIResponder",
268            feature = "UITabBarController",
269            feature = "UITabSidebarItem",
270            feature = "UIViewController"
271        ))]
272        /// Called whenever the sidebar item's `configurationState` changes or the item is reconfigured.
273        /// The passed in item will accure all modifications until the delegate requests for a new sidebar
274        /// item from the delegate method `tabBarController:sidebar:itemForRequest:`
275        #[optional]
276        #[unsafe(method(tabBarController:sidebar:updateItem:))]
277        #[unsafe(method_family = none)]
278        unsafe fn tabBarController_sidebar_updateItem(
279            &self,
280            tab_bar_controller: &UITabBarController,
281            sidebar: &UITabBarControllerSidebar,
282            item: &UITabSidebarItem,
283        );
284
285        #[cfg(all(
286            feature = "UIResponder",
287            feature = "UITab",
288            feature = "UITabBarController",
289            feature = "UIViewController"
290        ))]
291        /// Notifies the delegate when the sidebar is about to display the row representing the specified `tab`
292        #[optional]
293        #[unsafe(method(tabBarController:sidebar:willBeginDisplayingTab:))]
294        #[unsafe(method_family = none)]
295        unsafe fn tabBarController_sidebar_willBeginDisplayingTab(
296            &self,
297            tab_bar_controller: &UITabBarController,
298            sidebar: &UITabBarControllerSidebar,
299            tab: &UITab,
300        );
301
302        #[cfg(all(
303            feature = "UIResponder",
304            feature = "UITab",
305            feature = "UITabBarController",
306            feature = "UIViewController"
307        ))]
308        /// Notifies the delegate when the sidebar has finished displaying the row representing the specified `tab`
309        #[optional]
310        #[unsafe(method(tabBarController:sidebar:didEndDisplayingTab:))]
311        #[unsafe(method_family = none)]
312        unsafe fn tabBarController_sidebar_didEndDisplayingTab(
313            &self,
314            tab_bar_controller: &UITabBarController,
315            sidebar: &UITabBarControllerSidebar,
316            tab: &UITab,
317        );
318
319        #[cfg(all(
320            feature = "UIResponder",
321            feature = "UISwipeActionsConfiguration",
322            feature = "UITab",
323            feature = "UITabBarController",
324            feature = "UIViewController"
325        ))]
326        /// Called when the sidebar is about to show leading swipe actions for the specified `tab`.
327        /// Return either a concrete `UISwipeActionsConfiguration` or nil if the tab does not show swipe actions.
328        #[optional]
329        #[unsafe(method(tabBarController:sidebar:leadingSwipeActionsConfigurationForTab:))]
330        #[unsafe(method_family = none)]
331        unsafe fn tabBarController_sidebar_leadingSwipeActionsConfigurationForTab(
332            &self,
333            tab_bar_controller: &UITabBarController,
334            sidebar: &UITabBarControllerSidebar,
335            tab: &UITab,
336        ) -> Option<Retained<UISwipeActionsConfiguration>>;
337
338        #[cfg(all(
339            feature = "UIResponder",
340            feature = "UISwipeActionsConfiguration",
341            feature = "UITab",
342            feature = "UITabBarController",
343            feature = "UIViewController"
344        ))]
345        /// Called when the sidebar is about to show trailing swipe actions for a particular tab.
346        /// Return either a UISwipeActionsConfiguration object or nil if this tab does not show swipe actions.
347        #[optional]
348        #[unsafe(method(tabBarController:sidebar:trailingSwipeActionsConfigurationForTab:))]
349        #[unsafe(method_family = none)]
350        unsafe fn tabBarController_sidebar_trailingSwipeActionsConfigurationForTab(
351            &self,
352            tab_bar_controller: &UITabBarController,
353            sidebar: &UITabBarControllerSidebar,
354            tab: &UITab,
355        ) -> Option<Retained<UISwipeActionsConfiguration>>;
356
357        #[cfg(all(
358            feature = "UIContextMenuConfiguration",
359            feature = "UIResponder",
360            feature = "UITab",
361            feature = "UITabBarController",
362            feature = "UIViewController"
363        ))]
364        /// Called when the sidebar is about to display a context menu for the specified `tab`.
365        /// Return either a concrete `UIContextMenuConfiguration` or nil if the tab does not show context menus.
366        #[optional]
367        #[unsafe(method(tabBarController:sidebar:contextMenuConfigurationForTab:))]
368        #[unsafe(method_family = none)]
369        unsafe fn tabBarController_sidebar_contextMenuConfigurationForTab(
370            &self,
371            tab_bar_controller: &UITabBarController,
372            sidebar: &UITabBarControllerSidebar,
373            tab: &UITab,
374        ) -> Option<Retained<UIContextMenuConfiguration>>;
375    }
376);