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::DynBlock<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::DynBlock<
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
145extern_conformance!(
146    unsafe impl NSCopying for UICollectionLayoutListConfiguration {}
147);
148
149unsafe impl CopyingHelper for UICollectionLayoutListConfiguration {
150    type Result = Self;
151}
152
153extern_conformance!(
154    unsafe impl NSObjectProtocol for UICollectionLayoutListConfiguration {}
155);
156
157impl UICollectionLayoutListConfiguration {
158    extern_methods!(
159        #[unsafe(method(new))]
160        #[unsafe(method_family = new)]
161        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
162
163        #[unsafe(method(init))]
164        #[unsafe(method_family = init)]
165        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
166
167        #[unsafe(method(initWithAppearance:))]
168        #[unsafe(method_family = init)]
169        pub fn initWithAppearance(
170            this: Allocated<Self>,
171            appearance: UICollectionLayoutListAppearance,
172        ) -> Retained<Self>;
173
174        /// The overall appearance of the section.
175        #[unsafe(method(appearance))]
176        #[unsafe(method_family = none)]
177        pub fn appearance(&self) -> UICollectionLayoutListAppearance;
178
179        /// Whether this section shows separators or not. For additional control, see separatorConfiguration.
180        /// Note that when this property is NO, the separatorConfiguration is ineffective.
181        #[unsafe(method(showsSeparators))]
182        #[unsafe(method_family = none)]
183        pub fn showsSeparators(&self) -> bool;
184
185        /// Setter for [`showsSeparators`][Self::showsSeparators].
186        #[unsafe(method(setShowsSeparators:))]
187        #[unsafe(method_family = none)]
188        pub fn setShowsSeparators(&self, shows_separators: bool);
189
190        #[cfg(feature = "UIListSeparatorConfiguration")]
191        /// The preferred configuration for separators. Used as a baseline for a section in a list using this
192        /// `UICollectionLayoutListConfiguration`
193        #[unsafe(method(separatorConfiguration))]
194        #[unsafe(method_family = none)]
195        pub fn separatorConfiguration(&self) -> Retained<UIListSeparatorConfiguration>;
196
197        #[cfg(feature = "UIListSeparatorConfiguration")]
198        /// Setter for [`separatorConfiguration`][Self::separatorConfiguration].
199        ///
200        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
201        #[unsafe(method(setSeparatorConfiguration:))]
202        #[unsafe(method_family = none)]
203        pub fn setSeparatorConfiguration(
204            &self,
205            separator_configuration: &UIListSeparatorConfiguration,
206        );
207
208        #[cfg(all(feature = "UIListSeparatorConfiguration", feature = "block2"))]
209        /// This handler is executed when the list section is configuring separator appearance for an item. The index path for the item being configured and
210        /// a resolved separator configuration are passed in to this block. The configuration returned from this block will be treated as the final
211        /// separator configuration for this item.
212        ///
213        /// # Safety
214        ///
215        /// - The returned block's argument 1 must be a valid pointer.
216        /// - The returned block's argument 2 must be a valid pointer.
217        #[unsafe(method(itemSeparatorHandler))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn itemSeparatorHandler(&self) -> UICollectionLayoutListItemSeparatorHandler;
220
221        #[cfg(all(feature = "UIListSeparatorConfiguration", feature = "block2"))]
222        /// Setter for [`itemSeparatorHandler`][Self::itemSeparatorHandler].
223        ///
224        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
225        ///
226        /// # Safety
227        ///
228        /// `item_separator_handler` must be a valid pointer or null.
229        #[unsafe(method(setItemSeparatorHandler:))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn setItemSeparatorHandler(
232            &self,
233            item_separator_handler: UICollectionLayoutListItemSeparatorHandler,
234        );
235
236        #[cfg(feature = "UIColor")]
237        /// The background color of the section.
238        /// Defaults to nil, indicating the system background color for the specified appearance is used.
239        #[unsafe(method(backgroundColor))]
240        #[unsafe(method_family = none)]
241        pub fn backgroundColor(&self) -> Option<Retained<UIColor>>;
242
243        #[cfg(feature = "UIColor")]
244        /// Setter for [`backgroundColor`][Self::backgroundColor].
245        #[unsafe(method(setBackgroundColor:))]
246        #[unsafe(method_family = none)]
247        pub fn setBackgroundColor(&self, background_color: Option<&UIColor>);
248
249        #[cfg(all(feature = "UISwipeActionsConfiguration", feature = "block2"))]
250        /// Called when list is about to show leading swipe actions for a particular index path.
251        /// Return either a UISwipeActionsConfiguration object or nil if this index path does not show swipe actions.
252        ///
253        /// # Safety
254        ///
255        /// The returned block's argument must be a valid pointer.
256        #[unsafe(method(leadingSwipeActionsConfigurationProvider))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn leadingSwipeActionsConfigurationProvider(
259            &self,
260        ) -> UICollectionLayoutListSwipeActionsConfigurationProvider;
261
262        #[cfg(all(feature = "UISwipeActionsConfiguration", feature = "block2"))]
263        /// Setter for [`leadingSwipeActionsConfigurationProvider`][Self::leadingSwipeActionsConfigurationProvider].
264        ///
265        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
266        ///
267        /// # Safety
268        ///
269        /// `leading_swipe_actions_configuration_provider` must be a valid pointer or null.
270        #[unsafe(method(setLeadingSwipeActionsConfigurationProvider:))]
271        #[unsafe(method_family = none)]
272        pub unsafe fn setLeadingSwipeActionsConfigurationProvider(
273            &self,
274            leading_swipe_actions_configuration_provider: UICollectionLayoutListSwipeActionsConfigurationProvider,
275        );
276
277        #[cfg(all(feature = "UISwipeActionsConfiguration", feature = "block2"))]
278        /// Called when list is about to show trailing swipe actions for a particular index path.
279        /// Return either a UISwipeActionsConfiguration object or nil if this index path does not show swipe actions.
280        ///
281        /// # Safety
282        ///
283        /// The returned block's argument must be a valid pointer.
284        #[unsafe(method(trailingSwipeActionsConfigurationProvider))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn trailingSwipeActionsConfigurationProvider(
287            &self,
288        ) -> UICollectionLayoutListSwipeActionsConfigurationProvider;
289
290        #[cfg(all(feature = "UISwipeActionsConfiguration", feature = "block2"))]
291        /// Setter for [`trailingSwipeActionsConfigurationProvider`][Self::trailingSwipeActionsConfigurationProvider].
292        ///
293        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
294        ///
295        /// # Safety
296        ///
297        /// `trailing_swipe_actions_configuration_provider` must be a valid pointer or null.
298        #[unsafe(method(setTrailingSwipeActionsConfigurationProvider:))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn setTrailingSwipeActionsConfigurationProvider(
301            &self,
302            trailing_swipe_actions_configuration_provider: UICollectionLayoutListSwipeActionsConfigurationProvider,
303        );
304
305        /// Defines whether the section has a header. Defaults to UICollectionLayoutListHeaderModeNone.
306        #[unsafe(method(headerMode))]
307        #[unsafe(method_family = none)]
308        pub fn headerMode(&self) -> UICollectionLayoutListHeaderMode;
309
310        /// Setter for [`headerMode`][Self::headerMode].
311        #[unsafe(method(setHeaderMode:))]
312        #[unsafe(method_family = none)]
313        pub fn setHeaderMode(&self, header_mode: UICollectionLayoutListHeaderMode);
314
315        /// Defines whether the section has a footer. Defaults to UICollectionLayoutListFooterModeNone.
316        #[unsafe(method(footerMode))]
317        #[unsafe(method_family = none)]
318        pub fn footerMode(&self) -> UICollectionLayoutListFooterMode;
319
320        /// Setter for [`footerMode`][Self::footerMode].
321        #[unsafe(method(setFooterMode:))]
322        #[unsafe(method_family = none)]
323        pub fn setFooterMode(&self, footer_mode: UICollectionLayoutListFooterMode);
324
325        #[cfg(feature = "objc2-core-foundation")]
326        /// Padding above each section header. The default value is `UICollectionViewLayoutAutomaticDimension`
327        #[unsafe(method(headerTopPadding))]
328        #[unsafe(method_family = none)]
329        pub fn headerTopPadding(&self) -> CGFloat;
330
331        #[cfg(feature = "objc2-core-foundation")]
332        /// Setter for [`headerTopPadding`][Self::headerTopPadding].
333        #[unsafe(method(setHeaderTopPadding:))]
334        #[unsafe(method_family = none)]
335        pub fn setHeaderTopPadding(&self, header_top_padding: CGFloat);
336
337        /// Determines the type of items that will tightly hug their content.
338        ///
339        /// The default value for this property is `UICollectionLayoutListContentHuggingElementsSupplementaryHeader` on visionOS for plain style table views and an empty set on all other platforms.
340        /// 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.
341        #[unsafe(method(contentHuggingElements))]
342        #[unsafe(method_family = none)]
343        pub fn contentHuggingElements(&self) -> UICollectionLayoutListContentHuggingElements;
344
345        /// Setter for [`contentHuggingElements`][Self::contentHuggingElements].
346        #[unsafe(method(setContentHuggingElements:))]
347        #[unsafe(method_family = none)]
348        pub fn setContentHuggingElements(
349            &self,
350            content_hugging_elements: UICollectionLayoutListContentHuggingElements,
351        );
352    );
353}
354
355/// UICollectionLayoutListSection.
356#[cfg(feature = "UICollectionViewCompositionalLayout")]
357impl NSCollectionLayoutSection {
358    extern_methods!(
359        /// Creates a list section using the specified configuration. You should pass the layoutEnvironment from inside the UICollectionViewCompositionalLayoutSectionProvider.
360        #[unsafe(method(sectionWithListConfiguration:layoutEnvironment:))]
361        #[unsafe(method_family = none)]
362        pub fn sectionWithListConfiguration_layoutEnvironment(
363            configuration: &UICollectionLayoutListConfiguration,
364            layout_environment: &ProtocolObject<dyn NSCollectionLayoutEnvironment>,
365        ) -> Retained<Self>;
366    );
367}
368
369/// UICollectionLayoutListSection.
370#[cfg(all(
371    feature = "UICollectionViewCompositionalLayout",
372    feature = "UICollectionViewLayout"
373))]
374impl UICollectionViewCompositionalLayout {
375    extern_methods!(
376        /// Creates a compositional layout containing only list sections of the specified configuration.
377        #[unsafe(method(layoutWithListConfiguration:))]
378        #[unsafe(method_family = none)]
379        pub fn layoutWithListConfiguration(
380            configuration: &UICollectionLayoutListConfiguration,
381        ) -> Retained<Self>;
382    );
383}