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
72extern_conformance!(
73 unsafe impl NSObjectProtocol for UIDevice {}
74);
75
76impl UIDevice {
77 extern_methods!(
78 #[unsafe(method(currentDevice))]
79 #[unsafe(method_family = none)]
80 pub fn currentDevice(mtm: MainThreadMarker) -> Retained<UIDevice>;
81
82 #[unsafe(method(name))]
83 #[unsafe(method_family = none)]
84 pub unsafe fn name(&self) -> Retained<NSString>;
85
86 #[unsafe(method(model))]
87 #[unsafe(method_family = none)]
88 pub unsafe fn model(&self) -> Retained<NSString>;
89
90 #[unsafe(method(localizedModel))]
91 #[unsafe(method_family = none)]
92 pub unsafe fn localizedModel(&self) -> Retained<NSString>;
93
94 #[unsafe(method(systemName))]
95 #[unsafe(method_family = none)]
96 pub unsafe fn systemName(&self) -> Retained<NSString>;
97
98 #[unsafe(method(systemVersion))]
99 #[unsafe(method_family = none)]
100 pub unsafe fn systemVersion(&self) -> Retained<NSString>;
101
102 #[cfg(feature = "UIOrientation")]
103 #[unsafe(method(orientation))]
104 #[unsafe(method_family = none)]
105 pub unsafe fn orientation(&self) -> UIDeviceOrientation;
106
107 #[unsafe(method(identifierForVendor))]
108 #[unsafe(method_family = none)]
109 pub unsafe fn identifierForVendor(&self) -> Option<Retained<NSUUID>>;
110
111 #[unsafe(method(isGeneratingDeviceOrientationNotifications))]
112 #[unsafe(method_family = none)]
113 pub unsafe fn isGeneratingDeviceOrientationNotifications(&self) -> bool;
114
115 #[unsafe(method(beginGeneratingDeviceOrientationNotifications))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn beginGeneratingDeviceOrientationNotifications(&self);
118
119 #[unsafe(method(endGeneratingDeviceOrientationNotifications))]
120 #[unsafe(method_family = none)]
121 pub unsafe fn endGeneratingDeviceOrientationNotifications(&self);
122
123 #[unsafe(method(isBatteryMonitoringEnabled))]
124 #[unsafe(method_family = none)]
125 pub unsafe fn isBatteryMonitoringEnabled(&self) -> bool;
126
127 #[unsafe(method(setBatteryMonitoringEnabled:))]
129 #[unsafe(method_family = none)]
130 pub unsafe fn setBatteryMonitoringEnabled(&self, battery_monitoring_enabled: bool);
131
132 #[unsafe(method(batteryState))]
133 #[unsafe(method_family = none)]
134 pub unsafe fn batteryState(&self) -> UIDeviceBatteryState;
135
136 #[unsafe(method(batteryLevel))]
137 #[unsafe(method_family = none)]
138 pub unsafe fn batteryLevel(&self) -> c_float;
139
140 #[unsafe(method(isProximityMonitoringEnabled))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn isProximityMonitoringEnabled(&self) -> bool;
143
144 #[unsafe(method(setProximityMonitoringEnabled:))]
146 #[unsafe(method_family = none)]
147 pub unsafe fn setProximityMonitoringEnabled(&self, proximity_monitoring_enabled: bool);
148
149 #[unsafe(method(proximityState))]
150 #[unsafe(method_family = none)]
151 pub unsafe fn proximityState(&self) -> bool;
152
153 #[unsafe(method(isMultitaskingSupported))]
154 #[unsafe(method_family = none)]
155 pub unsafe fn isMultitaskingSupported(&self) -> bool;
156
157 #[unsafe(method(userInterfaceIdiom))]
158 #[unsafe(method_family = none)]
159 pub fn userInterfaceIdiom(&self) -> UIUserInterfaceIdiom;
160
161 #[unsafe(method(playInputClick))]
162 #[unsafe(method_family = none)]
163 pub unsafe fn playInputClick(&self);
164 );
165}
166
167impl UIDevice {
169 extern_methods!(
170 #[unsafe(method(init))]
171 #[unsafe(method_family = init)]
172 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
173
174 #[unsafe(method(new))]
175 #[unsafe(method_family = new)]
176 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
177 );
178}
179
180extern_protocol!(
181 pub unsafe trait UIInputViewAudioFeedback: NSObjectProtocol + MainThreadOnly {
183 #[optional]
184 #[unsafe(method(enableInputClicksWhenVisible))]
185 #[unsafe(method_family = none)]
186 unsafe fn enableInputClicksWhenVisible(&self) -> bool;
187 }
188);
189
190impl UIUserInterfaceIdiom {
191 }
193
194extern "C" {
195 pub static UIDeviceOrientationDidChangeNotification: &'static NSNotificationName;
197}
198
199extern "C" {
200 pub static UIDeviceBatteryStateDidChangeNotification: &'static NSNotificationName;
202}
203
204extern "C" {
205 pub static UIDeviceBatteryLevelDidChangeNotification: &'static NSNotificationName;
207}
208
209extern "C" {
210 pub static UIDeviceProximityStateDidChangeNotification: &'static NSNotificationName;
212}