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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIDeviceBatteryState(pub NSInteger);
impl UIDeviceBatteryState {
    #[doc(alias = "UIDeviceBatteryStateUnknown")]
    pub const Unknown: Self = Self(0);
    #[doc(alias = "UIDeviceBatteryStateUnplugged")]
    pub const Unplugged: Self = Self(1);
    #[doc(alias = "UIDeviceBatteryStateCharging")]
    pub const Charging: Self = Self(2);
    #[doc(alias = "UIDeviceBatteryStateFull")]
    pub const Full: Self = Self(3);
}

unsafe impl Encode for UIDeviceBatteryState {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UIDeviceBatteryState {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIUserInterfaceIdiom(pub NSInteger);
impl UIUserInterfaceIdiom {
    #[doc(alias = "UIUserInterfaceIdiomUnspecified")]
    pub const Unspecified: Self = Self(-1);
    #[doc(alias = "UIUserInterfaceIdiomPhone")]
    pub const Phone: Self = Self(0);
    #[doc(alias = "UIUserInterfaceIdiomPad")]
    pub const Pad: Self = Self(1);
    #[doc(alias = "UIUserInterfaceIdiomTV")]
    pub const TV: Self = Self(2);
    #[doc(alias = "UIUserInterfaceIdiomCarPlay")]
    pub const CarPlay: Self = Self(3);
    #[doc(alias = "UIUserInterfaceIdiomMac")]
    pub const Mac: Self = Self(5);
    #[doc(alias = "UIUserInterfaceIdiomVision")]
    pub const Vision: Self = Self(6);
}

unsafe impl Encode for UIUserInterfaceIdiom {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UIUserInterfaceIdiom {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct UIDevice;

    unsafe impl ClassType for UIDevice {
        type Super = NSObject;
        type Mutability = MainThreadOnly;
    }
);

unsafe impl NSObjectProtocol for UIDevice {}

extern_methods!(
    unsafe impl UIDevice {
        #[method_id(@__retain_semantics Other currentDevice)]
        pub fn currentDevice(mtm: MainThreadMarker) -> Retained<UIDevice>;

        #[method_id(@__retain_semantics Other name)]
        pub unsafe fn name(&self) -> Retained<NSString>;

        #[method_id(@__retain_semantics Other model)]
        pub unsafe fn model(&self) -> Retained<NSString>;

        #[method_id(@__retain_semantics Other localizedModel)]
        pub unsafe fn localizedModel(&self) -> Retained<NSString>;

        #[method_id(@__retain_semantics Other systemName)]
        pub unsafe fn systemName(&self) -> Retained<NSString>;

        #[method_id(@__retain_semantics Other systemVersion)]
        pub unsafe fn systemVersion(&self) -> Retained<NSString>;

        #[cfg(feature = "UIOrientation")]
        #[method(orientation)]
        pub unsafe fn orientation(&self) -> UIDeviceOrientation;

        #[method_id(@__retain_semantics Other identifierForVendor)]
        pub unsafe fn identifierForVendor(&self) -> Option<Retained<NSUUID>>;

        #[method(isGeneratingDeviceOrientationNotifications)]
        pub unsafe fn isGeneratingDeviceOrientationNotifications(&self) -> bool;

        #[method(beginGeneratingDeviceOrientationNotifications)]
        pub unsafe fn beginGeneratingDeviceOrientationNotifications(&self);

        #[method(endGeneratingDeviceOrientationNotifications)]
        pub unsafe fn endGeneratingDeviceOrientationNotifications(&self);

        #[method(isBatteryMonitoringEnabled)]
        pub unsafe fn isBatteryMonitoringEnabled(&self) -> bool;

        #[method(setBatteryMonitoringEnabled:)]
        pub unsafe fn setBatteryMonitoringEnabled(&self, battery_monitoring_enabled: bool);

        #[method(batteryState)]
        pub unsafe fn batteryState(&self) -> UIDeviceBatteryState;

        #[method(batteryLevel)]
        pub unsafe fn batteryLevel(&self) -> c_float;

        #[method(isProximityMonitoringEnabled)]
        pub unsafe fn isProximityMonitoringEnabled(&self) -> bool;

        #[method(setProximityMonitoringEnabled:)]
        pub unsafe fn setProximityMonitoringEnabled(&self, proximity_monitoring_enabled: bool);

        #[method(proximityState)]
        pub unsafe fn proximityState(&self) -> bool;

        #[method(isMultitaskingSupported)]
        pub unsafe fn isMultitaskingSupported(&self) -> bool;

        #[method(userInterfaceIdiom)]
        pub fn userInterfaceIdiom(&self) -> UIUserInterfaceIdiom;

        #[method(playInputClick)]
        pub unsafe fn playInputClick(&self);
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl UIDevice {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    }
);

extern_protocol!(
    pub unsafe trait UIInputViewAudioFeedback: NSObjectProtocol + IsMainThreadOnly {
        #[optional]
        #[method(enableInputClicksWhenVisible)]
        unsafe fn enableInputClicksWhenVisible(&self) -> bool;
    }

    unsafe impl ProtocolType for dyn UIInputViewAudioFeedback {}
);

// TODO: pub fn UI_USER_INTERFACE_IDIOM() -> UIUserInterfaceIdiom;

extern "C" {
    pub static UIDeviceOrientationDidChangeNotification: &'static NSNotificationName;
}

extern "C" {
    pub static UIDeviceBatteryStateDidChangeNotification: &'static NSNotificationName;
}

extern "C" {
    pub static UIDeviceBatteryLevelDidChangeNotification: &'static NSNotificationName;
}

extern "C" {
    pub static UIDeviceProximityStateDidChangeNotification: &'static NSNotificationName;
}