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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
//! 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/carplay/cpassistantcellactiontype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CPAssistantCellActionType(pub NSInteger);
impl CPAssistantCellActionType {
#[doc(alias = "CPAssistantCellActionTypePlayMedia")]
pub const PlayMedia: Self = Self(0);
#[doc(alias = "CPAssistantCellActionTypeStartCall")]
pub const StartCall: Self = Self(1);
}
unsafe impl Encode for CPAssistantCellActionType {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for CPAssistantCellActionType {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpassistantcellvisibility?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CPAssistantCellVisibility(pub NSInteger);
impl CPAssistantCellVisibility {
#[doc(alias = "CPAssistantCellVisibilityOff")]
pub const Off: Self = Self(0);
#[doc(alias = "CPAssistantCellVisibilityWhileLimitedUIActive")]
pub const WhileLimitedUIActive: Self = Self(1);
#[doc(alias = "CPAssistantCellVisibilityAlways")]
pub const Always: Self = Self(2);
}
unsafe impl Encode for CPAssistantCellVisibility {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for CPAssistantCellVisibility {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpassistantcellposition?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CPAssistantCellPosition(pub NSInteger);
impl CPAssistantCellPosition {
#[doc(alias = "CPAssistantCellPositionTop")]
pub const Top: Self = Self(0);
#[doc(alias = "CPAssistantCellPositionBottom")]
pub const Bottom: Self = Self(1);
}
unsafe impl Encode for CPAssistantCellPosition {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for CPAssistantCellPosition {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// `CPAssistantCellConfiguration`encapsulates the configuration options for your assistant cell.
///
///
/// Note: The Assistant Cell is only supported by CarPlay Audio and Communication apps.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpassistantcellconfiguration?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct CPAssistantCellConfiguration;
);
extern_conformance!(
unsafe impl NSCoding for CPAssistantCellConfiguration {}
);
extern_conformance!(
unsafe impl NSObjectProtocol for CPAssistantCellConfiguration {}
);
extern_conformance!(
unsafe impl NSSecureCoding for CPAssistantCellConfiguration {}
);
impl CPAssistantCellConfiguration {
extern_methods!(
/// Initialize an Assistant Cell Configuration with a position, visibility, and action representing the SiriKit intent that should be invoked when users select the assistant cell.
#[unsafe(method(initWithPosition:visibility:assistantAction:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithPosition_visibility_assistantAction(
this: Allocated<Self>,
position: CPAssistantCellPosition,
visibility: CPAssistantCellVisibility,
assistant_action: CPAssistantCellActionType,
) -> Retained<Self>;
/// The position of the Assistant Cell.
///
///
/// Note: The default value of this property is
/// `CPAssistantCellPositionTop.`
#[unsafe(method(position))]
#[unsafe(method_family = none)]
pub unsafe fn position(&self) -> CPAssistantCellPosition;
/// The visibility of the Assistant Cell.
///
///
/// Note: The default value of this property is
/// `CPAssistantCellVisibilityOff.`
#[unsafe(method(visibility))]
#[unsafe(method_family = none)]
pub unsafe fn visibility(&self) -> CPAssistantCellVisibility;
/// The action that Siri will perform when users select the assistant cell.
#[unsafe(method(assistantAction))]
#[unsafe(method_family = none)]
pub unsafe fn assistantAction(&self) -> CPAssistantCellActionType;
);
}
/// Methods declared on superclass `NSObject`.
impl CPAssistantCellConfiguration {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/carplay/cplisttemplate?language=objc)
#[unsafe(super(CPTemplate, NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "CPTemplate")]
pub struct CPListTemplate;
);
#[cfg(all(feature = "CPBarButtonProviding", feature = "CPTemplate"))]
extern_conformance!(
unsafe impl CPBarButtonProviding for CPListTemplate {}
);
#[cfg(feature = "CPTemplate")]
extern_conformance!(
unsafe impl NSCoding for CPListTemplate {}
);
#[cfg(feature = "CPTemplate")]
extern_conformance!(
unsafe impl NSObjectProtocol for CPListTemplate {}
);
#[cfg(feature = "CPTemplate")]
extern_conformance!(
unsafe impl NSSecureCoding for CPListTemplate {}
);
#[cfg(feature = "CPTemplate")]
impl CPListTemplate {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
#[cfg(feature = "CPListSection")]
/// Initialize a list template with one or more sections of items and an optional title.
#[unsafe(method(initWithTitle:sections:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithTitle_sections(
this: Allocated<Self>,
title: Option<&NSString>,
sections: &NSArray<CPListSection>,
) -> Retained<Self>;
#[cfg(feature = "CPListSection")]
/// Initialize a list template with one or more sections of items, an optional title, and configuration for the assistant cell via a
/// `CPAssistantCellConfiguration`object.
///
///
/// Note: The Assistant Cell is only supported by CarPlay Audio and Communication Apps.
///
///
/// Unlike
/// `CPListItem,`your application will not receive a callback when the user selects the cell.
/// Instead, configure an Intents app extention to receive user requests from SiriKit, in order to turn the requests into an
/// app-specific actions.
#[unsafe(method(initWithTitle:sections:assistantCellConfiguration:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithTitle_sections_assistantCellConfiguration(
this: Allocated<Self>,
title: Option<&NSString>,
sections: &NSArray<CPListSection>,
assistant_cell_configuration: Option<&CPAssistantCellConfiguration>,
) -> Retained<Self>;
#[cfg(all(feature = "CPGridButton", feature = "CPListSection"))]
/// Initialize a list template with one or more grid buttons to displayed in a list header.
#[unsafe(method(initWithTitle:sections:assistantCellConfiguration:headerGridButtons:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithTitle_sections_assistantCellConfiguration_headerGridButtons(
this: Allocated<Self>,
title: Option<&NSString>,
sections: &NSArray<CPListSection>,
assistant_cell_configuration: Option<&CPAssistantCellConfiguration>,
header_grid_buttons: Option<&NSArray<CPGridButton>>,
) -> Retained<Self>;
/// The list template's delegate is informed of list selection events.
#[deprecated]
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub unsafe fn delegate(
&self,
) -> Option<Retained<ProtocolObject<dyn CPListTemplateDelegate>>>;
/// Setter for [`delegate`][Self::delegate].
///
/// This is a [weak property][objc2::topics::weak_property].
#[deprecated]
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn CPListTemplateDelegate>>,
);
/// The maximum number of items, across all sections, that may appear in a
/// `CPListTemplate.`
/// Note: Your list template will display the first
/// `maximumItemCount`items, across all sections.
/// Any items or sections beyond that limit will be trimmed.
#[unsafe(method(maximumItemCount))]
#[unsafe(method_family = none)]
pub unsafe fn maximumItemCount(mtm: MainThreadMarker) -> NSUInteger;
/// The maximum number of sections that may appear in a
/// `CPListTemplate.`
/// Note: Your list template will display the first
/// `maximumSectionCount`sections.
/// Any sections beyond that limit will be trimmed.
#[unsafe(method(maximumSectionCount))]
#[unsafe(method_family = none)]
pub unsafe fn maximumSectionCount(mtm: MainThreadMarker) -> NSUInteger;
#[cfg(feature = "CPListSection")]
/// The sections displayed in this list.
#[unsafe(method(sections))]
#[unsafe(method_family = none)]
pub unsafe fn sections(&self) -> Retained<NSArray<CPListSection>>;
/// Title shown in the navigation bar while this template is visible.
#[unsafe(method(title))]
#[unsafe(method_family = none)]
pub unsafe fn title(&self) -> Option<Retained<NSString>>;
#[cfg(feature = "CPListSection")]
/// Update the list of sections displayed in this list template, reloading
/// the table view displaying this list.
#[unsafe(method(updateSections:))]
#[unsafe(method_family = none)]
pub unsafe fn updateSections(&self, sections: &NSArray<CPListSection>);
/// The number of sections currently displayed in this list template.
#[unsafe(method(sectionCount))]
#[unsafe(method_family = none)]
pub unsafe fn sectionCount(&self) -> NSUInteger;
/// The number of items currently displayed in this list template, across all sections.
#[unsafe(method(itemCount))]
#[unsafe(method_family = none)]
pub unsafe fn itemCount(&self) -> NSUInteger;
#[cfg(feature = "CPListItemTypes")]
/// Return an
/// `NSIndexPath`for the specified item, if it exists in any section
/// in this list template, or nil if not found.
#[unsafe(method(indexPathForItem:))]
#[unsafe(method_family = none)]
pub unsafe fn indexPathForItem(
&self,
item: &ProtocolObject<dyn CPListTemplateItem>,
) -> Option<Retained<NSIndexPath>>;
/// An optional array of strings, ordered from most to least preferred.
/// The variant strings should be provided as localized, displayable content.
/// The system will select the first variant that fits the available space.
///
/// If the list template does not contain any items (itemCount == 0), then
/// the template will display an empty view with a title and subtitle to indicate
/// that the template has no list items.
///
/// If the list template is updated to contain items, the empty view will be automatically
/// removed.
#[unsafe(method(emptyViewTitleVariants))]
#[unsafe(method_family = none)]
pub unsafe fn emptyViewTitleVariants(&self) -> Retained<NSArray<NSString>>;
/// Setter for [`emptyViewTitleVariants`][Self::emptyViewTitleVariants].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setEmptyViewTitleVariants:))]
#[unsafe(method_family = none)]
pub unsafe fn setEmptyViewTitleVariants(
&self,
empty_view_title_variants: &NSArray<NSString>,
);
/// An optional array of strings, ordered from most to least preferred.
/// The variant strings should be provided as localized, displayable content.
/// The system will select the first variant that fits the available space.
///
/// If the list template does not contain any items (itemCount == 0), then
/// the template will display an empty view with a title and subtitle to indicate
/// that the template has no list items.
///
/// If the list template is updated to contain items, the empty view will be automatically
/// removed.
#[unsafe(method(emptyViewSubtitleVariants))]
#[unsafe(method_family = none)]
pub unsafe fn emptyViewSubtitleVariants(&self) -> Retained<NSArray<NSString>>;
/// Setter for [`emptyViewSubtitleVariants`][Self::emptyViewSubtitleVariants].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setEmptyViewSubtitleVariants:))]
#[unsafe(method_family = none)]
pub unsafe fn setEmptyViewSubtitleVariants(
&self,
empty_view_subtitle_variants: &NSArray<NSString>,
);
/// If YES, a spinning activity indicator will be displayed while the list template contains no items.
/// The activity indicator will be displayed in addition to any
/// `emptyViewTitleVariants`or
/// `emptyViewSubtitleVariants.`
#[unsafe(method(showsSpinnerWhileEmpty))]
#[unsafe(method_family = none)]
pub unsafe fn showsSpinnerWhileEmpty(&self) -> bool;
/// Setter for [`showsSpinnerWhileEmpty`][Self::showsSpinnerWhileEmpty].
#[unsafe(method(setShowsSpinnerWhileEmpty:))]
#[unsafe(method_family = none)]
pub unsafe fn setShowsSpinnerWhileEmpty(&self, shows_spinner_while_empty: bool);
/// The configuration of the Assistant Cell.
///
/// Assigning to this property will dynamically update the List Template to reflect the visibility, position, and intent identifier of the Assistant Cell.
///
///
/// Note: The Assistant Cell is only supported by CarPlay Audio and Communication Apps.
///
///
/// Unlike
/// `CPListItem,`your application will not receive a callback when the user selects the cell.
/// Instead, configure an Intents app extention to receive user requests from SiriKit, in order to turn the requests into an
/// app-specific actions.
#[unsafe(method(assistantCellConfiguration))]
#[unsafe(method_family = none)]
pub unsafe fn assistantCellConfiguration(
&self,
) -> Option<Retained<CPAssistantCellConfiguration>>;
/// Setter for [`assistantCellConfiguration`][Self::assistantCellConfiguration].
#[unsafe(method(setAssistantCellConfiguration:))]
#[unsafe(method_family = none)]
pub unsafe fn setAssistantCellConfiguration(
&self,
assistant_cell_configuration: Option<&CPAssistantCellConfiguration>,
);
/// The maximum number of grid buttons that may appear in a
/// `CPListTemplate.`
/// Note: Your list template will display the first
/// `maximumHeaderGridButtonCount`buttons.
/// Any sections beyond that limit will be trimmed.
#[unsafe(method(maximumHeaderGridButtonCount))]
#[unsafe(method_family = none)]
pub unsafe fn maximumHeaderGridButtonCount(mtm: MainThreadMarker) -> NSUInteger;
#[cfg(feature = "objc2-core-foundation")]
/// The expected image size for your
/// `CPGridButton.`
/// To properly size your list images, your app should size them to the display scale of the car screen.
/// See -[CPInterfaceController carTraitCollection].
#[unsafe(method(maximumGridButtonImageSize))]
#[unsafe(method_family = none)]
pub unsafe fn maximumGridButtonImageSize(mtm: MainThreadMarker) -> CGSize;
#[cfg(feature = "CPGridButton")]
/// Assigning to this property will dynamically update the List Template and show the new header.
#[unsafe(method(headerGridButtons))]
#[unsafe(method_family = none)]
pub unsafe fn headerGridButtons(&self) -> Option<Retained<NSArray<CPGridButton>>>;
#[cfg(feature = "CPGridButton")]
/// Setter for [`headerGridButtons`][Self::headerGridButtons].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setHeaderGridButtons:))]
#[unsafe(method_family = none)]
pub unsafe fn setHeaderGridButtons(
&self,
header_grid_buttons: Option<&NSArray<CPGridButton>>,
);
);
}
extern_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/carplay/cplisttemplatedelegate?language=objc)
#[deprecated]
pub unsafe trait CPListTemplateDelegate: NSObjectProtocol {
#[cfg(all(feature = "CPListItem", feature = "CPTemplate", feature = "block2"))]
/// The user has selected an item in the list template.
///
/// Your app has an opportunity to perform any necessary operations to prepare for completing
/// this item selection. The list template will display a spinner after a short delay.
///
/// You must call the completion block after your app has finished loading and updated its UI.
///
///
/// Parameter `listTemplate`: The list template containing this item
///
/// Parameter `item`: The item selected by the user
///
/// Parameter `completionHandler`: A completion block you must call after you have updated your UI.
#[deprecated]
#[unsafe(method(listTemplate:didSelectListItem:completionHandler:))]
#[unsafe(method_family = none)]
unsafe fn listTemplate_didSelectListItem_completionHandler(
&self,
list_template: &CPListTemplate,
item: &CPListItem,
completion_handler: &block2::DynBlock<dyn Fn()>,
);
}
);