objc2_ui_kit/generated/
UIDevice.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct UIDeviceBatteryState(pub NSInteger);
15impl UIDeviceBatteryState {
16 #[doc(alias = "UIDeviceBatteryStateUnknown")]
17 pub const Unknown: Self = Self(0);
18 #[doc(alias = "UIDeviceBatteryStateUnplugged")]
19 pub const Unplugged: Self = Self(1);
20 #[doc(alias = "UIDeviceBatteryStateCharging")]
21 pub const Charging: Self = Self(2);
22 #[doc(alias = "UIDeviceBatteryStateFull")]
23 pub const Full: Self = Self(3);
24}
25
26unsafe impl Encode for UIDeviceBatteryState {
27 const ENCODING: Encoding = NSInteger::ENCODING;
28}
29
30unsafe impl RefEncode for UIDeviceBatteryState {
31 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
32}
33
34#[repr(transparent)]
37#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
38pub struct UIUserInterfaceIdiom(pub NSInteger);
39impl UIUserInterfaceIdiom {
40 #[doc(alias = "UIUserInterfaceIdiomUnspecified")]
41 pub const Unspecified: Self = Self(-1);
42 #[doc(alias = "UIUserInterfaceIdiomPhone")]
43 pub const Phone: Self = Self(0);
44 #[doc(alias = "UIUserInterfaceIdiomPad")]
45 pub const Pad: Self = Self(1);
46 #[doc(alias = "UIUserInterfaceIdiomTV")]
47 pub const TV: Self = Self(2);
48 #[doc(alias = "UIUserInterfaceIdiomCarPlay")]
49 pub const CarPlay: Self = Self(3);
50 #[doc(alias = "UIUserInterfaceIdiomMac")]
51 pub const Mac: Self = Self(5);
52 #[doc(alias = "UIUserInterfaceIdiomVision")]
53 pub const Vision: Self = Self(6);
54}
55
56unsafe impl Encode for UIUserInterfaceIdiom {
57 const ENCODING: Encoding = NSInteger::ENCODING;
58}
59
60unsafe impl RefEncode for UIUserInterfaceIdiom {
61 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64extern_class!(
65 #[unsafe(super(NSObject))]
67 #[thread_kind = MainThreadOnly]
68 #[derive(Debug, PartialEq, Eq, Hash)]
69 pub struct UIDevice;
70);
71
72unsafe impl NSObjectProtocol for UIDevice {}
73
74impl UIDevice {
75 extern_methods!(
76 #[unsafe(method(currentDevice))]
77 #[unsafe(method_family = none)]
78 pub fn currentDevice(mtm: MainThreadMarker) -> Retained<UIDevice>;
79
80 #[unsafe(method(name))]
81 #[unsafe(method_family = none)]
82 pub unsafe fn name(&self) -> Retained<NSString>;
83
84 #[unsafe(method(model))]
85 #[unsafe(method_family = none)]
86 pub unsafe fn model(&self) -> Retained<NSString>;
87
88 #[unsafe(method(localizedModel))]
89 #[unsafe(method_family = none)]
90 pub unsafe fn localizedModel(&self) -> Retained<NSString>;
91
92 #[unsafe(method(systemName))]
93 #[unsafe(method_family = none)]
94 pub unsafe fn systemName(&self) -> Retained<NSString>;
95
96 #[unsafe(method(systemVersion))]
97 #[unsafe(method_family = none)]
98 pub unsafe fn systemVersion(&self) -> Retained<NSString>;
99
100 #[cfg(feature = "UIOrientation")]
101 #[unsafe(method(orientation))]
102 #[unsafe(method_family = none)]
103 pub unsafe fn orientation(&self) -> UIDeviceOrientation;
104
105 #[unsafe(method(identifierForVendor))]
106 #[unsafe(method_family = none)]
107 pub unsafe fn identifierForVendor(&self) -> Option<Retained<NSUUID>>;
108
109 #[unsafe(method(isGeneratingDeviceOrientationNotifications))]
110 #[unsafe(method_family = none)]
111 pub unsafe fn isGeneratingDeviceOrientationNotifications(&self) -> bool;
112
113 #[unsafe(method(beginGeneratingDeviceOrientationNotifications))]
114 #[unsafe(method_family = none)]
115 pub unsafe fn beginGeneratingDeviceOrientationNotifications(&self);
116
117 #[unsafe(method(endGeneratingDeviceOrientationNotifications))]
118 #[unsafe(method_family = none)]
119 pub unsafe fn endGeneratingDeviceOrientationNotifications(&self);
120
121 #[unsafe(method(isBatteryMonitoringEnabled))]
122 #[unsafe(method_family = none)]
123 pub unsafe fn isBatteryMonitoringEnabled(&self) -> bool;
124
125 #[unsafe(method(setBatteryMonitoringEnabled:))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn setBatteryMonitoringEnabled(&self, battery_monitoring_enabled: bool);
129
130 #[unsafe(method(batteryState))]
131 #[unsafe(method_family = none)]
132 pub unsafe fn batteryState(&self) -> UIDeviceBatteryState;
133
134 #[unsafe(method(batteryLevel))]
135 #[unsafe(method_family = none)]
136 pub unsafe fn batteryLevel(&self) -> c_float;
137
138 #[unsafe(method(isProximityMonitoringEnabled))]
139 #[unsafe(method_family = none)]
140 pub unsafe fn isProximityMonitoringEnabled(&self) -> bool;
141
142 #[unsafe(method(setProximityMonitoringEnabled:))]
144 #[unsafe(method_family = none)]
145 pub unsafe fn setProximityMonitoringEnabled(&self, proximity_monitoring_enabled: bool);
146
147 #[unsafe(method(proximityState))]
148 #[unsafe(method_family = none)]
149 pub unsafe fn proximityState(&self) -> bool;
150
151 #[unsafe(method(isMultitaskingSupported))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn isMultitaskingSupported(&self) -> bool;
154
155 #[unsafe(method(userInterfaceIdiom))]
156 #[unsafe(method_family = none)]
157 pub fn userInterfaceIdiom(&self) -> UIUserInterfaceIdiom;
158
159 #[unsafe(method(playInputClick))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn playInputClick(&self);
162 );
163}
164
165impl UIDevice {
167 extern_methods!(
168 #[unsafe(method(init))]
169 #[unsafe(method_family = init)]
170 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
171
172 #[unsafe(method(new))]
173 #[unsafe(method_family = new)]
174 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
175 );
176}
177
178extern_protocol!(
179 pub unsafe trait UIInputViewAudioFeedback: NSObjectProtocol + MainThreadOnly {
181 #[optional]
182 #[unsafe(method(enableInputClicksWhenVisible))]
183 #[unsafe(method_family = none)]
184 unsafe fn enableInputClicksWhenVisible(&self) -> bool;
185 }
186);
187
188extern "C" {
191 pub static UIDeviceOrientationDidChangeNotification: &'static NSNotificationName;
193}
194
195extern "C" {
196 pub static UIDeviceBatteryStateDidChangeNotification: &'static NSNotificationName;
198}
199
200extern "C" {
201 pub static UIDeviceBatteryLevelDidChangeNotification: &'static NSNotificationName;
203}
204
205extern "C" {
206 pub static UIDeviceProximityStateDidChangeNotification: &'static NSNotificationName;
208}