objc2-car-play 0.3.2

Bindings to the CarPlay 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::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-ui-kit")]
use objc2_ui_kit::*;

use crate::*;

/// Reasons why your navigation alert was dismissed.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpnavigationalertdismissalcontext?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CPNavigationAlertDismissalContext(pub NSUInteger);
impl CPNavigationAlertDismissalContext {
    #[doc(alias = "CPNavigationAlertDismissalContextTimeout")]
    pub const Timeout: Self = Self(0);
    #[doc(alias = "CPNavigationAlertDismissalContextUserDismissed")]
    pub const UserDismissed: Self = Self(1);
    #[doc(alias = "CPNavigationAlertDismissalContextSystemDismissed")]
    pub const SystemDismissed: Self = Self(2);
}

unsafe impl Encode for CPNavigationAlertDismissalContext {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

/// Your
/// `CPNavigationAlert`may specify a duration for which the alert will be visible onscreen,
/// or 0 for an alert that is visible indefinitely.
///
/// For non-indefinite alerts, this is the minimum duration the alert will be visible.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpnavigationalertminimumduration?language=objc)
pub static CPNavigationAlertMinimumDuration: NSTimeInterval = 5 as _;

extern_class!(
    /// `CPNavigationAlert`is a banner alert that can display map or navigation-related information to the user.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpnavigationalert?language=objc)
    #[unsafe(super(NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CPNavigationAlert;
);

extern_conformance!(
    unsafe impl NSCoding for CPNavigationAlert {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for CPNavigationAlert {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for CPNavigationAlert {}
);

impl CPNavigationAlert {
    extern_methods!(
        #[cfg(all(feature = "CPAlertAction", feature = "CPImageSet"))]
        /// Fully specify a
        /// `CPNavigationAlert`with a title, image, primary and secondary action,
        /// and duration.
        ///
        ///
        /// Parameter `titleVariants`: An array of titles. The system will select a title that fits in the available space. The variant strings should be provided as localized, displayable content.
        ///
        ///
        /// Parameter `subtitleVariants`: An array of subtitles. The system will select a subtitle that fits in the available space. The variant strings should be provided as localized, displayable content.
        ///
        ///
        /// Parameter `imageSet`: An optional
        /// `CPImageSet`to display in this navigation alert. Animated images are not supported.
        /// If an animated image is provided, only the first image from each image set will be used.
        ///
        ///
        /// Parameter `primaryAction`: The alert must include at least one action button.
        ///
        ///
        /// Parameter `secondaryAction`: An optional secondary button to display on the trailing edge of this alert.
        ///
        ///
        /// Parameter `duration`: The duration for which this alert should be visible. Specify 0 for an alert
        /// that displays indefinitely.
        ///
        ///
        /// Returns: an initialized
        /// `CPNavigationAlert.`
        #[deprecated]
        #[unsafe(method(initWithTitleVariants:subtitleVariants:imageSet:primaryAction:secondaryAction:duration:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithTitleVariants_subtitleVariants_imageSet_primaryAction_secondaryAction_duration(
            this: Allocated<Self>,
            title_variants: &NSArray<NSString>,
            subtitle_variants: Option<&NSArray<NSString>>,
            image_set: Option<&CPImageSet>,
            primary_action: &CPAlertAction,
            secondary_action: Option<&CPAlertAction>,
            duration: NSTimeInterval,
        ) -> Retained<Self>;

        #[cfg(all(feature = "CPAlertAction", feature = "objc2-ui-kit"))]
        #[unsafe(method(initWithTitleVariants:subtitleVariants:image:primaryAction:secondaryAction:duration:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithTitleVariants_subtitleVariants_image_primaryAction_secondaryAction_duration(
            this: Allocated<Self>,
            title_variants: &NSArray<NSString>,
            subtitle_variants: Option<&NSArray<NSString>>,
            image: Option<&UIImage>,
            primary_action: &CPAlertAction,
            secondary_action: Option<&CPAlertAction>,
            duration: NSTimeInterval,
        ) -> Retained<Self>;

        /// The navigation alert may be updated with new title and subtitle variants, either
        /// after it has already been displayed on screen, or before its initial presentation on screen.
        ///
        /// Updating an alert that has been already been dismissed has no effect.
        ///
        ///
        /// Parameter `newTitleVariants`: an updated array of title variants
        ///
        /// Parameter `newSubtitleVariants`: an updated array of subtitle variants
        #[unsafe(method(updateTitleVariants:subtitleVariants:))]
        #[unsafe(method_family = none)]
        pub unsafe fn updateTitleVariants_subtitleVariants(
            &self,
            new_title_variants: &NSArray<NSString>,
            new_subtitle_variants: &NSArray<NSString>,
        );

        #[unsafe(method(titleVariants))]
        #[unsafe(method_family = none)]
        pub unsafe fn titleVariants(&self) -> Retained<NSArray<NSString>>;

        #[unsafe(method(subtitleVariants))]
        #[unsafe(method_family = none)]
        pub unsafe fn subtitleVariants(&self) -> Retained<NSArray<NSString>>;

        #[cfg(feature = "CPImageSet")]
        #[unsafe(method(imageSet))]
        #[unsafe(method_family = none)]
        pub unsafe fn imageSet(&self) -> Option<Retained<CPImageSet>>;

        #[cfg(feature = "objc2-ui-kit")]
        #[unsafe(method(image))]
        #[unsafe(method_family = none)]
        pub unsafe fn image(&self) -> Option<Retained<UIImage>>;

        #[cfg(feature = "CPAlertAction")]
        #[unsafe(method(primaryAction))]
        #[unsafe(method_family = none)]
        pub unsafe fn primaryAction(&self) -> Retained<CPAlertAction>;

        #[cfg(feature = "CPAlertAction")]
        #[unsafe(method(secondaryAction))]
        #[unsafe(method_family = none)]
        pub unsafe fn secondaryAction(&self) -> Option<Retained<CPAlertAction>>;

        #[unsafe(method(duration))]
        #[unsafe(method_family = none)]
        pub unsafe fn duration(&self) -> NSTimeInterval;
    );
}

/// Methods declared on superclass `NSObject`.
impl CPNavigationAlert {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}