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 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 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 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 fn init(this: Allocated<Self>) -> Retained<Self>;
79
80        #[unsafe(method(new))]
81        #[unsafe(method_family = new)]
82        pub 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 fn delegate(
104            &self,
105        ) -> Option<Retained<ProtocolObject<dyn UITabBarControllerSidebarDelegate>>>;
106
107        /// Setter for [`delegate`][Self::delegate].
108        ///
109        /// This is a [weak property][objc2::topics::weak_property].
110        #[unsafe(method(setDelegate:))]
111        #[unsafe(method_family = none)]
112        pub fn setDelegate(
113            &self,
114            delegate: Option<&ProtocolObject<dyn UITabBarControllerSidebarDelegate>>,
115        );
116
117        /// Determines if the sidebar is currently hidden.
118        #[unsafe(method(isHidden))]
119        #[unsafe(method_family = none)]
120        pub fn isHidden(&self) -> bool;
121
122        /// Setter for [`isHidden`][Self::isHidden].
123        #[unsafe(method(setHidden:))]
124        #[unsafe(method_family = none)]
125        pub fn setHidden(&self, hidden: bool);
126
127        /// The preferred layout for how the sidebar lays out with the tab bar controller's
128        /// content. Default is `.automatic`
129        #[unsafe(method(preferredLayout))]
130        #[unsafe(method_family = none)]
131        pub fn preferredLayout(&self) -> UITabBarControllerSidebarLayout;
132
133        /// Setter for [`preferredLayout`][Self::preferredLayout].
134        #[unsafe(method(setPreferredLayout:))]
135        #[unsafe(method_family = none)]
136        pub fn setPreferredLayout(&self, preferred_layout: UITabBarControllerSidebarLayout);
137
138        #[cfg(all(feature = "UIDeferredMenuElement", feature = "UIMenuElement"))]
139        /// 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
140        /// to appear, regardless of if you provide any content in the element's callback. Items returned are displayed directly in the presented menu. When
141        /// set, the "Edit Sidebar" action will also be moved into the overflow menu after the app-provided items.
142        #[unsafe(method(navigationOverflowItems))]
143        #[unsafe(method_family = none)]
144        pub fn navigationOverflowItems(&self) -> Option<Retained<UIDeferredMenuElement>>;
145
146        #[cfg(all(feature = "UIDeferredMenuElement", feature = "UIMenuElement"))]
147        /// Setter for [`navigationOverflowItems`][Self::navigationOverflowItems].
148        #[unsafe(method(setNavigationOverflowItems:))]
149        #[unsafe(method_family = none)]
150        pub fn setNavigationOverflowItems(
151            &self,
152            navigation_overflow_items: Option<&UIDeferredMenuElement>,
153        );
154
155        #[cfg(feature = "UIContentConfiguration")]
156        /// Content configuration for an optional header to display in the sidebar.
157        /// The header is displayed above all tab content in the sidebar.
158        #[unsafe(method(headerContentConfiguration))]
159        #[unsafe(method_family = none)]
160        pub fn headerContentConfiguration(
161            &self,
162        ) -> Option<Retained<ProtocolObject<dyn UIContentConfiguration>>>;
163
164        #[cfg(feature = "UIContentConfiguration")]
165        /// Setter for [`headerContentConfiguration`][Self::headerContentConfiguration].
166        ///
167        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
168        #[unsafe(method(setHeaderContentConfiguration:))]
169        #[unsafe(method_family = none)]
170        pub fn setHeaderContentConfiguration(
171            &self,
172            header_content_configuration: Option<&ProtocolObject<dyn UIContentConfiguration>>,
173        );
174
175        #[cfg(feature = "UIContentConfiguration")]
176        /// Content configuration for an optional header to display in the sidebar.
177        /// The footer is displayed below all tab content in the sidebar.
178        #[unsafe(method(footerContentConfiguration))]
179        #[unsafe(method_family = none)]
180        pub fn footerContentConfiguration(
181            &self,
182        ) -> Option<Retained<ProtocolObject<dyn UIContentConfiguration>>>;
183
184        #[cfg(feature = "UIContentConfiguration")]
185        /// Setter for [`footerContentConfiguration`][Self::footerContentConfiguration].
186        ///
187        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
188        #[unsafe(method(setFooterContentConfiguration:))]
189        #[unsafe(method_family = none)]
190        pub fn setFooterContentConfiguration(
191            &self,
192            footer_content_configuration: Option<&ProtocolObject<dyn UIContentConfiguration>>,
193        );
194
195        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
196        /// A view to display at the bottom of the sidebar, like a UIToolbar. The width of this view
197        /// will be managed by the sidebar itself, and its height will be set to the value it returns
198        /// from `systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:`
199        /// Default is nil.
200        #[unsafe(method(bottomBarView))]
201        #[unsafe(method_family = none)]
202        pub fn bottomBarView(&self) -> Option<Retained<UIView>>;
203
204        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
205        /// Setter for [`bottomBarView`][Self::bottomBarView].
206        #[unsafe(method(setBottomBarView:))]
207        #[unsafe(method_family = none)]
208        pub fn setBottomBarView(&self, bottom_bar_view: Option<&UIView>);
209
210        /// Scrolls to the specified target in the sidebar with an option to animate the change.
211        #[unsafe(method(scrollToTarget:animated:))]
212        #[unsafe(method_family = none)]
213        pub fn scrollToTarget_animated(&self, target: &UITabSidebarScrollTarget, animated: bool);
214
215        #[cfg(feature = "UITab")]
216        /// Requests the sidebar reconfigure the item representing the specified tab. This method has no effect if the `tab` is not
217        /// currently displayed in the sidebar.
218        #[unsafe(method(reconfigureItemForTab:))]
219        #[unsafe(method_family = none)]
220        pub fn reconfigureItemForTab(&self, tab: &UITab);
221
222        #[unsafe(method(init))]
223        #[unsafe(method_family = init)]
224        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
225
226        #[unsafe(method(new))]
227        #[unsafe(method_family = new)]
228        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
229    );
230}
231
232extern_protocol!(
233    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitabbarcontrollersidebaranimating?language=objc)
234    pub unsafe trait UITabBarControllerSidebarAnimating:
235        NSObjectProtocol + MainThreadOnly
236    {
237        #[cfg(feature = "block2")]
238        #[unsafe(method(addAnimations:))]
239        #[unsafe(method_family = none)]
240        fn addAnimations(&self, animations: &block2::DynBlock<dyn Fn()>);
241
242        #[cfg(feature = "block2")]
243        #[unsafe(method(addCompletion:))]
244        #[unsafe(method_family = none)]
245        fn addCompletion(&self, completion: &block2::DynBlock<dyn Fn()>);
246    }
247);
248
249extern_protocol!(
250    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitabbarcontrollersidebardelegate?language=objc)
251    pub unsafe trait UITabBarControllerSidebarDelegate:
252        NSObjectProtocol + MainThreadOnly
253    {
254        #[cfg(all(
255            feature = "UIResponder",
256            feature = "UITabBarController",
257            feature = "UIViewController"
258        ))]
259        /// Notifies the delegate when the visibility of the sidebar is about to change when `sidebar.isHidden` changes.
260        /// Add animations to the animator to run alongside the visibility update. Alongside animations and completions will run immediately
261        /// if the sidebar visibility is changed without animation.
262        #[optional]
263        #[unsafe(method(tabBarController:sidebarVisibilityWillChange:animator:))]
264        #[unsafe(method_family = none)]
265        fn tabBarController_sidebarVisibilityWillChange_animator(
266            &self,
267            tab_bar_controller: &UITabBarController,
268            sidebar: &UITabBarControllerSidebar,
269            animator: &ProtocolObject<dyn UITabBarControllerSidebarAnimating>,
270        );
271
272        #[cfg(all(
273            feature = "UIResponder",
274            feature = "UITabBarController",
275            feature = "UITabSidebarItem",
276            feature = "UIViewController"
277        ))]
278        /// Return a `UITabSidebarItem` for the specified item request. When created, the item will be preconfigured
279        /// to the appropriate defaults for its given content. If this method is not implemented, a default sidebar
280        /// item will be provided for the request.
281        #[optional]
282        #[unsafe(method(tabBarController:sidebar:itemForRequest:))]
283        #[unsafe(method_family = none)]
284        fn tabBarController_sidebar_itemForRequest(
285            &self,
286            tab_bar_controller: &UITabBarController,
287            sidebar: &UITabBarControllerSidebar,
288            request: &UITabSidebarItemRequest,
289        ) -> Retained<UITabSidebarItem>;
290
291        #[cfg(all(
292            feature = "UIResponder",
293            feature = "UITabBarController",
294            feature = "UITabSidebarItem",
295            feature = "UIViewController"
296        ))]
297        /// Called whenever the sidebar item's `configurationState` changes or the item is reconfigured.
298        /// The passed in item will accrue all modifications until the delegate requests for a new sidebar
299        /// item from the delegate method `tabBarController:sidebar:itemForRequest:`
300        #[optional]
301        #[unsafe(method(tabBarController:sidebar:updateItem:))]
302        #[unsafe(method_family = none)]
303        fn tabBarController_sidebar_updateItem(
304            &self,
305            tab_bar_controller: &UITabBarController,
306            sidebar: &UITabBarControllerSidebar,
307            item: &UITabSidebarItem,
308        );
309
310        #[cfg(all(
311            feature = "UIResponder",
312            feature = "UITab",
313            feature = "UITabBarController",
314            feature = "UIViewController"
315        ))]
316        /// Notifies the delegate when the sidebar is about to display the row representing the specified `tab`
317        #[optional]
318        #[unsafe(method(tabBarController:sidebar:willBeginDisplayingTab:))]
319        #[unsafe(method_family = none)]
320        fn tabBarController_sidebar_willBeginDisplayingTab(
321            &self,
322            tab_bar_controller: &UITabBarController,
323            sidebar: &UITabBarControllerSidebar,
324            tab: &UITab,
325        );
326
327        #[cfg(all(
328            feature = "UIResponder",
329            feature = "UITab",
330            feature = "UITabBarController",
331            feature = "UIViewController"
332        ))]
333        /// Notifies the delegate when the sidebar has finished displaying the row representing the specified `tab`
334        #[optional]
335        #[unsafe(method(tabBarController:sidebar:didEndDisplayingTab:))]
336        #[unsafe(method_family = none)]
337        fn tabBarController_sidebar_didEndDisplayingTab(
338            &self,
339            tab_bar_controller: &UITabBarController,
340            sidebar: &UITabBarControllerSidebar,
341            tab: &UITab,
342        );
343
344        #[cfg(all(
345            feature = "UIResponder",
346            feature = "UISwipeActionsConfiguration",
347            feature = "UITab",
348            feature = "UITabBarController",
349            feature = "UIViewController"
350        ))]
351        /// Called when the sidebar is about to show leading swipe actions for the specified `tab`.
352        /// Return either a concrete `UISwipeActionsConfiguration` or nil if the tab does not show swipe actions.
353        #[optional]
354        #[unsafe(method(tabBarController:sidebar:leadingSwipeActionsConfigurationForTab:))]
355        #[unsafe(method_family = none)]
356        fn tabBarController_sidebar_leadingSwipeActionsConfigurationForTab(
357            &self,
358            tab_bar_controller: &UITabBarController,
359            sidebar: &UITabBarControllerSidebar,
360            tab: &UITab,
361        ) -> Option<Retained<UISwipeActionsConfiguration>>;
362
363        #[cfg(all(
364            feature = "UIResponder",
365            feature = "UISwipeActionsConfiguration",
366            feature = "UITab",
367            feature = "UITabBarController",
368            feature = "UIViewController"
369        ))]
370        /// Called when the sidebar is about to show trailing swipe actions for a particular tab.
371        /// Return either a UISwipeActionsConfiguration object or nil if this tab does not show swipe actions.
372        #[optional]
373        #[unsafe(method(tabBarController:sidebar:trailingSwipeActionsConfigurationForTab:))]
374        #[unsafe(method_family = none)]
375        fn tabBarController_sidebar_trailingSwipeActionsConfigurationForTab(
376            &self,
377            tab_bar_controller: &UITabBarController,
378            sidebar: &UITabBarControllerSidebar,
379            tab: &UITab,
380        ) -> Option<Retained<UISwipeActionsConfiguration>>;
381
382        #[cfg(all(
383            feature = "UIContextMenuConfiguration",
384            feature = "UIResponder",
385            feature = "UITab",
386            feature = "UITabBarController",
387            feature = "UIViewController"
388        ))]
389        /// Called when the sidebar is about to display a context menu for the specified `tab`.
390        /// Return either a concrete `UIContextMenuConfiguration` or nil if the tab does not show context menus.
391        #[optional]
392        #[unsafe(method(tabBarController:sidebar:contextMenuConfigurationForTab:))]
393        #[unsafe(method_family = none)]
394        fn tabBarController_sidebar_contextMenuConfigurationForTab(
395            &self,
396            tab_bar_controller: &UITabBarController,
397            sidebar: &UITabBarControllerSidebar,
398            tab: &UITab,
399        ) -> Option<Retained<UIContextMenuConfiguration>>;
400
401        #[cfg(all(
402            feature = "UIDragItem",
403            feature = "UIDragSession",
404            feature = "UIResponder",
405            feature = "UITab",
406            feature = "UITabBarController",
407            feature = "UIViewController"
408        ))]
409        /// 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.
410        /// 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.
411        #[optional]
412        #[unsafe(method(tabBarController:sidebar:itemsForBeginningDragSession:tab:))]
413        #[unsafe(method_family = none)]
414        fn tabBarController_sidebar_itemsForBeginningDragSession_tab(
415            &self,
416            tab_bar_controller: &UITabBarController,
417            sidebar: &UITabBarControllerSidebar,
418            drag_session: &ProtocolObject<dyn UIDragSession>,
419            tab: &UITab,
420        ) -> Retained<NSArray<UIDragItem>>;
421
422        #[cfg(all(
423            feature = "UIDragItem",
424            feature = "UIDragSession",
425            feature = "UIResponder",
426            feature = "UITab",
427            feature = "UITabBarController",
428            feature = "UIViewController"
429        ))]
430        /// Called when a new drag session is requesting items to add to the existing drag session in the sidebar from the specified `tab`.
431        /// Return items if the specified tab can add to the drag session, or an empty array if nothing should be added.
432        #[optional]
433        #[unsafe(method(tabBarController:sidebar:itemsForAddingToDragSession:tab:))]
434        #[unsafe(method_family = none)]
435        fn tabBarController_sidebar_itemsForAddingToDragSession_tab(
436            &self,
437            tab_bar_controller: &UITabBarController,
438            sidebar: &UITabBarControllerSidebar,
439            drag_session: &ProtocolObject<dyn UIDragSession>,
440            tab: &UITab,
441        ) -> Retained<NSArray<UIDragItem>>;
442
443        #[cfg(all(
444            feature = "UIAction",
445            feature = "UIDragSession",
446            feature = "UIDropInteraction",
447            feature = "UIMenuElement",
448            feature = "UIResponder",
449            feature = "UITab",
450            feature = "UITabBarController",
451            feature = "UITabGroup",
452            feature = "UIViewController"
453        ))]
454        /// Determines if items from the specified drop session can be dropped into the specified `sidebarAction`. If the operation is either a `.move` or `.copy`,
455        /// then the drop will proceed and `tabBarController:sidebar:sidebarAction:acceptItemsFromDropSession:` is called. By default, the drop will be
456        /// treated as a cancel operation if this is not implemented.
457        #[optional]
458        #[unsafe(method(tabBarController:sidebar:sidebarAction:group:operationForAcceptingItemsFromDropSession:))]
459        #[unsafe(method_family = none)]
460        fn tabBarController_sidebar_sidebarAction_group_operationForAcceptingItemsFromDropSession(
461            &self,
462            tab_bar_controller: &UITabBarController,
463            sidebar: &UITabBarControllerSidebar,
464            sidebar_action: &UIAction,
465            group: &UITabGroup,
466            session: &ProtocolObject<dyn UIDropSession>,
467        ) -> UIDropOperation;
468
469        #[cfg(all(
470            feature = "UIAction",
471            feature = "UIDragSession",
472            feature = "UIMenuElement",
473            feature = "UIResponder",
474            feature = "UITab",
475            feature = "UITabBarController",
476            feature = "UITabGroup",
477            feature = "UIViewController"
478        ))]
479        /// Receive the drop from into the `sidebarAction` using the specified session. This is only called if the drop operation returned
480        /// from `tabBarController:sidebar:sidebarAction:operationForAcceptingItemsFromDropSession` is valid for a drop.
481        #[optional]
482        #[unsafe(method(tabBarController:sidebar:sidebarAction:group:acceptItemsFromDropSession:))]
483        #[unsafe(method_family = none)]
484        fn tabBarController_sidebar_sidebarAction_group_acceptItemsFromDropSession(
485            &self,
486            tab_bar_controller: &UITabBarController,
487            sidebar: &UITabBarControllerSidebar,
488            sidebar_action: &UIAction,
489            group: &UITabGroup,
490            session: &ProtocolObject<dyn UIDropSession>,
491        );
492    }
493);