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 unsafe 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 unsafe 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 unsafe fn showsSeparators(&self) -> bool;
184
185        /// Setter for [`showsSeparators`][Self::showsSeparators].
186        #[unsafe(method(setShowsSeparators:))]
187        #[unsafe(method_family = none)]
188        pub unsafe 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 unsafe fn separatorConfiguration(&self) -> Retained<UIListSeparatorConfiguration>;
196
197        #[cfg(feature = "UIListSeparatorConfiguration")]
198        /// Setter for [`separatorConfiguration`][Self::separatorConfiguration].
199        #[unsafe(method(setSeparatorConfiguration:))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn setSeparatorConfiguration(
202            &self,
203            separator_configuration: &UIListSeparatorConfiguration,
204        );
205
206        #[cfg(all(feature = "UIListSeparatorConfiguration", feature = "block2"))]
207        /// This handler is executed when the list section is configuring separator appearance for an item. The index path for the item being configured and
208        /// a resolved separator configuration are passed in to this block. The configuration returned from this block will be treated as the final
209        /// separator configuration for this item.
210        #[unsafe(method(itemSeparatorHandler))]
211        #[unsafe(method_family = none)]
212        pub unsafe fn itemSeparatorHandler(&self) -> UICollectionLayoutListItemSeparatorHandler;
213
214        #[cfg(all(feature = "UIListSeparatorConfiguration", feature = "block2"))]
215        /// Setter for [`itemSeparatorHandler`][Self::itemSeparatorHandler].
216        #[unsafe(method(setItemSeparatorHandler:))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn setItemSeparatorHandler(
219            &self,
220            item_separator_handler: UICollectionLayoutListItemSeparatorHandler,
221        );
222
223        #[cfg(feature = "UIColor")]
224        /// The background color of the section.
225        /// Defaults to nil, indicating the system background color for the specified appearance is used.
226        #[unsafe(method(backgroundColor))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn backgroundColor(&self) -> Option<Retained<UIColor>>;
229
230        #[cfg(feature = "UIColor")]
231        /// Setter for [`backgroundColor`][Self::backgroundColor].
232        #[unsafe(method(setBackgroundColor:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn setBackgroundColor(&self, background_color: Option<&UIColor>);
235
236        #[cfg(all(feature = "UISwipeActionsConfiguration", feature = "block2"))]
237        /// Called when list is about to show leading swipe actions for a particular index path.
238        /// Return either a UISwipeActionsConfiguration object or nil if this index path does not show swipe actions.
239        #[unsafe(method(leadingSwipeActionsConfigurationProvider))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn leadingSwipeActionsConfigurationProvider(
242            &self,
243        ) -> UICollectionLayoutListSwipeActionsConfigurationProvider;
244
245        #[cfg(all(feature = "UISwipeActionsConfiguration", feature = "block2"))]
246        /// Setter for [`leadingSwipeActionsConfigurationProvider`][Self::leadingSwipeActionsConfigurationProvider].
247        #[unsafe(method(setLeadingSwipeActionsConfigurationProvider:))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn setLeadingSwipeActionsConfigurationProvider(
250            &self,
251            leading_swipe_actions_configuration_provider: UICollectionLayoutListSwipeActionsConfigurationProvider,
252        );
253
254        #[cfg(all(feature = "UISwipeActionsConfiguration", feature = "block2"))]
255        /// Called when list is about to show trailing swipe actions for a particular index path.
256        /// Return either a UISwipeActionsConfiguration object or nil if this index path does not show swipe actions.
257        #[unsafe(method(trailingSwipeActionsConfigurationProvider))]
258        #[unsafe(method_family = none)]
259        pub unsafe fn trailingSwipeActionsConfigurationProvider(
260            &self,
261        ) -> UICollectionLayoutListSwipeActionsConfigurationProvider;
262
263        #[cfg(all(feature = "UISwipeActionsConfiguration", feature = "block2"))]
264        /// Setter for [`trailingSwipeActionsConfigurationProvider`][Self::trailingSwipeActionsConfigurationProvider].
265        #[unsafe(method(setTrailingSwipeActionsConfigurationProvider:))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn setTrailingSwipeActionsConfigurationProvider(
268            &self,
269            trailing_swipe_actions_configuration_provider: UICollectionLayoutListSwipeActionsConfigurationProvider,
270        );
271
272        /// Defines whether the section has a header. Defaults to UICollectionLayoutListHeaderModeNone.
273        #[unsafe(method(headerMode))]
274        #[unsafe(method_family = none)]
275        pub unsafe fn headerMode(&self) -> UICollectionLayoutListHeaderMode;
276
277        /// Setter for [`headerMode`][Self::headerMode].
278        #[unsafe(method(setHeaderMode:))]
279        #[unsafe(method_family = none)]
280        pub unsafe fn setHeaderMode(&self, header_mode: UICollectionLayoutListHeaderMode);
281
282        /// Defines whether the section has a footer. Defaults to UICollectionLayoutListFooterModeNone.
283        #[unsafe(method(footerMode))]
284        #[unsafe(method_family = none)]
285        pub unsafe fn footerMode(&self) -> UICollectionLayoutListFooterMode;
286
287        /// Setter for [`footerMode`][Self::footerMode].
288        #[unsafe(method(setFooterMode:))]
289        #[unsafe(method_family = none)]
290        pub unsafe fn setFooterMode(&self, footer_mode: UICollectionLayoutListFooterMode);
291
292        #[cfg(feature = "objc2-core-foundation")]
293        /// Padding above each section header. The default value is `UICollectionViewLayoutAutomaticDimension`
294        #[unsafe(method(headerTopPadding))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn headerTopPadding(&self) -> CGFloat;
297
298        #[cfg(feature = "objc2-core-foundation")]
299        /// Setter for [`headerTopPadding`][Self::headerTopPadding].
300        #[unsafe(method(setHeaderTopPadding:))]
301        #[unsafe(method_family = none)]
302        pub unsafe fn setHeaderTopPadding(&self, header_top_padding: CGFloat);
303
304        /// Determines the type of items that will tightly hug their content.
305        ///
306        /// The default value for this property is `UICollectionLayoutListContentHuggingElementsSupplementaryHeader` on visionOS for plain style table views and an empty set on all other platforms.
307        /// 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.
308        #[unsafe(method(contentHuggingElements))]
309        #[unsafe(method_family = none)]
310        pub unsafe fn contentHuggingElements(&self)
311            -> UICollectionLayoutListContentHuggingElements;
312
313        /// Setter for [`contentHuggingElements`][Self::contentHuggingElements].
314        #[unsafe(method(setContentHuggingElements:))]
315        #[unsafe(method_family = none)]
316        pub unsafe fn setContentHuggingElements(
317            &self,
318            content_hugging_elements: UICollectionLayoutListContentHuggingElements,
319        );
320    );
321}
322
323/// UICollectionLayoutListSection.
324#[cfg(feature = "UICollectionViewCompositionalLayout")]
325impl NSCollectionLayoutSection {
326    extern_methods!(
327        /// Creates a list section using the specified configuration. You should pass the layoutEnvironment from inside the UICollectionViewCompositionalLayoutSectionProvider.
328        #[unsafe(method(sectionWithListConfiguration:layoutEnvironment:))]
329        #[unsafe(method_family = none)]
330        pub unsafe fn sectionWithListConfiguration_layoutEnvironment(
331            configuration: &UICollectionLayoutListConfiguration,
332            layout_environment: &ProtocolObject<dyn NSCollectionLayoutEnvironment>,
333        ) -> Retained<Self>;
334    );
335}
336
337/// UICollectionLayoutListSection.
338#[cfg(all(
339    feature = "UICollectionViewCompositionalLayout",
340    feature = "UICollectionViewLayout"
341))]
342impl UICollectionViewCompositionalLayout {
343    extern_methods!(
344        /// Creates a compositional layout containing only list sections of the specified configuration.
345        #[unsafe(method(layoutWithListConfiguration:))]
346        #[unsafe(method_family = none)]
347        pub unsafe fn layoutWithListConfiguration(
348            configuration: &UICollectionLayoutListConfiguration,
349        ) -> Retained<Self>;
350    );
351}