objc2_car_play/generated/
CPAlertAction.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
12/// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpalertactionstyle?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct CPAlertActionStyle(pub NSUInteger);
17impl CPAlertActionStyle {
18    #[doc(alias = "CPAlertActionStyleDefault")]
19    pub const Default: Self = Self(0);
20    #[doc(alias = "CPAlertActionStyleCancel")]
21    pub const Cancel: Self = Self(1);
22    #[doc(alias = "CPAlertActionStyleDestructive")]
23    pub const Destructive: Self = Self(2);
24}
25
26unsafe impl Encode for CPAlertActionStyle {
27    const ENCODING: Encoding = NSUInteger::ENCODING;
28}
29
30unsafe impl RefEncode for CPAlertActionStyle {
31    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
32}
33
34/// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpalertactionhandler?language=objc)
35#[cfg(feature = "block2")]
36pub type CPAlertActionHandler = *mut block2::DynBlock<dyn Fn(NonNull<CPAlertAction>)>;
37
38extern_class!(
39    /// `CPAlertAction`represents a single action that appears inside of a
40    /// `CPActionSheetTemplate`or
41    /// `CPAlertTemplate.`
42    /// The style of the parent template and the style of the
43    /// `CPAlertAction`will together
44    /// determine the action's appearance.
45    ///
46    /// The action has a customizable title, style, and a block callback
47    /// that is invoked when the user taps this button.
48    ///
49    /// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpalertaction?language=objc)
50    #[unsafe(super(NSObject))]
51    #[derive(Debug, PartialEq, Eq, Hash)]
52    pub struct CPAlertAction;
53);
54
55extern_conformance!(
56    unsafe impl NSCoding for CPAlertAction {}
57);
58
59extern_conformance!(
60    unsafe impl NSObjectProtocol for CPAlertAction {}
61);
62
63extern_conformance!(
64    unsafe impl NSSecureCoding for CPAlertAction {}
65);
66
67impl CPAlertAction {
68    extern_methods!(
69        #[unsafe(method(init))]
70        #[unsafe(method_family = init)]
71        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
72
73        #[unsafe(method(new))]
74        #[unsafe(method_family = new)]
75        pub unsafe fn new() -> Retained<Self>;
76
77        #[cfg(feature = "block2")]
78        /// Create an alert action with a title, display style, and a callback handler that is invoked
79        /// when the user taps this action.
80        ///
81        /// # Safety
82        ///
83        /// `handler` must be a valid pointer.
84        #[unsafe(method(initWithTitle:style:handler:))]
85        #[unsafe(method_family = init)]
86        pub unsafe fn initWithTitle_style_handler(
87            this: Allocated<Self>,
88            title: &NSString,
89            style: CPAlertActionStyle,
90            handler: CPAlertActionHandler,
91        ) -> Retained<Self>;
92
93        #[cfg(all(feature = "block2", feature = "objc2-ui-kit"))]
94        /// Create an alert action with a title, a custom action color, and a callback handler that is invoked
95        /// when the user taps this action.
96        ///
97        /// The system will automatically determine if the provided color meets contrast requirements.
98        /// If the provided color does not meet contrast requirements, the system default will be used.
99        /// Font color will automatically be adjusted by the system to correspond with this color.
100        /// Alpha values will be ignored.
101        ///
102        /// # Safety
103        ///
104        /// `handler` must be a valid pointer.
105        #[unsafe(method(initWithTitle:color:handler:))]
106        #[unsafe(method_family = init)]
107        pub unsafe fn initWithTitle_color_handler(
108            this: Allocated<Self>,
109            title: &NSString,
110            color: &UIColor,
111            handler: CPAlertActionHandler,
112        ) -> Retained<Self>;
113
114        #[unsafe(method(title))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn title(&self) -> Retained<NSString>;
117
118        #[unsafe(method(style))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn style(&self) -> CPAlertActionStyle;
121
122        #[cfg(feature = "block2")]
123        /// # Safety
124        ///
125        /// The returned block's argument must be a valid pointer.
126        #[unsafe(method(handler))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn handler(&self) -> CPAlertActionHandler;
129
130        #[cfg(feature = "objc2-ui-kit")]
131        #[unsafe(method(color))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn color(&self) -> Option<Retained<UIColor>>;
134    );
135}