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::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpcontact?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CPContact;
);

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

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

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

impl CPContact {
    extern_methods!(
        #[cfg(feature = "objc2-ui-kit")]
        /// Initializes a new contact to be used with
        /// `CPContactTemplate,`with a name and image
        ///
        ///
        /// Parameter `name`: The name to be displayed for this contact.
        ///
        /// Parameter `image`: An image for this contact. The maximum image size in points is CPButtonMaximumImageSize; larger images will be scaled down.
        ///
        ///
        /// Note: When providing an image, your app should provide a
        /// `UIImage`that is display-ready. If necessary for the image, provide
        /// light and dark styles by using an asset from your asset catalog, prepared with light and dark styles
        /// or by using
        /// `UIImageAsset`to combine two
        /// `UIImage`instances into a single image with
        /// both styles.
        ///
        /// UIImageAsset is used to combine multiple UIImages with different trait collections into a single UIImage.
        ///
        ///
        /// To properly size your list images, your app should consider the display scale of the car screen.
        /// See -[CPInterfaceController carTraitCollection].
        #[unsafe(method(initWithName:image:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithName_image(
            this: Allocated<Self>,
            name: &NSString,
            image: &UIImage,
        ) -> Retained<Self>;

        /// The name that will be displayed for this contact.
        #[unsafe(method(name))]
        #[unsafe(method_family = none)]
        pub unsafe fn name(&self) -> Retained<NSString>;

        /// Setter for [`name`][Self::name].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setName:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setName(&self, name: &NSString);

        #[cfg(feature = "objc2-ui-kit")]
        /// An image representing the contact.
        #[unsafe(method(image))]
        #[unsafe(method_family = none)]
        pub unsafe fn image(&self) -> Retained<UIImage>;

        #[cfg(feature = "objc2-ui-kit")]
        /// Setter for [`image`][Self::image].
        #[unsafe(method(setImage:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setImage(&self, image: &UIImage);

        #[cfg(feature = "CPButton")]
        /// Action buttons that will be displayed when this
        /// `CPContact`is displayed in a
        /// `CPContactTemplate.`
        #[unsafe(method(actions))]
        #[unsafe(method_family = none)]
        pub unsafe fn actions(&self) -> Option<Retained<NSArray<CPButton>>>;

        #[cfg(feature = "CPButton")]
        /// Setter for [`actions`][Self::actions].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setActions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setActions(&self, actions: Option<&NSArray<CPButton>>);

        /// Optional text that will be displayed in addition to the contact name
        #[unsafe(method(subtitle))]
        #[unsafe(method_family = none)]
        pub unsafe fn subtitle(&self) -> Option<Retained<NSString>>;

        /// Setter for [`subtitle`][Self::subtitle].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setSubtitle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSubtitle(&self, subtitle: Option<&NSString>);

        /// Optional text that will be displayed in addition to the contact name
        #[unsafe(method(informativeText))]
        #[unsafe(method_family = none)]
        pub unsafe fn informativeText(&self) -> Option<Retained<NSString>>;

        /// Setter for [`informativeText`][Self::informativeText].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setInformativeText:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setInformativeText(&self, informative_text: Option<&NSString>);
    );
}

/// Methods declared on superclass `NSObject`.
impl CPContact {
    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() -> Retained<Self>;
    );
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpcontactcallbutton?language=objc)
    #[unsafe(super(CPButton, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "CPButton")]
    pub struct CPContactCallButton;
);

#[cfg(feature = "CPButton")]
extern_conformance!(
    unsafe impl NSObjectProtocol for CPContactCallButton {}
);

#[cfg(feature = "CPButton")]
impl CPContactCallButton {
    extern_methods!(
        #[cfg(feature = "block2")]
        /// Create a contact button with a system-provided call image that, when tapped, calls your custom handler.
        ///
        ///
        /// Parameter `handler`: A block that will be called when the user taps this button.
        #[unsafe(method(initWithHandler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithHandler(
            this: Allocated<Self>,
            handler: Option<&block2::DynBlock<dyn Fn(NonNull<CPButton>)>>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "block2", feature = "objc2-ui-kit"))]
        #[unsafe(method(initWithImage:handler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithImage_handler(
            this: Allocated<Self>,
            image: &UIImage,
            handler: Option<&block2::DynBlock<dyn Fn(NonNull<CPButton>)>>,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `CPButton`.
#[cfg(feature = "CPButton")]
impl CPContactCallButton {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpcontactmessagebutton?language=objc)
    #[unsafe(super(CPButton, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "CPButton")]
    pub struct CPContactMessageButton;
);

#[cfg(feature = "CPButton")]
extern_conformance!(
    unsafe impl NSObjectProtocol for CPContactMessageButton {}
);

#[cfg(feature = "CPButton")]
impl CPContactMessageButton {
    extern_methods!(
        /// Create a contact button that, when tapped, launches to Siri to compose a message to this entity.
        /// When tapped, this button does NOT call a handler in your app. Instead, it will launch to Siri.
        /// To compose a message, you must provide a phone OR email for this contact.
        ///
        ///
        /// Parameter `phoneOrEmail`: A phone or email address for this contact. This will not be displayed in the button,
        /// but it is necessary for Siri to compose a message to this contact entity.
        #[unsafe(method(initWithPhoneOrEmail:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithPhoneOrEmail(
            this: Allocated<Self>,
            phone_or_email: &NSString,
        ) -> Retained<Self>;

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

/// Methods declared on superclass `CPButton`.
#[cfg(feature = "CPButton")]
impl CPContactMessageButton {
    extern_methods!(
        #[cfg(all(feature = "block2", feature = "objc2-ui-kit"))]
        /// Initialize a button for the Contact, POI, or Information templates with a custom image and a handler, called when
        /// the user taps this button.
        ///
        ///
        /// Parameter `image`: An image to be displayed in this button. The maximum image size is given by
        /// `CPButtonMaximumImageSize.`
        /// Parameter `handler`: A block that will be called when the user taps this button.
        ///
        ///
        /// Note: This class is only available in templates that support buttons with custom images, like the Contact template.
        ///
        ///
        /// When providing an image, your app should provide a
        /// `UIImage`that is display-ready. If necessary for the image, provide
        /// light and dark styles by using an asset from your asset catalog, prepared with light and dark styles
        /// or by using
        /// `UIImageAsset`to combine two
        /// `UIImage`instances into a single image with
        /// both styles.
        ///
        /// UIImageAsset is used to combine multiple UIImages with different trait collections into a single UIImage.
        #[unsafe(method(initWithImage:handler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithImage_handler(
            this: Allocated<Self>,
            image: &UIImage,
            handler: Option<&block2::DynBlock<dyn Fn(NonNull<CPButton>)>>,
        ) -> Retained<Self>;

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

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpcontactdirectionsbutton?language=objc)
    #[unsafe(super(CPButton, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "CPButton")]
    pub struct CPContactDirectionsButton;
);

#[cfg(feature = "CPButton")]
extern_conformance!(
    unsafe impl NSObjectProtocol for CPContactDirectionsButton {}
);

#[cfg(feature = "CPButton")]
impl CPContactDirectionsButton {
    extern_methods!(
        #[cfg(feature = "block2")]
        /// Create a contact button with a system-provided navigation directions image that, when tapped, calls your custom handler.
        ///
        ///
        /// Parameter `handler`: A block that will be called when the user taps this button.
        #[unsafe(method(initWithHandler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithHandler(
            this: Allocated<Self>,
            handler: Option<&block2::DynBlock<dyn Fn(NonNull<CPButton>)>>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "block2", feature = "objc2-ui-kit"))]
        #[unsafe(method(initWithImage:handler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithImage_handler(
            this: Allocated<Self>,
            image: &UIImage,
            handler: Option<&block2::DynBlock<dyn Fn(NonNull<CPButton>)>>,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `CPButton`.
#[cfg(feature = "CPButton")]
impl CPContactDirectionsButton {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}