objc2_car_play/generated/
CPInterfaceController.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::*;
6use objc2_foundation::*;
7#[cfg(feature = "objc2-ui-kit")]
8use objc2_ui_kit::*;
9
10use crate::*;
11
12extern "C" {
13    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/carplayerrordomain?language=objc)
14    pub static CarPlayErrorDomain: &'static NSString;
15}
16
17extern_class!(
18    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpinterfacecontroller?language=objc)
19    #[unsafe(super(NSObject))]
20    #[thread_kind = MainThreadOnly]
21    #[derive(Debug, PartialEq, Eq, Hash)]
22    pub struct CPInterfaceController;
23);
24
25extern_conformance!(
26    unsafe impl NSObjectProtocol for CPInterfaceController {}
27);
28
29impl CPInterfaceController {
30    extern_methods!(
31        #[unsafe(method(init))]
32        #[unsafe(method_family = init)]
33        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
34
35        #[unsafe(method(new))]
36        #[unsafe(method_family = new)]
37        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
38
39        /// The delegate for this interface controller.
40        #[unsafe(method(delegate))]
41        #[unsafe(method_family = none)]
42        pub unsafe fn delegate(
43            &self,
44        ) -> Option<Retained<ProtocolObject<dyn CPInterfaceControllerDelegate>>>;
45
46        /// Setter for [`delegate`][Self::delegate].
47        ///
48        /// This is a [weak property][objc2::topics::weak_property].
49        #[unsafe(method(setDelegate:))]
50        #[unsafe(method_family = none)]
51        pub unsafe fn setDelegate(
52            &self,
53            delegate: Option<&ProtocolObject<dyn CPInterfaceControllerDelegate>>,
54        );
55
56        /// Set the preferred interface style to UIUserInterfaceStyleDark for all templates. Set this value to YES prior to setting a root template
57        /// or pushing any templates for first appearance to have style UIUserInterfaceStyleDark. The default value is NO which will allow templates to change between light and dark styles.
58        #[unsafe(method(prefersDarkUserInterfaceStyle))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn prefersDarkUserInterfaceStyle(&self) -> bool;
61
62        /// Setter for [`prefersDarkUserInterfaceStyle`][Self::prefersDarkUserInterfaceStyle].
63        #[unsafe(method(setPrefersDarkUserInterfaceStyle:))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn setPrefersDarkUserInterfaceStyle(
66            &self,
67            prefers_dark_user_interface_style: bool,
68        );
69
70        #[cfg(all(feature = "CPTemplate", feature = "block2"))]
71        /// Set the root template. If no existing templates exist in the template navigation hierarchy, the animated flag will be ignored.
72        /// If there is an existing template navigation hierarchy, the existing stack will be replaced by the new root template.
73        ///
74        /// The completion block will be called after the template has been presented. If the template was presented successfully,
75        /// the boolean parameter will be YES. Otherwise, the boolean parameter will be NO and an
76        /// `NSError`will be provided describing the failure.
77        ///
78        ///
79        /// Note: If the template presentation is not successful AND no completion block is specified, an exception will be thrown.
80        #[unsafe(method(setRootTemplate:animated:completion:))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn setRootTemplate_animated_completion(
83            &self,
84            root_template: &CPTemplate,
85            animated: bool,
86            completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
87        );
88
89        #[cfg(all(feature = "CPTemplate", feature = "block2"))]
90        /// Push a new template onto the template navigation hierarchy, showing it immediately.
91        ///
92        /// The completion block will be called after the template has been presented. If the template was presented successfully,
93        /// the boolean parameter will be YES. Otherwise, the boolean parameter will be NO and an
94        /// `NSError`will be provided describing the failure.
95        ///
96        ///
97        /// Note: If the template presentation is not successful AND no completion block is specified, an exception will be thrown.
98        #[unsafe(method(pushTemplate:animated:completion:))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn pushTemplate_animated_completion(
101            &self,
102            template_to_push: &CPTemplate,
103            animated: bool,
104            completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
105        );
106
107        #[cfg(feature = "block2")]
108        /// Pop back a single level in the template navigation hierarchy.
109        /// The completion block will be called after the pop completes.
110        /// The success parameter in the completion block indicates if any template was popped.
111        #[unsafe(method(popTemplateAnimated:completion:))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn popTemplateAnimated_completion(
114            &self,
115            animated: bool,
116            completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
117        );
118
119        #[cfg(feature = "block2")]
120        /// Pop back to the first template in the template navigation hierarchy.
121        /// The completion block will be called after the pop completes.
122        /// The success parameter in the completion block indicates if any templates were popped.
123        #[unsafe(method(popToRootTemplateAnimated:completion:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn popToRootTemplateAnimated_completion(
126            &self,
127            animated: bool,
128            completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
129        );
130
131        #[cfg(all(feature = "CPTemplate", feature = "block2"))]
132        /// Pop back to a specified template.
133        ///
134        /// targetTemplate must exist in the current template navigation hierarchy.
135        ///
136        /// The completion block will be called after the pop completes.
137        /// If the specified template does not exist in the template stack,
138        /// the completion block will be called with a success parameter of NO and a non-nil NSError.
139        #[unsafe(method(popToTemplate:animated:completion:))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn popToTemplate_animated_completion(
142            &self,
143            target_template: &CPTemplate,
144            animated: bool,
145            completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
146        );
147
148        #[cfg(all(feature = "CPTemplate", feature = "block2"))]
149        /// Present a template modally over the navigation hierarchy. Only one template may be presented at a time.
150        ///
151        ///
152        /// Note: Supported template types:
153        /// `CPActionSheetTemplate,``CPAlertTemplate,``CPVoiceControlTemplate`The completion block will be called after the template has been presented. If the template was presented successfully,
154        /// the boolean parameter will be YES. Otherwise, the boolean parameter will be NO and an
155        /// `NSError`will be provided describing the failure.
156        ///
157        ///
158        /// Note: If the template presentation is not successful AND no completion block is specified, an exception will be thrown.
159        #[unsafe(method(presentTemplate:animated:completion:))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn presentTemplate_animated_completion(
162            &self,
163            template_to_present: &CPTemplate,
164            animated: bool,
165            completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
166        );
167
168        #[cfg(feature = "block2")]
169        /// Dismiss the current modally-presented template, optionally animating the dismissal.
170        ///
171        ///
172        /// Note: If there is no current modally-presented template, this method will have no effect.
173        ///
174        /// The completion block will be called after the template has been dismissed. If the template was dismissed successfully,
175        /// the boolean parameter will be YES. Otherwise, the boolean parameter will be NO and an
176        /// `NSError`will be provided describing the failure.
177        #[unsafe(method(dismissTemplateAnimated:completion:))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn dismissTemplateAnimated_completion(
180            &self,
181            animated: bool,
182            completion: Option<&block2::DynBlock<dyn Fn(Bool, *mut NSError)>>,
183        );
184
185        #[cfg(feature = "CPTemplate")]
186        /// The current modally-presented template.
187        ///
188        ///
189        /// Warning: Reading this property may synchronously perform an IPC call to retrieve the current presented template.
190        #[unsafe(method(presentedTemplate))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn presentedTemplate(&self) -> Option<Retained<CPTemplate>>;
193
194        #[cfg(feature = "CPTemplate")]
195        /// Returns the root template.
196        #[unsafe(method(rootTemplate))]
197        #[unsafe(method_family = none)]
198        pub unsafe fn rootTemplate(&self) -> Retained<CPTemplate>;
199
200        #[cfg(feature = "CPTemplate")]
201        /// The top template in the navigation hierarchy.
202        ///
203        ///
204        /// Warning: Reading this property may synchronously perform an IPC call to retrieve the current top-most template.
205        #[unsafe(method(topTemplate))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn topTemplate(&self) -> Option<Retained<CPTemplate>>;
208
209        #[cfg(feature = "CPTemplate")]
210        /// The current stack of templates in the navigation hierarchy.
211        ///
212        ///
213        /// Warning: Reading this property may synchronously perform an IPC call to retrieve the current stack of templates.
214        #[unsafe(method(templates))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn templates(&self) -> Retained<NSArray<CPTemplate>>;
217
218        #[cfg(feature = "objc2-ui-kit")]
219        /// The trait collection for the car's primary screen.
220        ///
221        /// Your app should use this trait collection when deriving metrics, like screen scale, for
222        /// your templates. For example, images you display in any template should be sized to a
223        /// display scale matching the scale of the
224        /// `carTraitCollection,`not the scale of the
225        /// iOS device's main screen.
226        #[unsafe(method(carTraitCollection))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn carTraitCollection(&self) -> Retained<UITraitCollection>;
229
230        #[cfg(feature = "CPTemplate")]
231        /// Set the root template. If no existing templates exist in the template navigation hierarchy, the animated flag will be ignored.
232        /// If there is an existing template navigation hierarchy, the existing stack will be replaced by the new root template.
233        #[deprecated]
234        #[unsafe(method(setRootTemplate:animated:))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn setRootTemplate_animated(&self, root_template: &CPTemplate, animated: bool);
237
238        #[cfg(feature = "CPTemplate")]
239        /// Push a new template onto the template navigation hierarchy, showing it immediately.
240        #[deprecated]
241        #[unsafe(method(pushTemplate:animated:))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn pushTemplate_animated(&self, template_to_push: &CPTemplate, animated: bool);
244
245        /// Pop back a single level in the template navigation hierarchy.
246        #[deprecated]
247        #[unsafe(method(popTemplateAnimated:))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn popTemplateAnimated(&self, animated: bool);
250
251        /// Pop back to the first template in the template navigation hierarchy.
252        #[deprecated]
253        #[unsafe(method(popToRootTemplateAnimated:))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn popToRootTemplateAnimated(&self, animated: bool);
256
257        #[cfg(feature = "CPTemplate")]
258        /// Pop back to a specified template.
259        ///
260        /// targetTemplate must exist in the current template navigation hierarchy.
261        #[deprecated]
262        #[unsafe(method(popToTemplate:animated:))]
263        #[unsafe(method_family = none)]
264        pub unsafe fn popToTemplate_animated(&self, target_template: &CPTemplate, animated: bool);
265
266        #[cfg(feature = "CPTemplate")]
267        /// Present a template modally over the navigation hierarchy. Only one template may be presented at a time.
268        ///
269        ///
270        /// Note: Supported template types:
271        /// `CPActionSheetTemplate,``CPAlertTemplate,``CPVoiceControlTemplate`
272        #[deprecated]
273        #[unsafe(method(presentTemplate:animated:))]
274        #[unsafe(method_family = none)]
275        pub unsafe fn presentTemplate_animated(
276            &self,
277            template_to_present: &CPTemplate,
278            animated: bool,
279        );
280
281        /// Dismiss the current modally-presented template, optionally animating the dismissal.
282        ///
283        ///
284        /// Note: If there is no current modally-presented template, this method will have no effect.
285        #[deprecated]
286        #[unsafe(method(dismissTemplateAnimated:))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn dismissTemplateAnimated(&self, animated: bool);
289    );
290}
291
292extern_protocol!(
293    /// CPInterfaceControllerDelegate allows your app to observe template visibility lifecycles for
294    /// the templates presented by your app.
295    ///
296    /// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpinterfacecontrollerdelegate?language=objc)
297    pub unsafe trait CPInterfaceControllerDelegate:
298        NSObjectProtocol + MainThreadOnly
299    {
300        #[cfg(feature = "CPTemplate")]
301        #[optional]
302        #[unsafe(method(templateWillAppear:animated:))]
303        #[unsafe(method_family = none)]
304        unsafe fn templateWillAppear_animated(&self, a_template: &CPTemplate, animated: bool);
305
306        #[cfg(feature = "CPTemplate")]
307        #[optional]
308        #[unsafe(method(templateDidAppear:animated:))]
309        #[unsafe(method_family = none)]
310        unsafe fn templateDidAppear_animated(&self, a_template: &CPTemplate, animated: bool);
311
312        #[cfg(feature = "CPTemplate")]
313        #[optional]
314        #[unsafe(method(templateWillDisappear:animated:))]
315        #[unsafe(method_family = none)]
316        unsafe fn templateWillDisappear_animated(&self, a_template: &CPTemplate, animated: bool);
317
318        #[cfg(feature = "CPTemplate")]
319        #[optional]
320        #[unsafe(method(templateDidDisappear:animated:))]
321        #[unsafe(method_family = none)]
322        unsafe fn templateDidDisappear_animated(&self, a_template: &CPTemplate, animated: bool);
323    }
324);
325
326extern_protocol!(
327    /// A set of methods that are called by the
328    /// `UIApplication`singleton in response to CarPlay lifecycle events.
329    ///
330    ///
331    /// This must be implemented by the same object that serves as your application's delegate object.
332    ///
333    /// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpapplicationdelegate?language=objc)
334    #[cfg(feature = "objc2-ui-kit")]
335    #[deprecated]
336    pub unsafe trait CPApplicationDelegate: UIApplicationDelegate {
337        #[cfg(feature = "CPWindow")]
338        /// The CarPlay screen has connected and is ready to present content.
339        ///
340        /// Your app should create its view controller and assign it to the
341        /// `rootViewController`property
342        /// of this window.
343        ///
344        ///
345        /// Note: It is the responsibility of the delegate to maintain a reference to the interface controller beyond the scope of this method.
346        #[deprecated]
347        #[unsafe(method(application:didConnectCarInterfaceController:toWindow:))]
348        #[unsafe(method_family = none)]
349        unsafe fn application_didConnectCarInterfaceController_toWindow(
350            &self,
351            application: &UIApplication,
352            interface_controller: &CPInterfaceController,
353            window: &CPWindow,
354        );
355
356        #[cfg(feature = "CPWindow")]
357        /// The CarPlay screen has disconnected.
358        #[deprecated]
359        #[unsafe(method(application:didDisconnectCarInterfaceController:fromWindow:))]
360        #[unsafe(method_family = none)]
361        unsafe fn application_didDisconnectCarInterfaceController_fromWindow(
362            &self,
363            application: &UIApplication,
364            interface_controller: &CPInterfaceController,
365            window: &CPWindow,
366        );
367
368        #[cfg(feature = "CPNavigationAlert")]
369        /// If your application posts a
370        /// `CPNavigationAlert`while backgrounded, a notification banner may be presented to the user.
371        /// If the user taps on that banner, your application will launch on the car screen and this method will be called
372        /// with the alert the user tapped.
373        #[deprecated]
374        #[optional]
375        #[unsafe(method(application:didSelectNavigationAlert:))]
376        #[unsafe(method_family = none)]
377        unsafe fn application_didSelectNavigationAlert(
378            &self,
379            application: &UIApplication,
380            navigation_alert: &CPNavigationAlert,
381        );
382
383        #[cfg(feature = "CPManeuver")]
384        /// If your application posts a
385        /// `CPManeuver`while backgrounded, a notification banner may be presented to the user.
386        /// If the user taps on that banner, your application will launch on the car screen and this method will be called
387        /// with the maneuver the user tapped.
388        #[deprecated]
389        #[optional]
390        #[unsafe(method(application:didSelectManeuver:))]
391        #[unsafe(method_family = none)]
392        unsafe fn application_didSelectManeuver(
393            &self,
394            application: &UIApplication,
395            maneuver: &CPManeuver,
396        );
397    }
398);