objc2_car_play/generated/
CPListTemplate.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/carplay/cpassistantcellactiontype?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct CPAssistantCellActionType(pub NSInteger);
17impl CPAssistantCellActionType {
18    #[doc(alias = "CPAssistantCellActionTypePlayMedia")]
19    pub const PlayMedia: Self = Self(0);
20    #[doc(alias = "CPAssistantCellActionTypeStartCall")]
21    pub const StartCall: Self = Self(1);
22}
23
24unsafe impl Encode for CPAssistantCellActionType {
25    const ENCODING: Encoding = NSInteger::ENCODING;
26}
27
28unsafe impl RefEncode for CPAssistantCellActionType {
29    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32/// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpassistantcellvisibility?language=objc)
33// NS_ENUM
34#[repr(transparent)]
35#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
36pub struct CPAssistantCellVisibility(pub NSInteger);
37impl CPAssistantCellVisibility {
38    #[doc(alias = "CPAssistantCellVisibilityOff")]
39    pub const Off: Self = Self(0);
40    #[doc(alias = "CPAssistantCellVisibilityWhileLimitedUIActive")]
41    pub const WhileLimitedUIActive: Self = Self(1);
42    #[doc(alias = "CPAssistantCellVisibilityAlways")]
43    pub const Always: Self = Self(2);
44}
45
46unsafe impl Encode for CPAssistantCellVisibility {
47    const ENCODING: Encoding = NSInteger::ENCODING;
48}
49
50unsafe impl RefEncode for CPAssistantCellVisibility {
51    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
52}
53
54/// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpassistantcellposition?language=objc)
55// NS_ENUM
56#[repr(transparent)]
57#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
58pub struct CPAssistantCellPosition(pub NSInteger);
59impl CPAssistantCellPosition {
60    #[doc(alias = "CPAssistantCellPositionTop")]
61    pub const Top: Self = Self(0);
62    #[doc(alias = "CPAssistantCellPositionBottom")]
63    pub const Bottom: Self = Self(1);
64}
65
66unsafe impl Encode for CPAssistantCellPosition {
67    const ENCODING: Encoding = NSInteger::ENCODING;
68}
69
70unsafe impl RefEncode for CPAssistantCellPosition {
71    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
72}
73
74extern_class!(
75    /// `CPAssistantCellConfiguration`encapsulates the configuration options for your assistant cell.
76    ///
77    ///
78    /// Note: The Assistant Cell is only supported by CarPlay Audio and Communication apps.
79    ///
80    /// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpassistantcellconfiguration?language=objc)
81    #[unsafe(super(NSObject))]
82    #[derive(Debug, PartialEq, Eq, Hash)]
83    pub struct CPAssistantCellConfiguration;
84);
85
86extern_conformance!(
87    unsafe impl NSCoding for CPAssistantCellConfiguration {}
88);
89
90extern_conformance!(
91    unsafe impl NSObjectProtocol for CPAssistantCellConfiguration {}
92);
93
94extern_conformance!(
95    unsafe impl NSSecureCoding for CPAssistantCellConfiguration {}
96);
97
98impl CPAssistantCellConfiguration {
99    extern_methods!(
100        /// 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.
101        #[unsafe(method(initWithPosition:visibility:assistantAction:))]
102        #[unsafe(method_family = init)]
103        pub unsafe fn initWithPosition_visibility_assistantAction(
104            this: Allocated<Self>,
105            position: CPAssistantCellPosition,
106            visibility: CPAssistantCellVisibility,
107            assistant_action: CPAssistantCellActionType,
108        ) -> Retained<Self>;
109
110        /// The position of the Assistant Cell.
111        ///
112        ///
113        /// Note: The default value of this property is
114        /// `CPAssistantCellPositionTop.`
115        #[unsafe(method(position))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn position(&self) -> CPAssistantCellPosition;
118
119        /// The visibility of the Assistant Cell.
120        ///
121        ///
122        /// Note: The default value of this property is
123        /// `CPAssistantCellVisibilityOff.`
124        #[unsafe(method(visibility))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn visibility(&self) -> CPAssistantCellVisibility;
127
128        /// The action that Siri will perform when users select the assistant cell.
129        #[unsafe(method(assistantAction))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn assistantAction(&self) -> CPAssistantCellActionType;
132    );
133}
134
135/// Methods declared on superclass `NSObject`.
136impl CPAssistantCellConfiguration {
137    extern_methods!(
138        #[unsafe(method(init))]
139        #[unsafe(method_family = init)]
140        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
141
142        #[unsafe(method(new))]
143        #[unsafe(method_family = new)]
144        pub unsafe fn new() -> Retained<Self>;
145    );
146}
147
148extern_class!(
149    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cplisttemplate?language=objc)
150    #[unsafe(super(CPTemplate, NSObject))]
151    #[thread_kind = MainThreadOnly]
152    #[derive(Debug, PartialEq, Eq, Hash)]
153    #[cfg(feature = "CPTemplate")]
154    pub struct CPListTemplate;
155);
156
157#[cfg(all(feature = "CPBarButtonProviding", feature = "CPTemplate"))]
158extern_conformance!(
159    unsafe impl CPBarButtonProviding for CPListTemplate {}
160);
161
162#[cfg(feature = "CPTemplate")]
163extern_conformance!(
164    unsafe impl NSCoding for CPListTemplate {}
165);
166
167#[cfg(feature = "CPTemplate")]
168extern_conformance!(
169    unsafe impl NSObjectProtocol for CPListTemplate {}
170);
171
172#[cfg(feature = "CPTemplate")]
173extern_conformance!(
174    unsafe impl NSSecureCoding for CPListTemplate {}
175);
176
177#[cfg(feature = "CPTemplate")]
178impl CPListTemplate {
179    extern_methods!(
180        #[unsafe(method(init))]
181        #[unsafe(method_family = init)]
182        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
183
184        #[unsafe(method(new))]
185        #[unsafe(method_family = new)]
186        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
187
188        #[cfg(feature = "CPListSection")]
189        /// Initialize a list template with one or more sections of items and an optional title.
190        #[unsafe(method(initWithTitle:sections:))]
191        #[unsafe(method_family = init)]
192        pub unsafe fn initWithTitle_sections(
193            this: Allocated<Self>,
194            title: Option<&NSString>,
195            sections: &NSArray<CPListSection>,
196        ) -> Retained<Self>;
197
198        #[cfg(feature = "CPListSection")]
199        /// Initialize a list template with one or more sections of items, an optional title, and configuration for the assistant cell via a
200        /// `CPAssistantCellConfiguration`object.
201        ///
202        ///
203        /// Note: The Assistant Cell is only supported by CarPlay Audio and Communication Apps.
204        ///
205        ///
206        /// Unlike
207        /// `CPListItem,`your application will not receive a callback when the user selects the cell.
208        /// Instead, configure an Intents app extention to receive user requests from SiriKit, in order to turn the requests into an
209        /// app-specific actions.
210        #[unsafe(method(initWithTitle:sections:assistantCellConfiguration:))]
211        #[unsafe(method_family = init)]
212        pub unsafe fn initWithTitle_sections_assistantCellConfiguration(
213            this: Allocated<Self>,
214            title: Option<&NSString>,
215            sections: &NSArray<CPListSection>,
216            assistant_cell_configuration: Option<&CPAssistantCellConfiguration>,
217        ) -> Retained<Self>;
218
219        #[cfg(all(feature = "CPGridButton", feature = "CPListSection"))]
220        /// Initialize a list template with one or more grid buttons to displayed in a list header.
221        #[unsafe(method(initWithTitle:sections:assistantCellConfiguration:headerGridButtons:))]
222        #[unsafe(method_family = init)]
223        pub unsafe fn initWithTitle_sections_assistantCellConfiguration_headerGridButtons(
224            this: Allocated<Self>,
225            title: Option<&NSString>,
226            sections: &NSArray<CPListSection>,
227            assistant_cell_configuration: Option<&CPAssistantCellConfiguration>,
228            header_grid_buttons: Option<&NSArray<CPGridButton>>,
229        ) -> Retained<Self>;
230
231        /// The list template's delegate is informed of list selection events.
232        #[deprecated]
233        #[unsafe(method(delegate))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn delegate(
236            &self,
237        ) -> Option<Retained<ProtocolObject<dyn CPListTemplateDelegate>>>;
238
239        /// Setter for [`delegate`][Self::delegate].
240        ///
241        /// This is a [weak property][objc2::topics::weak_property].
242        #[deprecated]
243        #[unsafe(method(setDelegate:))]
244        #[unsafe(method_family = none)]
245        pub unsafe fn setDelegate(
246            &self,
247            delegate: Option<&ProtocolObject<dyn CPListTemplateDelegate>>,
248        );
249
250        /// The maximum number of items, across all sections, that may appear in a
251        /// `CPListTemplate.`
252        /// Note: Your list template will display the first
253        /// `maximumItemCount`items, across all sections.
254        /// Any items or sections beyond that limit will be trimmed.
255        #[unsafe(method(maximumItemCount))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn maximumItemCount(mtm: MainThreadMarker) -> NSUInteger;
258
259        /// The maximum number of sections that may appear in a
260        /// `CPListTemplate.`
261        /// Note: Your list template will display the first
262        /// `maximumSectionCount`sections.
263        /// Any sections beyond that limit will be trimmed.
264        #[unsafe(method(maximumSectionCount))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn maximumSectionCount(mtm: MainThreadMarker) -> NSUInteger;
267
268        #[cfg(feature = "CPListSection")]
269        /// The sections displayed in this list.
270        #[unsafe(method(sections))]
271        #[unsafe(method_family = none)]
272        pub unsafe fn sections(&self) -> Retained<NSArray<CPListSection>>;
273
274        /// Title shown in the navigation bar while this template is visible.
275        #[unsafe(method(title))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn title(&self) -> Option<Retained<NSString>>;
278
279        #[cfg(feature = "CPListSection")]
280        /// Update the list of sections displayed in this list template, reloading
281        /// the table view displaying this list.
282        #[unsafe(method(updateSections:))]
283        #[unsafe(method_family = none)]
284        pub unsafe fn updateSections(&self, sections: &NSArray<CPListSection>);
285
286        /// The number of sections currently displayed in this list template.
287        #[unsafe(method(sectionCount))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn sectionCount(&self) -> NSUInteger;
290
291        /// The number of items currently displayed in this list template, across all sections.
292        #[unsafe(method(itemCount))]
293        #[unsafe(method_family = none)]
294        pub unsafe fn itemCount(&self) -> NSUInteger;
295
296        #[cfg(feature = "CPListItemTypes")]
297        /// Return an
298        /// `NSIndexPath`for the specified item, if it exists in any section
299        /// in this list template, or nil if not found.
300        #[unsafe(method(indexPathForItem:))]
301        #[unsafe(method_family = none)]
302        pub unsafe fn indexPathForItem(
303            &self,
304            item: &ProtocolObject<dyn CPListTemplateItem>,
305        ) -> Option<Retained<NSIndexPath>>;
306
307        /// An optional array of strings, ordered from most to least preferred.
308        /// The variant strings should be provided as localized, displayable content.
309        /// The system will select the first variant that fits the available space.
310        ///
311        /// If the list template does not contain any items (itemCount == 0), then
312        /// the template will display an empty view with a title and subtitle to indicate
313        /// that the template has no list items.
314        ///
315        /// If the list template is updated to contain items, the empty view will be automatically
316        /// removed.
317        #[unsafe(method(emptyViewTitleVariants))]
318        #[unsafe(method_family = none)]
319        pub unsafe fn emptyViewTitleVariants(&self) -> Retained<NSArray<NSString>>;
320
321        /// Setter for [`emptyViewTitleVariants`][Self::emptyViewTitleVariants].
322        ///
323        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
324        #[unsafe(method(setEmptyViewTitleVariants:))]
325        #[unsafe(method_family = none)]
326        pub unsafe fn setEmptyViewTitleVariants(
327            &self,
328            empty_view_title_variants: &NSArray<NSString>,
329        );
330
331        /// An optional array of strings, ordered from most to least preferred.
332        /// The variant strings should be provided as localized, displayable content.
333        /// The system will select the first variant that fits the available space.
334        ///
335        /// If the list template does not contain any items (itemCount == 0), then
336        /// the template will display an empty view with a title and subtitle to indicate
337        /// that the template has no list items.
338        ///
339        /// If the list template is updated to contain items, the empty view will be automatically
340        /// removed.
341        #[unsafe(method(emptyViewSubtitleVariants))]
342        #[unsafe(method_family = none)]
343        pub unsafe fn emptyViewSubtitleVariants(&self) -> Retained<NSArray<NSString>>;
344
345        /// Setter for [`emptyViewSubtitleVariants`][Self::emptyViewSubtitleVariants].
346        ///
347        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
348        #[unsafe(method(setEmptyViewSubtitleVariants:))]
349        #[unsafe(method_family = none)]
350        pub unsafe fn setEmptyViewSubtitleVariants(
351            &self,
352            empty_view_subtitle_variants: &NSArray<NSString>,
353        );
354
355        /// If YES, a spinning activity indicator will be displayed while the list template contains no items.
356        /// The activity indicator will be displayed in addition to any
357        /// `emptyViewTitleVariants`or
358        /// `emptyViewSubtitleVariants.`
359        #[unsafe(method(showsSpinnerWhileEmpty))]
360        #[unsafe(method_family = none)]
361        pub unsafe fn showsSpinnerWhileEmpty(&self) -> bool;
362
363        /// Setter for [`showsSpinnerWhileEmpty`][Self::showsSpinnerWhileEmpty].
364        #[unsafe(method(setShowsSpinnerWhileEmpty:))]
365        #[unsafe(method_family = none)]
366        pub unsafe fn setShowsSpinnerWhileEmpty(&self, shows_spinner_while_empty: bool);
367
368        /// The configuration of the Assistant Cell.
369        ///
370        /// Assigning to this property will dynamically update the List Template to reflect the visibility, position, and intent identifier of the Assistant Cell.
371        ///
372        ///
373        /// Note: The Assistant Cell is only supported by CarPlay Audio and Communication Apps.
374        ///
375        ///
376        /// Unlike
377        /// `CPListItem,`your application will not receive a callback when the user selects the cell.
378        /// Instead, configure an Intents app extention to receive user requests from SiriKit, in order to turn the requests into an
379        /// app-specific actions.
380        #[unsafe(method(assistantCellConfiguration))]
381        #[unsafe(method_family = none)]
382        pub unsafe fn assistantCellConfiguration(
383            &self,
384        ) -> Option<Retained<CPAssistantCellConfiguration>>;
385
386        /// Setter for [`assistantCellConfiguration`][Self::assistantCellConfiguration].
387        #[unsafe(method(setAssistantCellConfiguration:))]
388        #[unsafe(method_family = none)]
389        pub unsafe fn setAssistantCellConfiguration(
390            &self,
391            assistant_cell_configuration: Option<&CPAssistantCellConfiguration>,
392        );
393
394        /// The maximum number of grid buttons that may appear in a
395        /// `CPListTemplate.`
396        /// Note: Your list template will display the first
397        /// `maximumHeaderGridButtonCount`buttons.
398        /// Any sections beyond that limit will be trimmed.
399        #[unsafe(method(maximumHeaderGridButtonCount))]
400        #[unsafe(method_family = none)]
401        pub unsafe fn maximumHeaderGridButtonCount(mtm: MainThreadMarker) -> NSUInteger;
402
403        #[cfg(feature = "objc2-core-foundation")]
404        /// The expected image size for your
405        /// `CPGridButton.`
406        /// To properly size your list images, your app should size them to the display scale of the car screen.
407        /// See -[CPInterfaceController carTraitCollection].
408        #[unsafe(method(maximumGridButtonImageSize))]
409        #[unsafe(method_family = none)]
410        pub unsafe fn maximumGridButtonImageSize(mtm: MainThreadMarker) -> CGSize;
411
412        #[cfg(feature = "CPGridButton")]
413        /// Assigning to this property will dynamically update the List Template and show the new header.
414        #[unsafe(method(headerGridButtons))]
415        #[unsafe(method_family = none)]
416        pub unsafe fn headerGridButtons(&self) -> Option<Retained<NSArray<CPGridButton>>>;
417
418        #[cfg(feature = "CPGridButton")]
419        /// Setter for [`headerGridButtons`][Self::headerGridButtons].
420        ///
421        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
422        #[unsafe(method(setHeaderGridButtons:))]
423        #[unsafe(method_family = none)]
424        pub unsafe fn setHeaderGridButtons(
425            &self,
426            header_grid_buttons: Option<&NSArray<CPGridButton>>,
427        );
428    );
429}
430
431extern_protocol!(
432    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cplisttemplatedelegate?language=objc)
433    #[deprecated]
434    pub unsafe trait CPListTemplateDelegate: NSObjectProtocol {
435        #[cfg(all(feature = "CPListItem", feature = "CPTemplate", feature = "block2"))]
436        /// The user has selected an item in the list template.
437        ///
438        /// Your app has an opportunity to perform any necessary operations to prepare for completing
439        /// this item selection. The list template will display a spinner after a short delay.
440        ///
441        /// You must call the completion block after your app has finished loading and updated its UI.
442        ///
443        ///
444        /// Parameter `listTemplate`: The list template containing this item
445        ///
446        /// Parameter `item`: The item selected by the user
447        ///
448        /// Parameter `completionHandler`: A completion block you must call after you have updated your UI.
449        #[deprecated]
450        #[unsafe(method(listTemplate:didSelectListItem:completionHandler:))]
451        #[unsafe(method_family = none)]
452        unsafe fn listTemplate_didSelectListItem_completionHandler(
453            &self,
454            list_template: &CPListTemplate,
455            item: &CPListItem,
456            completion_handler: &block2::DynBlock<dyn Fn()>,
457        );
458    }
459);