objc2_ui_kit/generated/
UICollectionLayoutList.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#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionlayoutlistappearance?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct UICollectionLayoutListAppearance(pub NSInteger);
17impl UICollectionLayoutListAppearance {
18    #[doc(alias = "UICollectionLayoutListAppearancePlain")]
19    pub const Plain: Self = Self(0);
20    #[doc(alias = "UICollectionLayoutListAppearanceGrouped")]
21    pub const Grouped: Self = Self(1);
22    #[doc(alias = "UICollectionLayoutListAppearanceInsetGrouped")]
23    pub const InsetGrouped: Self = Self(2);
24    #[doc(alias = "UICollectionLayoutListAppearanceSidebar")]
25    pub const Sidebar: Self = Self(3);
26    #[doc(alias = "UICollectionLayoutListAppearanceSidebarPlain")]
27    pub const SidebarPlain: Self = Self(4);
28}
29
30unsafe impl Encode for UICollectionLayoutListAppearance {
31    const ENCODING: Encoding = NSInteger::ENCODING;
32}
33
34unsafe impl RefEncode for UICollectionLayoutListAppearance {
35    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
36}
37
38/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionlayoutlistheadermode?language=objc)
39// NS_ENUM
40#[repr(transparent)]
41#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
42pub struct UICollectionLayoutListHeaderMode(pub NSInteger);
43impl UICollectionLayoutListHeaderMode {
44    /// No headers are shown
45    #[doc(alias = "UICollectionLayoutListHeaderModeNone")]
46    pub const None: Self = Self(0);
47    /// Uses supplementary views of kind UICollectionElementKindSectionHeader to show headers
48    #[doc(alias = "UICollectionLayoutListHeaderModeSupplementary")]
49    pub const Supplementary: Self = Self(1);
50    /// Styles the first item in a section as a header. This is especially useful when using hierarchical data sources to be able to expand and collapse the header.
51    #[doc(alias = "UICollectionLayoutListHeaderModeFirstItemInSection")]
52    pub const FirstItemInSection: Self = Self(2);
53}
54
55unsafe impl Encode for UICollectionLayoutListHeaderMode {
56    const ENCODING: Encoding = NSInteger::ENCODING;
57}
58
59unsafe impl RefEncode for UICollectionLayoutListHeaderMode {
60    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
61}
62
63/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionlayoutlistfootermode?language=objc)
64// NS_ENUM
65#[repr(transparent)]
66#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
67pub struct UICollectionLayoutListFooterMode(pub NSInteger);
68impl UICollectionLayoutListFooterMode {
69    /// No footers are shown
70    #[doc(alias = "UICollectionLayoutListFooterModeNone")]
71    pub const None: Self = Self(0);
72    /// Uses supplementary views of kind UICollectionElementKindSectionFooter to show footers
73    #[doc(alias = "UICollectionLayoutListFooterModeSupplementary")]
74    pub const Supplementary: Self = Self(1);
75}
76
77unsafe impl Encode for UICollectionLayoutListFooterMode {
78    const ENCODING: Encoding = NSInteger::ENCODING;
79}
80
81unsafe impl RefEncode for UICollectionLayoutListFooterMode {
82    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
83}
84
85/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionlayoutlistswipeactionsconfigurationprovider?language=objc)
86#[cfg(all(feature = "UISwipeActionsConfiguration", feature = "block2"))]
87pub type UICollectionLayoutListSwipeActionsConfigurationProvider =
88    *mut block2::Block<dyn Fn(NonNull<NSIndexPath>) -> *mut UISwipeActionsConfiguration>;
89
90/// A block that is executed by list sections to provide granular control over separator appearance.
91///
92///
93/// Parameter `itemIndexPath`: The index path of the item for which separators are being configured.
94///
95/// Parameter `sectionSeparatorConfiguration`: The list section's separator configuration for this cell. This configuration contains
96/// the values for separator visibility and insets according to the current state of the item.
97///
98///
99/// Returns: The configuration to use for separators at
100/// `itemIndexPath.`
101///
102/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionlayoutlistitemseparatorhandler?language=objc)
103#[cfg(all(feature = "UIListSeparatorConfiguration", feature = "block2"))]
104pub type UICollectionLayoutListItemSeparatorHandler = *mut block2::Block<
105    dyn Fn(
106        NonNull<NSIndexPath>,
107        NonNull<UIListSeparatorConfiguration>,
108    ) -> NonNull<UIListSeparatorConfiguration>,
109>;
110
111/// A setting for which items in the layout should tightly hug their content
112///
113/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionlayoutlistcontenthuggingelements?language=objc)
114// NS_OPTIONS
115#[repr(transparent)]
116#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
117pub struct UICollectionLayoutListContentHuggingElements(pub NSUInteger);
118bitflags::bitflags! {
119    impl UICollectionLayoutListContentHuggingElements: NSUInteger {
120        #[doc(alias = "UICollectionLayoutListContentHuggingElementsNone")]
121        const None = 0;
122        #[doc(alias = "UICollectionLayoutListContentHuggingElementsSupplementaryHeader")]
123        const SupplementaryHeader = 1<<0;
124    }
125}
126
127unsafe impl Encode for UICollectionLayoutListContentHuggingElements {
128    const ENCODING: Encoding = NSUInteger::ENCODING;
129}
130
131unsafe impl RefEncode for UICollectionLayoutListContentHuggingElements {
132    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
133}
134
135extern_class!(
136    /// A list configuration can be used to layout a section inside a UICollectionViewCompositionalLayout as a list.
137    ///
138    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionlayoutlistconfiguration?language=objc)
139    #[unsafe(super(NSObject))]
140    #[thread_kind = MainThreadOnly]
141    #[derive(Debug, PartialEq, Eq, Hash)]
142    pub struct UICollectionLayoutListConfiguration;
143);
144
145unsafe impl NSCopying for UICollectionLayoutListConfiguration {}
146
147unsafe impl CopyingHelper for UICollectionLayoutListConfiguration {
148    type Result = Self;
149}
150
151unsafe impl NSObjectProtocol for UICollectionLayoutListConfiguration {}
152
153impl UICollectionLayoutListConfiguration {
154    extern_methods!(
155        #[unsafe(method(new))]
156        #[unsafe(method_family = new)]
157        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
158
159        #[unsafe(method(init))]
160        #[unsafe(method_family = init)]
161        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
162
163        #[unsafe(method(initWithAppearance:))]
164        #[unsafe(method_family = init)]
165        pub unsafe fn initWithAppearance(
166            this: Allocated<Self>,
167            appearance: UICollectionLayoutListAppearance,
168        ) -> Retained<Self>;
169
170        /// The overall appearance of the section.
171        #[unsafe(method(appearance))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn appearance(&self) -> UICollectionLayoutListAppearance;
174
175        /// Whether this section shows separators or not. For additional control, see separatorConfiguration.
176        /// Note that when this property is NO, the separatorConfiguration is ineffective.
177        #[unsafe(method(showsSeparators))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn showsSeparators(&self) -> bool;
180
181        /// Setter for [`showsSeparators`][Self::showsSeparators].
182        #[unsafe(method(setShowsSeparators:))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn setShowsSeparators(&self, shows_separators: bool);
185
186        #[cfg(feature = "UIListSeparatorConfiguration")]
187        /// The preferred configuration for separators. Used as a baseline for a section in a list using this
188        /// `UICollectionLayoutListConfiguration`
189        #[unsafe(method(separatorConfiguration))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn separatorConfiguration(&self) -> Retained<UIListSeparatorConfiguration>;
192
193        #[cfg(feature = "UIListSeparatorConfiguration")]
194        /// Setter for [`separatorConfiguration`][Self::separatorConfiguration].
195        #[unsafe(method(setSeparatorConfiguration:))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn setSeparatorConfiguration(
198            &self,
199            separator_configuration: &UIListSeparatorConfiguration,
200        );
201
202        #[cfg(all(feature = "UIListSeparatorConfiguration", feature = "block2"))]
203        /// This handler is executed when the list section is configuring separator appearance for an item. The index path for the item being configured and
204        /// a resolved separator configuration are passed in to this block. The configuration returned from this block will be treated as the final
205        /// separator configuration for this item.
206        #[unsafe(method(itemSeparatorHandler))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn itemSeparatorHandler(&self) -> UICollectionLayoutListItemSeparatorHandler;
209
210        #[cfg(all(feature = "UIListSeparatorConfiguration", feature = "block2"))]
211        /// Setter for [`itemSeparatorHandler`][Self::itemSeparatorHandler].
212        #[unsafe(method(setItemSeparatorHandler:))]
213        #[unsafe(method_family = none)]
214        pub unsafe fn setItemSeparatorHandler(
215            &self,
216            item_separator_handler: UICollectionLayoutListItemSeparatorHandler,
217        );
218
219        #[cfg(feature = "UIColor")]
220        /// The background color of the section.
221        /// Defaults to nil, indicating the system background color for the specified appearance is used.
222        #[unsafe(method(backgroundColor))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn backgroundColor(&self) -> Option<Retained<UIColor>>;
225
226        #[cfg(feature = "UIColor")]
227        /// Setter for [`backgroundColor`][Self::backgroundColor].
228        #[unsafe(method(setBackgroundColor:))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn setBackgroundColor(&self, background_color: Option<&UIColor>);
231
232        #[cfg(all(feature = "UISwipeActionsConfiguration", feature = "block2"))]
233        /// Called when list is about to show leading swipe actions for a particular index path.
234        /// Return either a UISwipeActionsConfiguration object or nil if this index path does not show swipe actions.
235        #[unsafe(method(leadingSwipeActionsConfigurationProvider))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn leadingSwipeActionsConfigurationProvider(
238            &self,
239        ) -> UICollectionLayoutListSwipeActionsConfigurationProvider;
240
241        #[cfg(all(feature = "UISwipeActionsConfiguration", feature = "block2"))]
242        /// Setter for [`leadingSwipeActionsConfigurationProvider`][Self::leadingSwipeActionsConfigurationProvider].
243        #[unsafe(method(setLeadingSwipeActionsConfigurationProvider:))]
244        #[unsafe(method_family = none)]
245        pub unsafe fn setLeadingSwipeActionsConfigurationProvider(
246            &self,
247            leading_swipe_actions_configuration_provider: UICollectionLayoutListSwipeActionsConfigurationProvider,
248        );
249
250        #[cfg(all(feature = "UISwipeActionsConfiguration", feature = "block2"))]
251        /// Called when list is about to show trailing swipe actions for a particular index path.
252        /// Return either a UISwipeActionsConfiguration object or nil if this index path does not show swipe actions.
253        #[unsafe(method(trailingSwipeActionsConfigurationProvider))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn trailingSwipeActionsConfigurationProvider(
256            &self,
257        ) -> UICollectionLayoutListSwipeActionsConfigurationProvider;
258
259        #[cfg(all(feature = "UISwipeActionsConfiguration", feature = "block2"))]
260        /// Setter for [`trailingSwipeActionsConfigurationProvider`][Self::trailingSwipeActionsConfigurationProvider].
261        #[unsafe(method(setTrailingSwipeActionsConfigurationProvider:))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn setTrailingSwipeActionsConfigurationProvider(
264            &self,
265            trailing_swipe_actions_configuration_provider: UICollectionLayoutListSwipeActionsConfigurationProvider,
266        );
267
268        /// Defines whether the section has a header. Defaults to UICollectionLayoutListHeaderModeNone.
269        #[unsafe(method(headerMode))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn headerMode(&self) -> UICollectionLayoutListHeaderMode;
272
273        /// Setter for [`headerMode`][Self::headerMode].
274        #[unsafe(method(setHeaderMode:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn setHeaderMode(&self, header_mode: UICollectionLayoutListHeaderMode);
277
278        /// Defines whether the section has a footer. Defaults to UICollectionLayoutListFooterModeNone.
279        #[unsafe(method(footerMode))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn footerMode(&self) -> UICollectionLayoutListFooterMode;
282
283        /// Setter for [`footerMode`][Self::footerMode].
284        #[unsafe(method(setFooterMode:))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn setFooterMode(&self, footer_mode: UICollectionLayoutListFooterMode);
287
288        #[cfg(feature = "objc2-core-foundation")]
289        /// Padding above each section header. The default value is `UICollectionViewLayoutAutomaticDimension`
290        #[unsafe(method(headerTopPadding))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn headerTopPadding(&self) -> CGFloat;
293
294        #[cfg(feature = "objc2-core-foundation")]
295        /// Setter for [`headerTopPadding`][Self::headerTopPadding].
296        #[unsafe(method(setHeaderTopPadding:))]
297        #[unsafe(method_family = none)]
298        pub unsafe fn setHeaderTopPadding(&self, header_top_padding: CGFloat);
299
300        /// Determines the type of items that will tightly hug their content.
301        ///
302        /// The default value for this property is `UICollectionLayoutListContentHuggingElementsSupplementaryHeader` on visionOS for plain style table views and an empty set on all other platforms.
303        /// When the value of this property is `UICollectionLayoutListContentHuggingElementsSupplementaryHeader`, the header view will not stretch the width of the collection view if its content's intrinsic content size is less than the collection view's width.
304        #[unsafe(method(contentHuggingElements))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn contentHuggingElements(&self)
307            -> UICollectionLayoutListContentHuggingElements;
308
309        /// Setter for [`contentHuggingElements`][Self::contentHuggingElements].
310        #[unsafe(method(setContentHuggingElements:))]
311        #[unsafe(method_family = none)]
312        pub unsafe fn setContentHuggingElements(
313            &self,
314            content_hugging_elements: UICollectionLayoutListContentHuggingElements,
315        );
316    );
317}
318
319/// UICollectionLayoutListSection.
320#[cfg(feature = "UICollectionViewCompositionalLayout")]
321impl NSCollectionLayoutSection {
322    extern_methods!(
323        /// Creates a list section using the specified configuration. You should pass the layoutEnvironment from inside the UICollectionViewCompositionalLayoutSectionProvider.
324        #[unsafe(method(sectionWithListConfiguration:layoutEnvironment:))]
325        #[unsafe(method_family = none)]
326        pub unsafe fn sectionWithListConfiguration_layoutEnvironment(
327            configuration: &UICollectionLayoutListConfiguration,
328            layout_environment: &ProtocolObject<dyn NSCollectionLayoutEnvironment>,
329        ) -> Retained<Self>;
330    );
331}
332
333/// UICollectionLayoutListSection.
334#[cfg(all(
335    feature = "UICollectionViewCompositionalLayout",
336    feature = "UICollectionViewLayout"
337))]
338impl UICollectionViewCompositionalLayout {
339    extern_methods!(
340        /// Creates a compositional layout containing only list sections of the specified configuration.
341        #[unsafe(method(layoutWithListConfiguration:))]
342        #[unsafe(method_family = none)]
343        pub unsafe fn layoutWithListConfiguration(
344            configuration: &UICollectionLayoutListConfiguration,
345        ) -> Retained<Self>;
346    );
347}