objc2_core_location_ui/generated/
CLLocationButton.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::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9#[cfg(feature = "objc2-quartz-core")]
10#[cfg(not(target_os = "watchos"))]
11use objc2_quartz_core::*;
12#[cfg(feature = "objc2-ui-kit")]
13use objc2_ui_kit::*;
14
15use crate::*;
16
17/// Constants that specify styles for the location arrow icon on the button.
18///
19/// See also [Apple's documentation](https://developer.apple.com/documentation/corelocationui/cllocationbuttonicon?language=objc)
20// NS_ENUM
21#[repr(transparent)]
22#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
23pub struct CLLocationButtonIcon(pub NSInteger);
24impl CLLocationButtonIcon {
25    /// A style that doesn't display an icon.
26    ///
27    /// Use a different icon style if ``CLLocationButton/label`` is ``CLLocationButtonLabel/none``.
28    #[doc(alias = "CLLocationButtonIconNone")]
29    pub const None: Self = Self(0);
30    /// A style that displays a filled arrow icon.
31    #[doc(alias = "CLLocationButtonIconArrowFilled")]
32    pub const ArrowFilled: Self = Self(1);
33    /// A style that displays an unfilled, outline arrow icon.
34    #[doc(alias = "CLLocationButtonIconArrowOutline")]
35    pub const ArrowOutline: Self = Self(2);
36}
37
38unsafe impl Encode for CLLocationButtonIcon {
39    const ENCODING: Encoding = NSInteger::ENCODING;
40}
41
42unsafe impl RefEncode for CLLocationButtonIcon {
43    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
44}
45
46/// Constants that specify the text of the button label.
47///
48/// See also [Apple's documentation](https://developer.apple.com/documentation/corelocationui/cllocationbuttonlabel?language=objc)
49// NS_ENUM
50#[repr(transparent)]
51#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
52pub struct CLLocationButtonLabel(pub NSInteger);
53impl CLLocationButtonLabel {
54    /// A style that doesn’t display a text label.
55    ///
56    /// Use a different label style if ``CLLocationButton/icon`` is ``CLLocationButtonIcon/none``.
57    #[doc(alias = "CLLocationButtonLabelNone")]
58    pub const None: Self = Self(0);
59    /// A button label with the text _Current Location_.
60    #[doc(alias = "CLLocationButtonLabelCurrentLocation")]
61    pub const CurrentLocation: Self = Self(1);
62    /// A button label with the text _Send Current Location_.
63    #[doc(alias = "CLLocationButtonLabelSendCurrentLocation")]
64    pub const SendCurrentLocation: Self = Self(2);
65    /// A button label with the text _Send My Current Location_.
66    #[doc(alias = "CLLocationButtonLabelSendMyCurrentLocation")]
67    pub const SendMyCurrentLocation: Self = Self(3);
68    /// A button label with the text _Share Current Location_.
69    #[doc(alias = "CLLocationButtonLabelShareCurrentLocation")]
70    pub const ShareCurrentLocation: Self = Self(4);
71    /// A button label with the text _Share My Current Location_.
72    #[doc(alias = "CLLocationButtonLabelShareMyCurrentLocation")]
73    pub const ShareMyCurrentLocation: Self = Self(5);
74}
75
76unsafe impl Encode for CLLocationButtonLabel {
77    const ENCODING: Encoding = NSInteger::ENCODING;
78}
79
80unsafe impl RefEncode for CLLocationButtonLabel {
81    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
82}
83
84extern_class!(
85    /// A button that grants one-time location authorization.
86    ///
87    /// `CLLocationButton` simplifies requesting one-time authorization to access
88    /// location data. Add this button to your user interface in situations when
89    /// users may want to grant temporary access to their location data each time
90    /// they use a particular feature of your app.
91    ///
92    /// ![Screenshot of the location button with an icon that uses the filled arrow
93    /// style and a label that shows Current Location.](cllocationbutton-1)
94    ///
95    /// The first time a user taps this button,
96    /// <doc
97    /// ://com.apple.documentation/documentation/corelocation> asks the user to
98    /// confirm that they’re comfortable using this UI element when they want to
99    /// grant temporary access to their location data. If the user agrees, the app
100    /// receives temporary
101    /// <doc
102    /// ://com.apple.documentation/documentation/corelocation/clauthorizationstatus/authorizedwheninuse>
103    /// authorization, like when the user chooses _Allow Once_ in response to your
104    /// app’s standard location authorization request. This temporary authorization
105    /// expires when your app is no longer in use.
106    ///
107    /// After the user agrees to using `CLLocationButton`, the button becomes
108    /// approved to request future authorizations without displaying an additional
109    /// alert to the user. The next time the user taps it, this button simply grants
110    /// one-time authorization without requiring confirmation.
111    ///
112    /// After you receive this temporary authorization, fetch the user's location
113    /// using the
114    /// <doc
115    /// ://com.apple.documentation/documentation/corelocation> API and
116    /// perform any app-specific tasks related to that location data. Connect the
117    /// button to initiate the tasks you want to perform after getting authorization
118    /// by adding a target and action to the button. Keep in mind that this action
119    /// activates every time the user taps this button, regardless of whether the
120    /// app already has location authorization.
121    ///
122    /// Create a `CLLocationButton` in Interface Builder or in code, like this:
123    ///
124    /// ```swift
125    /// let locationButton = CLLocationButton()
126    /// locationButton.icon = .arrowFilled
127    /// locationButton.label = .currentLocation
128    /// locationButton.cornerRadius = 25.0
129    /// locationButton.addTarget(self, action: #selector(userPressedLocationButton), for: .touchUpInside)
130    /// ```
131    ///
132    /// - Important: When a user taps the button, it only provides one-time
133    /// authorization to fetch location data — not the location data itself. For
134    /// more details about fetching location data, see
135    /// <doc
136    /// ://com.apple.documentation/documentation/corelocation/configuring_your_app_to_use_location_services>.
137    ///
138    /// Configure the button's content by specifying its ``CLLocationButton/icon``
139    /// and ``CLLocationButton/label`` styles. Customize its appearance using the
140    /// ``CLLocationButton/cornerRadius`` and ``CLLocationButton/fontSize``
141    /// properties, or the standard view appearance properties
142    /// <doc
143    /// ://com.apple.documentation/documentation/uikit/uiview/1622591-backgroundcolor>
144    /// and
145    /// <doc
146    /// ://com.apple.documentation/documentation/uikit/uiview/1622467-tintcolor>.
147    /// For design guidance, see [Human Interface
148    /// Guidelines](https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/accessing-user-data/).
149    ///
150    /// See also [Apple's documentation](https://developer.apple.com/documentation/corelocationui/cllocationbutton?language=objc)
151    #[unsafe(super(UIControl, UIView, UIResponder, NSObject))]
152    #[derive(Debug, PartialEq, Eq, Hash)]
153    #[cfg(feature = "objc2-ui-kit")]
154    pub struct CLLocationButton;
155);
156
157#[cfg(all(feature = "objc2-quartz-core", feature = "objc2-ui-kit"))]
158#[cfg(not(target_os = "watchos"))]
159extern_conformance!(
160    unsafe impl CALayerDelegate for CLLocationButton {}
161);
162
163#[cfg(feature = "objc2-ui-kit")]
164extern_conformance!(
165    unsafe impl NSCoding for CLLocationButton {}
166);
167
168#[cfg(feature = "objc2-ui-kit")]
169extern_conformance!(
170    unsafe impl NSObjectProtocol for CLLocationButton {}
171);
172
173#[cfg(feature = "objc2-ui-kit")]
174extern_conformance!(
175    unsafe impl NSSecureCoding for CLLocationButton {}
176);
177
178#[cfg(feature = "objc2-ui-kit")]
179extern_conformance!(
180    unsafe impl UIAppearance for CLLocationButton {}
181);
182
183#[cfg(feature = "objc2-ui-kit")]
184extern_conformance!(
185    unsafe impl UIAppearanceContainer for CLLocationButton {}
186);
187
188#[cfg(feature = "objc2-ui-kit")]
189extern_conformance!(
190    unsafe impl UICoordinateSpace for CLLocationButton {}
191);
192
193#[cfg(feature = "objc2-ui-kit")]
194extern_conformance!(
195    unsafe impl UIDynamicItem for CLLocationButton {}
196);
197
198#[cfg(feature = "objc2-ui-kit")]
199extern_conformance!(
200    unsafe impl UIFocusEnvironment for CLLocationButton {}
201);
202
203#[cfg(feature = "objc2-ui-kit")]
204extern_conformance!(
205    unsafe impl UIFocusItem for CLLocationButton {}
206);
207
208#[cfg(feature = "objc2-ui-kit")]
209extern_conformance!(
210    unsafe impl UIFocusItemContainer for CLLocationButton {}
211);
212
213#[cfg(feature = "objc2-ui-kit")]
214extern_conformance!(
215    unsafe impl UIResponderStandardEditActions for CLLocationButton {}
216);
217
218#[cfg(feature = "objc2-ui-kit")]
219extern_conformance!(
220    unsafe impl UITraitEnvironment for CLLocationButton {}
221);
222
223#[cfg(feature = "objc2-ui-kit")]
224impl CLLocationButton {
225    extern_methods!(
226        /// The style of the location arrow icon on the button.
227        #[unsafe(method(icon))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn icon(&self) -> CLLocationButtonIcon;
230
231        /// Setter for [`icon`][Self::icon].
232        #[unsafe(method(setIcon:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn setIcon(&self, icon: CLLocationButtonIcon);
235
236        /// The text of the button label.
237        #[unsafe(method(label))]
238        #[unsafe(method_family = none)]
239        pub unsafe fn label(&self) -> CLLocationButtonLabel;
240
241        /// Setter for [`label`][Self::label].
242        #[unsafe(method(setLabel:))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn setLabel(&self, label: CLLocationButtonLabel);
245
246        #[cfg(feature = "objc2-core-foundation")]
247        /// The font size of the text on the button.
248        #[unsafe(method(fontSize))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn fontSize(&self) -> CGFloat;
251
252        #[cfg(feature = "objc2-core-foundation")]
253        /// Setter for [`fontSize`][Self::fontSize].
254        #[unsafe(method(setFontSize:))]
255        #[unsafe(method_family = none)]
256        pub unsafe fn setFontSize(&self, font_size: CGFloat);
257
258        #[cfg(feature = "objc2-core-foundation")]
259        /// The corner radius of the button.
260        #[unsafe(method(cornerRadius))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn cornerRadius(&self) -> CGFloat;
263
264        #[cfg(feature = "objc2-core-foundation")]
265        /// Setter for [`cornerRadius`][Self::cornerRadius].
266        #[unsafe(method(setCornerRadius:))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn setCornerRadius(&self, corner_radius: CGFloat);
269    );
270}
271
272/// Methods declared on superclass `UIControl`.
273#[cfg(feature = "objc2-ui-kit")]
274impl CLLocationButton {
275    extern_methods!(
276        #[cfg(feature = "objc2-core-foundation")]
277        #[unsafe(method(initWithFrame:))]
278        #[unsafe(method_family = init)]
279        pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
280
281        /// # Safety
282        ///
283        /// `coder` possibly has further requirements.
284        #[unsafe(method(initWithCoder:))]
285        #[unsafe(method_family = init)]
286        pub unsafe fn initWithCoder(
287            this: Allocated<Self>,
288            coder: &NSCoder,
289        ) -> Option<Retained<Self>>;
290
291        #[cfg(feature = "objc2-core-foundation")]
292        /// Initializes the control and adds primaryAction for the UIControlEventPrimaryActionTriggered control event. Subclasses of UIControl may alter or add behaviors around the usage of primaryAction, see subclass documentation of this initializer for additional information.
293        #[unsafe(method(initWithFrame:primaryAction:))]
294        #[unsafe(method_family = init)]
295        pub unsafe fn initWithFrame_primaryAction(
296            this: Allocated<Self>,
297            frame: CGRect,
298            primary_action: Option<&UIAction>,
299        ) -> Retained<Self>;
300    );
301}
302
303/// Methods declared on superclass `UIView`.
304#[cfg(feature = "objc2-ui-kit")]
305impl CLLocationButton {
306    extern_methods!(
307        #[unsafe(method(init))]
308        #[unsafe(method_family = init)]
309        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
310    );
311}
312
313/// Methods declared on superclass `NSObject`.
314#[cfg(feature = "objc2-ui-kit")]
315impl CLLocationButton {
316    extern_methods!(
317        #[unsafe(method(new))]
318        #[unsafe(method_family = new)]
319        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
320    );
321}