objc2-core-location-ui 0.3.2

Bindings to the CoreLocationUI framework
Documentation
//! 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::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-quartz-core")]
#[cfg(not(target_os = "watchos"))]
use objc2_quartz_core::*;
#[cfg(feature = "objc2-ui-kit")]
use objc2_ui_kit::*;

use crate::*;

/// Constants that specify styles for the location arrow icon on the button.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corelocationui/cllocationbuttonicon?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CLLocationButtonIcon(pub NSInteger);
impl CLLocationButtonIcon {
    /// A style that doesn't display an icon.
    ///
    /// Use a different icon style if ``CLLocationButton/label`` is ``CLLocationButtonLabel/none``.
    #[doc(alias = "CLLocationButtonIconNone")]
    pub const None: Self = Self(0);
    /// A style that displays a filled arrow icon.
    #[doc(alias = "CLLocationButtonIconArrowFilled")]
    pub const ArrowFilled: Self = Self(1);
    /// A style that displays an unfilled, outline arrow icon.
    #[doc(alias = "CLLocationButtonIconArrowOutline")]
    pub const ArrowOutline: Self = Self(2);
}

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

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

/// Constants that specify the text of the button label.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corelocationui/cllocationbuttonlabel?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CLLocationButtonLabel(pub NSInteger);
impl CLLocationButtonLabel {
    /// A style that doesn’t display a text label.
    ///
    /// Use a different label style if ``CLLocationButton/icon`` is ``CLLocationButtonIcon/none``.
    #[doc(alias = "CLLocationButtonLabelNone")]
    pub const None: Self = Self(0);
    /// A button label with the text _Current Location_.
    #[doc(alias = "CLLocationButtonLabelCurrentLocation")]
    pub const CurrentLocation: Self = Self(1);
    /// A button label with the text _Send Current Location_.
    #[doc(alias = "CLLocationButtonLabelSendCurrentLocation")]
    pub const SendCurrentLocation: Self = Self(2);
    /// A button label with the text _Send My Current Location_.
    #[doc(alias = "CLLocationButtonLabelSendMyCurrentLocation")]
    pub const SendMyCurrentLocation: Self = Self(3);
    /// A button label with the text _Share Current Location_.
    #[doc(alias = "CLLocationButtonLabelShareCurrentLocation")]
    pub const ShareCurrentLocation: Self = Self(4);
    /// A button label with the text _Share My Current Location_.
    #[doc(alias = "CLLocationButtonLabelShareMyCurrentLocation")]
    pub const ShareMyCurrentLocation: Self = Self(5);
}

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

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

extern_class!(
    /// A button that grants one-time location authorization.
    ///
    /// `CLLocationButton` simplifies requesting one-time authorization to access
    /// location data. Add this button to your user interface in situations when
    /// users may want to grant temporary access to their location data each time
    /// they use a particular feature of your app.
    ///
    /// ![Screenshot of the location button with an icon that uses the filled arrow
    /// style and a label that shows Current Location.](cllocationbutton-1)
    ///
    /// The first time a user taps this button,
    /// <doc
    /// ://com.apple.documentation/documentation/corelocation> asks the user to
    /// confirm that they’re comfortable using this UI element when they want to
    /// grant temporary access to their location data. If the user agrees, the app
    /// receives temporary
    /// <doc
    /// ://com.apple.documentation/documentation/corelocation/clauthorizationstatus/authorizedwheninuse>
    /// authorization, like when the user chooses _Allow Once_ in response to your
    /// app’s standard location authorization request. This temporary authorization
    /// expires when your app is no longer in use.
    ///
    /// After the user agrees to using `CLLocationButton`, the button becomes
    /// approved to request future authorizations without displaying an additional
    /// alert to the user. The next time the user taps it, this button simply grants
    /// one-time authorization without requiring confirmation.
    ///
    /// After you receive this temporary authorization, fetch the user's location
    /// using the
    /// <doc
    /// ://com.apple.documentation/documentation/corelocation> API and
    /// perform any app-specific tasks related to that location data. Connect the
    /// button to initiate the tasks you want to perform after getting authorization
    /// by adding a target and action to the button. Keep in mind that this action
    /// activates every time the user taps this button, regardless of whether the
    /// app already has location authorization.
    ///
    /// Create a `CLLocationButton` in Interface Builder or in code, like this:
    ///
    /// ```swift
    /// let locationButton = CLLocationButton()
    /// locationButton.icon = .arrowFilled
    /// locationButton.label = .currentLocation
    /// locationButton.cornerRadius = 25.0
    /// locationButton.addTarget(self, action: #selector(userPressedLocationButton), for: .touchUpInside)
    /// ```
    ///
    /// - Important: When a user taps the button, it only provides one-time
    /// authorization to fetch location data — not the location data itself. For
    /// more details about fetching location data, see
    /// <doc
    /// ://com.apple.documentation/documentation/corelocation/configuring_your_app_to_use_location_services>.
    ///
    /// Configure the button's content by specifying its ``CLLocationButton/icon``
    /// and ``CLLocationButton/label`` styles. Customize its appearance using the
    /// ``CLLocationButton/cornerRadius`` and ``CLLocationButton/fontSize``
    /// properties, or the standard view appearance properties
    /// <doc
    /// ://com.apple.documentation/documentation/uikit/uiview/1622591-backgroundcolor>
    /// and
    /// <doc
    /// ://com.apple.documentation/documentation/uikit/uiview/1622467-tintcolor>.
    /// For design guidance, see [Human Interface
    /// Guidelines](https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/accessing-user-data/).
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corelocationui/cllocationbutton?language=objc)
    #[unsafe(super(UIControl, UIView, UIResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2-ui-kit")]
    pub struct CLLocationButton;
);

#[cfg(all(feature = "objc2-quartz-core", feature = "objc2-ui-kit"))]
#[cfg(not(target_os = "watchos"))]
extern_conformance!(
    unsafe impl CALayerDelegate for CLLocationButton {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl NSCoding for CLLocationButton {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl NSObjectProtocol for CLLocationButton {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl NSSecureCoding for CLLocationButton {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl UIAppearance for CLLocationButton {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl UIAppearanceContainer for CLLocationButton {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl UICoordinateSpace for CLLocationButton {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl UIDynamicItem for CLLocationButton {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl UIFocusEnvironment for CLLocationButton {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl UIFocusItem for CLLocationButton {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl UIFocusItemContainer for CLLocationButton {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl UIResponderStandardEditActions for CLLocationButton {}
);

#[cfg(feature = "objc2-ui-kit")]
extern_conformance!(
    unsafe impl UITraitEnvironment for CLLocationButton {}
);

#[cfg(feature = "objc2-ui-kit")]
impl CLLocationButton {
    extern_methods!(
        /// The style of the location arrow icon on the button.
        #[unsafe(method(icon))]
        #[unsafe(method_family = none)]
        pub unsafe fn icon(&self) -> CLLocationButtonIcon;

        /// Setter for [`icon`][Self::icon].
        #[unsafe(method(setIcon:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setIcon(&self, icon: CLLocationButtonIcon);

        /// The text of the button label.
        #[unsafe(method(label))]
        #[unsafe(method_family = none)]
        pub unsafe fn label(&self) -> CLLocationButtonLabel;

        /// Setter for [`label`][Self::label].
        #[unsafe(method(setLabel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLabel(&self, label: CLLocationButtonLabel);

        #[cfg(feature = "objc2-core-foundation")]
        /// The font size of the text on the button.
        #[unsafe(method(fontSize))]
        #[unsafe(method_family = none)]
        pub unsafe fn fontSize(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`fontSize`][Self::fontSize].
        #[unsafe(method(setFontSize:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFontSize(&self, font_size: CGFloat);

        #[cfg(feature = "objc2-core-foundation")]
        /// The corner radius of the button.
        #[unsafe(method(cornerRadius))]
        #[unsafe(method_family = none)]
        pub unsafe fn cornerRadius(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`cornerRadius`][Self::cornerRadius].
        #[unsafe(method(setCornerRadius:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setCornerRadius(&self, corner_radius: CGFloat);
    );
}

/// Methods declared on superclass `UIControl`.
#[cfg(feature = "objc2-ui-kit")]
impl CLLocationButton {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(initWithFrame:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;

        #[cfg(feature = "objc2-core-foundation")]
        /// 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.
        #[unsafe(method(initWithFrame:primaryAction:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFrame_primaryAction(
            this: Allocated<Self>,
            frame: CGRect,
            primary_action: Option<&UIAction>,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `UIView`.
#[cfg(feature = "objc2-ui-kit")]
impl CLLocationButton {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "objc2-ui-kit")]
impl CLLocationButton {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}