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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitabbarcontrollersidebarlayout?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct UITabBarControllerSidebarLayout(pub NSInteger);
15impl UITabBarControllerSidebarLayout {
16    /// On iOS, this resolves to `overlap`.
17    /// On macOS and visionOS, this resolves to `tile`.
18    #[doc(alias = "UITabBarControllerSidebarLayoutAutomatic")]
19    pub const Automatic: Self = Self(0);
20    /// When the sidebar is displayed, it will overlap the selected view controller,
21    /// allowing the selected view controller to render underneath the sidebar. Anchor
22    /// the view's content to the `layoutMarginsGuide` or `safeAreaLayoutGuide` to avoid
23    /// being occluded by the sidebar.
24    #[doc(alias = "UITabBarControllerSidebarLayoutOverlap")]
25    pub const Overlap: Self = Self(1);
26    /// When the sidebar is displayed, the selected view controller is resized and shifted
27    /// to display alongside the sidebar. The selected view controller is not occluded by
28    /// the sidebar, cannot render underneath the sidebar.
29    #[doc(alias = "UITabBarControllerSidebarLayoutTile")]
30    pub const Tile: Self = Self(2);
31}
32
33unsafe impl Encode for UITabBarControllerSidebarLayout {
34    const ENCODING: Encoding = NSInteger::ENCODING;
35}
36
37unsafe impl RefEncode for UITabBarControllerSidebarLayout {
38    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
39}
40
41extern_class!(
42    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitabsidebarscrolltarget?language=objc)
43    #[unsafe(super(NSObject))]
44    #[thread_kind = MainThreadOnly]
45    #[derive(Debug, PartialEq, Eq, Hash)]
46    pub struct UITabSidebarScrollTarget;
47);
48
49extern_conformance!(
50    unsafe impl NSObjectProtocol for UITabSidebarScrollTarget {}
51);
52
53impl UITabSidebarScrollTarget {
54    extern_methods!(
55        /// Scrolls to the `headerContentConfiguration` if it is set.
56        #[unsafe(method(targetForHeader))]
57        #[unsafe(method_family = none)]
58        pub unsafe fn targetForHeader(mtm: MainThreadMarker) -> Retained<Self>;
59
60        /// Scrolls to the `footerContentConfiguration` if it is set.
61        #[unsafe(method(targetForFooter))]
62        #[unsafe(method_family = none)]
63        pub unsafe fn targetForFooter(mtm: MainThreadMarker) -> Retained<Self>;
64
65        #[cfg(feature = "UITab")]
66        /// Scrolls to the item representing the tab if it exists.
67        #[unsafe(method(targetForTab:))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn targetForTab(tab: &UITab) -> Retained<Self>;
70    );
71}
72
73/// Methods declared on superclass `NSObject`.
74impl UITabSidebarScrollTarget {
75    extern_methods!(
76        #[unsafe(method(init))]
77        #[unsafe(method_family = init)]
78        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
79
80        #[unsafe(method(new))]
81        #[unsafe(method_family = new)]
82        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
83    );
84}
85
86extern_class!(
87    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitabbarcontrollersidebar?language=objc)
88    #[unsafe(super(NSObject))]
89    #[thread_kind = MainThreadOnly]
90    #[derive(Debug, PartialEq, Eq, Hash)]
91    pub struct UITabBarControllerSidebar;
92);
93
94extern_conformance!(
95    unsafe impl NSObjectProtocol for UITabBarControllerSidebar {}
96);
97
98impl UITabBarControllerSidebar {
99    extern_methods!(
100        /// The object managing the delegate of the sidebar.
101        #[unsafe(method(delegate))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn delegate(
104            &self,
105        ) -> Option<Retained<ProtocolObject<dyn UITabBarControllerSidebarDelegate>>>;
106
107        /// This is a [weak property][objc2::topics::weak_property].
108        /// Setter for [`delegate`][Self::delegate].
109        #[unsafe(method(setDelegate:))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn setDelegate(
112            &self,
113            delegate: Option<&ProtocolObject<dyn UITabBarControllerSidebarDelegate>>,
114        );
115
116        /// Determines if the sidebar is currently hidden.
117        #[unsafe(method(isHidden))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn isHidden(&self) -> bool;
120
121        /// Setter for [`isHidden`][Self::isHidden].
122        #[unsafe(method(setHidden:))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn setHidden(&self, hidden: bool);
125
126        /// The preferred layout for how the sidebar lays out with the tab bar controller's
127        /// content. Default is `.automatic`
128        #[unsafe(method(preferredLayout))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn preferredLayout(&self) -> UITabBarControllerSidebarLayout;
131
132        /// Setter for [`preferredLayout`][Self::preferredLayout].
133        #[unsafe(method(setPreferredLayout:))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn setPreferredLayout(&self, preferred_layout: UITabBarControllerSidebarLayout);
136
137        #[cfg(all(feature = "UIDeferredMenuElement", feature = "UIMenuElement"))]
138        /// Additional items to add to the overflow menu in the sidebar's navigation bar. Setting this property to a non-nil value will force the overflow button
139        /// to appear, regardless of if you provide any content in the element's callback. Items returned are displayed directly in the presented menu. When
140        /// set, the "Edit Sidebar" action will also be moved into the overflow menu after the app-provided items.
141        #[unsafe(method(navigationOverflowItems))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn navigationOverflowItems(&self) -> Option<Retained<UIDeferredMenuElement>>;
144
145        #[cfg(all(feature = "UIDeferredMenuElement", feature = "UIMenuElement"))]
146        /// Setter for [`navigationOverflowItems`][Self::navigationOverflowItems].
147        #[unsafe(method(setNavigationOverflowItems:))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn setNavigationOverflowItems(
150            &self,
151            navigation_overflow_items: Option<&UIDeferredMenuElement>,
152        );
153
154        #[cfg(feature = "UIContentConfiguration")]
155        /// Content configuration for an optional header to display in the sidebar.
156        /// The header is displayed above all tab content in the sidebar.
157        #[unsafe(method(headerContentConfiguration))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn headerContentConfiguration(
160            &self,
161        ) -> Option<Retained<ProtocolObject<dyn UIContentConfiguration>>>;
162
163        #[cfg(feature = "UIContentConfiguration")]
164        /// Setter for [`headerContentConfiguration`][Self::headerContentConfiguration].
165        #[unsafe(method(setHeaderContentConfiguration:))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn setHeaderContentConfiguration(
168            &self,
169            header_content_configuration: Option<&ProtocolObject<dyn UIContentConfiguration>>,
170        );
171
172        #[cfg(feature = "UIContentConfiguration")]
173        /// Content configuration for an optional header to display in the sidebar.
174        /// The footer is displayed below all tab content in the sidebar.
175        #[unsafe(method(footerContentConfiguration))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn footerContentConfiguration(
178            &self,
179        ) -> Option<Retained<ProtocolObject<dyn UIContentConfiguration>>>;
180
181        #[cfg(feature = "UIContentConfiguration")]
182        /// Setter for [`footerContentConfiguration`][Self::footerContentConfiguration].
183        #[unsafe(method(setFooterContentConfiguration:))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn setFooterContentConfiguration(
186            &self,
187            footer_content_configuration: Option<&ProtocolObject<dyn UIContentConfiguration>>,
188        );
189
190        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
191        /// A view to display at the bottom of the sidebar, like a UIToolbar. The width of this view
192        /// will be managed by the sidebar itself, and its height will be set to the value it returns
193        /// from `systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:`
194        /// Default is nil.
195        #[unsafe(method(bottomBarView))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn bottomBarView(&self) -> Option<Retained<UIView>>;
198
199        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
200        /// Setter for [`bottomBarView`][Self::bottomBarView].
201        #[unsafe(method(setBottomBarView:))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn setBottomBarView(&self, bottom_bar_view: Option<&UIView>);
204
205        /// Scrolls to the specified target in the sidebar with an option to animate the change.
206        #[unsafe(method(scrollToTarget:animated:))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn scrollToTarget_animated(
209            &self,
210            target: &UITabSidebarScrollTarget,
211            animated: bool,
212        );
213
214        #[cfg(feature = "UITab")]
215        /// Requests the sidebar reconfigure the item representing the specified tab. This method has no effect if the `tab` is not
216        /// currently displayed in the sidebar.
217        #[unsafe(method(reconfigureItemForTab:))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn reconfigureItemForTab(&self, tab: &UITab);
220
221        #[unsafe(method(init))]
222        #[unsafe(method_family = init)]
223        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
224
225        #[unsafe(method(new))]
226        #[unsafe(method_family = new)]
227        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
228    );
229}
230
231extern_protocol!(
232    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitabbarcontrollersidebaranimating?language=objc)
233    pub unsafe trait UITabBarControllerSidebarAnimating:
234        NSObjectProtocol + MainThreadOnly
235    {
236        #[cfg(feature = "block2")]
237        #[unsafe(method(addAnimations:))]
238        #[unsafe(method_family = none)]
239        unsafe fn addAnimations(&self, animations: &block2::DynBlock<dyn Fn()>);
240
241        #[cfg(feature = "block2")]
242        #[unsafe(method(addCompletion:))]
243        #[unsafe(method_family = none)]
244        unsafe fn addCompletion(&self, completion: &block2::DynBlock<dyn Fn()>);
245    }
246);
247
248extern_protocol!(
249    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitabbarcontrollersidebardelegate?language=objc)
250    pub unsafe trait UITabBarControllerSidebarDelegate:
251        NSObjectProtocol + MainThreadOnly
252    {
253        #[cfg(all(
254            feature = "UIResponder",
255            feature = "UITabBarController",
256            feature = "UIViewController"
257        ))]
258        /// Notifies the delegate when the visibility of the sidebar is about to change when `sidebar.isHidden` changes.
259        /// Add animations to the animator to run alongside the visibility update. Alongside animations and completions will run immediately
260        /// if the sidebar visibility is changed without animation.
261        #[optional]
262        #[unsafe(method(tabBarController:sidebarVisibilityWillChange:animator:))]
263        #[unsafe(method_family = none)]
264        unsafe fn tabBarController_sidebarVisibilityWillChange_animator(
265            &self,
266            tab_bar_controller: &UITabBarController,
267            sidebar: &UITabBarControllerSidebar,
268            animator: &ProtocolObject<dyn UITabBarControllerSidebarAnimating>,
269        );
270
271        #[cfg(all(
272            feature = "UIResponder",
273            feature = "UITabBarController",
274            feature = "UITabSidebarItem",
275            feature = "UIViewController"
276        ))]
277        /// Return a `UITabSidebarItem` for the specified item request. When created, the item will be preconfigured
278        /// to the appropriate defaults for its given content. If this method is not implemented, a default sidebar
279        /// item will be provided for the request.
280        #[optional]
281        #[unsafe(method(tabBarController:sidebar:itemForRequest:))]
282        #[unsafe(method_family = none)]
283        unsafe fn tabBarController_sidebar_itemForRequest(
284            &self,
285            tab_bar_controller: &UITabBarController,
286            sidebar: &UITabBarControllerSidebar,
287            request: &UITabSidebarItemRequest,
288        ) -> Retained<UITabSidebarItem>;
289
290        #[cfg(all(
291            feature = "UIResponder",
292            feature = "UITabBarController",
293            feature = "UITabSidebarItem",
294            feature = "UIViewController"
295        ))]
296        /// Called whenever the sidebar item's `configurationState` changes or the item is reconfigured.
297        /// The passed in item will accure all modifications until the delegate requests for a new sidebar
298        /// item from the delegate method `tabBarController:sidebar:itemForRequest:`
299        #[optional]
300        #[unsafe(method(tabBarController:sidebar:updateItem:))]
301        #[unsafe(method_family = none)]
302        unsafe fn tabBarController_sidebar_updateItem(
303            &self,
304            tab_bar_controller: &UITabBarController,
305            sidebar: &UITabBarControllerSidebar,
306            item: &UITabSidebarItem,
307        );
308
309        #[cfg(all(
310            feature = "UIResponder",
311            feature = "UITab",
312            feature = "UITabBarController",
313            feature = "UIViewController"
314        ))]
315        /// Notifies the delegate when the sidebar is about to display the row representing the specified `tab`
316        #[optional]
317        #[unsafe(method(tabBarController:sidebar:willBeginDisplayingTab:))]
318        #[unsafe(method_family = none)]
319        unsafe fn tabBarController_sidebar_willBeginDisplayingTab(
320            &self,
321            tab_bar_controller: &UITabBarController,
322            sidebar: &UITabBarControllerSidebar,
323            tab: &UITab,
324        );
325
326        #[cfg(all(
327            feature = "UIResponder",
328            feature = "UITab",
329            feature = "UITabBarController",
330            feature = "UIViewController"
331        ))]
332        /// Notifies the delegate when the sidebar has finished displaying the row representing the specified `tab`
333        #[optional]
334        #[unsafe(method(tabBarController:sidebar:didEndDisplayingTab:))]
335        #[unsafe(method_family = none)]
336        unsafe fn tabBarController_sidebar_didEndDisplayingTab(
337            &self,
338            tab_bar_controller: &UITabBarController,
339            sidebar: &UITabBarControllerSidebar,
340            tab: &UITab,
341        );
342
343        #[cfg(all(
344            feature = "UIResponder",
345            feature = "UISwipeActionsConfiguration",
346            feature = "UITab",
347            feature = "UITabBarController",
348            feature = "UIViewController"
349        ))]
350        /// Called when the sidebar is about to show leading swipe actions for the specified `tab`.
351        /// Return either a concrete `UISwipeActionsConfiguration` or nil if the tab does not show swipe actions.
352        #[optional]
353        #[unsafe(method(tabBarController:sidebar:leadingSwipeActionsConfigurationForTab:))]
354        #[unsafe(method_family = none)]
355        unsafe fn tabBarController_sidebar_leadingSwipeActionsConfigurationForTab(
356            &self,
357            tab_bar_controller: &UITabBarController,
358            sidebar: &UITabBarControllerSidebar,
359            tab: &UITab,
360        ) -> Option<Retained<UISwipeActionsConfiguration>>;
361
362        #[cfg(all(
363            feature = "UIResponder",
364            feature = "UISwipeActionsConfiguration",
365            feature = "UITab",
366            feature = "UITabBarController",
367            feature = "UIViewController"
368        ))]
369        /// Called when the sidebar is about to show trailing swipe actions for a particular tab.
370        /// Return either a UISwipeActionsConfiguration object or nil if this tab does not show swipe actions.
371        #[optional]
372        #[unsafe(method(tabBarController:sidebar:trailingSwipeActionsConfigurationForTab:))]
373        #[unsafe(method_family = none)]
374        unsafe fn tabBarController_sidebar_trailingSwipeActionsConfigurationForTab(
375            &self,
376            tab_bar_controller: &UITabBarController,
377            sidebar: &UITabBarControllerSidebar,
378            tab: &UITab,
379        ) -> Option<Retained<UISwipeActionsConfiguration>>;
380
381        #[cfg(all(
382            feature = "UIContextMenuConfiguration",
383            feature = "UIResponder",
384            feature = "UITab",
385            feature = "UITabBarController",
386            feature = "UIViewController"
387        ))]
388        /// Called when the sidebar is about to display a context menu for the specified `tab`.
389        /// Return either a concrete `UIContextMenuConfiguration` or nil if the tab does not show context menus.
390        #[optional]
391        #[unsafe(method(tabBarController:sidebar:contextMenuConfigurationForTab:))]
392        #[unsafe(method_family = none)]
393        unsafe fn tabBarController_sidebar_contextMenuConfigurationForTab(
394            &self,
395            tab_bar_controller: &UITabBarController,
396            sidebar: &UITabBarControllerSidebar,
397            tab: &UITab,
398        ) -> Option<Retained<UIContextMenuConfiguration>>;
399
400        #[cfg(all(
401            feature = "UIDragItem",
402            feature = "UIDragSession",
403            feature = "UIResponder",
404            feature = "UITab",
405            feature = "UITabBarController",
406            feature = "UIViewController"
407        ))]
408        /// Called when a new drag session has begun in the sidebar from the specified `tab`. Return drag items if the specified tab can be dragged, or an empty array if no drags should begin.
409        /// Note that if drag items are returned on tabs in groups that allow reordering, then tab reordering is disabled when the sidebar is not in editing.
410        #[optional]
411        #[unsafe(method(tabBarController:sidebar:itemsForBeginningDragSession:tab:))]
412        #[unsafe(method_family = none)]
413        unsafe fn tabBarController_sidebar_itemsForBeginningDragSession_tab(
414            &self,
415            tab_bar_controller: &UITabBarController,
416            sidebar: &UITabBarControllerSidebar,
417            drag_session: &ProtocolObject<dyn UIDragSession>,
418            tab: &UITab,
419        ) -> Retained<NSArray<UIDragItem>>;
420
421        #[cfg(all(
422            feature = "UIDragItem",
423            feature = "UIDragSession",
424            feature = "UIResponder",
425            feature = "UITab",
426            feature = "UITabBarController",
427            feature = "UIViewController"
428        ))]
429        /// Called when a new drag session is requesting items to add to the existing drag session in the sidebar from the specified `tab`.
430        /// Return items if the specified tab can add to the drag session, or an empty array if nothing should be added.
431        #[optional]
432        #[unsafe(method(tabBarController:sidebar:itemsForAddingToDragSession:tab:))]
433        #[unsafe(method_family = none)]
434        unsafe fn tabBarController_sidebar_itemsForAddingToDragSession_tab(
435            &self,
436            tab_bar_controller: &UITabBarController,
437            sidebar: &UITabBarControllerSidebar,
438            drag_session: &ProtocolObject<dyn UIDragSession>,
439            tab: &UITab,
440        ) -> Retained<NSArray<UIDragItem>>;
441
442        #[cfg(all(
443            feature = "UIAction",
444            feature = "UIDragSession",
445            feature = "UIDropInteraction",
446            feature = "UIMenuElement",
447            feature = "UIResponder",
448            feature = "UITab",
449            feature = "UITabBarController",
450            feature = "UITabGroup",
451            feature = "UIViewController"
452        ))]
453        /// Determines if items from the specified drop session can be dropped into the specified `sidebarAction`. If the operation is either a `.move` or `.copy`,
454        /// then the drop will proceed and `tabBarController:sidebar:sidebarAction:acceptItemsFromDropSession:` is called. By default, the drop will be
455        /// treated as a cancel operation if this is not implemented.
456        #[optional]
457        #[unsafe(method(tabBarController:sidebar:sidebarAction:group:operationForAcceptingItemsFromDropSession:))]
458        #[unsafe(method_family = none)]
459        unsafe fn tabBarController_sidebar_sidebarAction_group_operationForAcceptingItemsFromDropSession(
460            &self,
461            tab_bar_controller: &UITabBarController,
462            sidebar: &UITabBarControllerSidebar,
463            sidebar_action: &UIAction,
464            group: &UITabGroup,
465            session: &ProtocolObject<dyn UIDropSession>,
466        ) -> UIDropOperation;
467
468        #[cfg(all(
469            feature = "UIAction",
470            feature = "UIDragSession",
471            feature = "UIMenuElement",
472            feature = "UIResponder",
473            feature = "UITab",
474            feature = "UITabBarController",
475            feature = "UITabGroup",
476            feature = "UIViewController"
477        ))]
478        /// Receive the drop from into the `sidebarAction` using the specified session. This is only called if the drop operation returned
479        /// from `tabBarController:sidebar:sidebarAction:operationForAcceptingItemsFromDropSession` is valid for a drop.
480        #[optional]
481        #[unsafe(method(tabBarController:sidebar:sidebarAction:group:acceptItemsFromDropSession:))]
482        #[unsafe(method_family = none)]
483        unsafe fn tabBarController_sidebar_sidebarAction_group_acceptItemsFromDropSession(
484            &self,
485            tab_bar_controller: &UITabBarController,
486            sidebar: &UITabBarControllerSidebar,
487            sidebar_action: &UIAction,
488            group: &UITabGroup,
489            session: &ProtocolObject<dyn UIDropSession>,
490        );
491    }
492);