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