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
//! 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::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-ui-kit")]
use objc2_ui_kit::*;
use crate::*;
/// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpalertactionstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CPAlertActionStyle(pub NSUInteger);
impl CPAlertActionStyle {
#[doc(alias = "CPAlertActionStyleDefault")]
pub const Default: Self = Self(0);
#[doc(alias = "CPAlertActionStyleCancel")]
pub const Cancel: Self = Self(1);
#[doc(alias = "CPAlertActionStyleDestructive")]
pub const Destructive: Self = Self(2);
}
unsafe impl Encode for CPAlertActionStyle {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for CPAlertActionStyle {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpalertactionhandler?language=objc)
#[cfg(feature = "block2")]
pub type CPAlertActionHandler = *mut block2::DynBlock<dyn Fn(NonNull<CPAlertAction>)>;
extern_class!(
/// `CPAlertAction`represents a single action that appears inside of a
/// `CPActionSheetTemplate`or
/// `CPAlertTemplate.`
/// The style of the parent template and the style of the
/// `CPAlertAction`will together
/// determine the action's appearance.
///
/// The action has a customizable title, style, and a block callback
/// that is invoked when the user taps this button.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpalertaction?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct CPAlertAction;
);
extern_conformance!(
unsafe impl NSCoding for CPAlertAction {}
);
extern_conformance!(
unsafe impl NSObjectProtocol for CPAlertAction {}
);
extern_conformance!(
unsafe impl NSSecureCoding for CPAlertAction {}
);
impl CPAlertAction {
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>;
#[cfg(feature = "block2")]
/// Create an alert action with a title, display style, and a callback handler that is invoked
/// when the user taps this action.
///
/// # Safety
///
/// `handler` must be a valid pointer.
#[unsafe(method(initWithTitle:style:handler:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithTitle_style_handler(
this: Allocated<Self>,
title: &NSString,
style: CPAlertActionStyle,
handler: CPAlertActionHandler,
) -> Retained<Self>;
#[cfg(all(feature = "block2", feature = "objc2-ui-kit"))]
/// Create an alert action with a title, a custom action color, and a callback handler that is invoked
/// when the user taps this action.
///
/// The system will automatically determine if the provided color meets contrast requirements.
/// If the provided color does not meet contrast requirements, the system default will be used.
/// Font color will automatically be adjusted by the system to correspond with this color.
/// Alpha values will be ignored.
///
/// # Safety
///
/// `handler` must be a valid pointer.
#[unsafe(method(initWithTitle:color:handler:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithTitle_color_handler(
this: Allocated<Self>,
title: &NSString,
color: &UIColor,
handler: CPAlertActionHandler,
) -> Retained<Self>;
#[unsafe(method(title))]
#[unsafe(method_family = none)]
pub unsafe fn title(&self) -> Retained<NSString>;
#[unsafe(method(style))]
#[unsafe(method_family = none)]
pub unsafe fn style(&self) -> CPAlertActionStyle;
#[cfg(feature = "block2")]
/// # Safety
///
/// The returned block's argument must be a valid pointer.
#[unsafe(method(handler))]
#[unsafe(method_family = none)]
pub unsafe fn handler(&self) -> CPAlertActionHandler;
#[cfg(feature = "objc2-ui-kit")]
#[unsafe(method(color))]
#[unsafe(method_family = none)]
pub unsafe fn color(&self) -> Option<Retained<UIColor>>;
);
}