objc2-messages 0.3.2

Bindings to the Messages 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-ui-kit")]
use objc2_ui_kit::*;

use crate::*;

/// Describes how the extension is presented in Messages.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/messages/msmessagesapppresentationstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MSMessagesAppPresentationStyle(pub NSUInteger);
impl MSMessagesAppPresentationStyle {
    #[doc(alias = "MSMessagesAppPresentationStyleCompact")]
    pub const Compact: Self = Self(0);
    #[doc(alias = "MSMessagesAppPresentationStyleExpanded")]
    pub const Expanded: Self = Self(1);
    #[doc(alias = "MSMessagesAppPresentationStyleTranscript")]
    pub const Transcript: Self = Self(2);
}

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

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

/// Describes the context for which the extension was launched
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/messages/msmessagesapppresentationcontext?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MSMessagesAppPresentationContext(pub NSUInteger);
impl MSMessagesAppPresentationContext {
    #[doc(alias = "MSMessagesAppPresentationContextMessages")]
    pub const Messages: Self = Self(0);
    #[doc(alias = "MSMessagesAppPresentationContextMedia")]
    pub const Media: Self = Self(1);
}

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

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

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/messages/msmessagesapptranscriptpresentation?language=objc)
    pub unsafe trait MSMessagesAppTranscriptPresentation {
        #[cfg(feature = "objc2-core-foundation")]
        /// The content size of the view controller's view fitting the constraining size.
        ///
        /// This method will only be called if the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript`.
        ///
        /// Parameter `size`: The maximum size the view will be displayed at.
        #[unsafe(method(contentSizeThatFits:))]
        #[unsafe(method_family = none)]
        unsafe fn contentSizeThatFits(&self, size: CGSize) -> CGSize;

        #[cfg(feature = "objc2-ui-kit")]
        /// Override to provide a message tint color, e.g. to match the content of the message, or your app's brand color.
        ///
        /// This color will be drawn either in a material or as a solid color, depending on transcript context. The default value is nil, which renders the plugin balloon with the system standard background color. This must be a simple RGB color - other color types such as displayP3 or pattern images are not supported. This also does not support dynamic colors. If your color needs to be dynamic, you must call `invalidateMessageTintColor` when the dynamic conditions change.
        #[unsafe(method(messageTintColor))]
        #[unsafe(method_family = none)]
        unsafe fn messageTintColor(&self) -> Option<Retained<UIColor>>;

        #[cfg(feature = "objc2-core-foundation")]
        /// The corner radius of the message when presented in the transcript. Use this value to create concentric rounded subviews inside your view. Use continuous corners (kCACornerCurveContinuous) on your view.
        ///
        /// This property varies with dynamic type size. Use trait collection registration to trigger an updated layout when dynamic type size changes. To avoid the edges of the transcript view, use `layoutMargins`. This value is only valid when `presentationStyle` is `MSMessagesAppPresentationStyleTranscript`.
        #[unsafe(method(messageCornerRadius))]
        #[unsafe(method_family = none)]
        unsafe fn messageCornerRadius(&self) -> CGFloat;

        /// Call this when `messageTintColor` changes, e.g. due to change in app state or trait collection.
        ///
        /// The message will be updated to reflect the new color. This method will only work if the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript`.
        #[unsafe(method(invalidateMessageTintColor))]
        #[unsafe(method_family = none)]
        unsafe fn invalidateMessageTintColor(&self);
    }
);

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/messages/msmessagesappviewcontroller?language=objc)
    #[unsafe(super(UIViewController, UIResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2-ui-kit")]
    pub struct MSMessagesAppViewController;
);

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

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

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

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

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

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

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

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

#[cfg(feature = "objc2-ui-kit")]
impl MSMessagesAppViewController {
    extern_methods!(
        #[cfg(feature = "MSConversation")]
        /// Current active conversation.
        #[unsafe(method(activeConversation))]
        #[unsafe(method_family = none)]
        pub unsafe fn activeConversation(&self) -> Option<Retained<MSConversation>>;

        /// Get the presentation extension's current presentation style.
        #[unsafe(method(presentationStyle))]
        #[unsafe(method_family = none)]
        pub unsafe fn presentationStyle(&self) -> MSMessagesAppPresentationStyle;

        /// The context for which the extension was launched
        #[unsafe(method(presentationContext))]
        #[unsafe(method_family = none)]
        pub unsafe fn presentationContext(&self) -> MSMessagesAppPresentationContext;

        /// Requests that Messages transition the extension to the specified presentation style.
        ///
        /// When the current `presentationStyle` is `MSMessagesAppPresentationStyleTranscript`, a new instance of `MSMessagesAppViewController` will be instantiated with the requested presentation style if needed.
        ///
        /// Parameter `presentationStyle`: The presentation style to transition to. `MSMessagesAppPresentationStyleTranscript` is not a valid presentation style to request.
        #[unsafe(method(requestPresentationStyle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn requestPresentationStyle(
            &self,
            presentation_style: MSMessagesAppPresentationStyle,
        );

        #[cfg(feature = "MSConversation")]
        /// Called when the extension is about to become active.
        ///
        /// Parameter `conversation`: The current conversation.
        #[unsafe(method(willBecomeActiveWithConversation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn willBecomeActiveWithConversation(&self, conversation: &MSConversation);

        #[cfg(feature = "MSConversation")]
        /// Called when the extension has become active.
        ///
        /// Parameter `conversation`: The current conversation.
        #[unsafe(method(didBecomeActiveWithConversation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn didBecomeActiveWithConversation(&self, conversation: &MSConversation);

        #[cfg(feature = "MSConversation")]
        /// Called when the extension will resign active.
        ///
        /// Parameter `conversation`: The current conversation.
        #[unsafe(method(willResignActiveWithConversation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn willResignActiveWithConversation(&self, conversation: &MSConversation);

        #[cfg(feature = "MSConversation")]
        /// Called when the extension has resigned active.
        ///
        /// Parameter `conversation`: The current conversation.
        #[unsafe(method(didResignActiveWithConversation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn didResignActiveWithConversation(&self, conversation: &MSConversation);
    );
}

/// Methods declared on superclass `UIViewController`.
#[cfg(feature = "objc2-ui-kit")]
impl MSMessagesAppViewController {
    extern_methods!(
        #[unsafe(method(initWithNibName:bundle:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithNibName_bundle(
            this: Allocated<Self>,
            nib_name_or_nil: Option<&NSString>,
            nib_bundle_or_nil: Option<&NSBundle>,
        ) -> 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>>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "objc2-ui-kit")]
impl MSMessagesAppViewController {
    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>;
    );
}

/// CompactOrExpandedPresentation.
#[cfg(feature = "objc2-ui-kit")]
impl MSMessagesAppViewController {
    extern_methods!(
        /// Tells Messages to dismiss the extension and present the keyboard.
        ///
        /// Calling this method does nothing when the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript`.
        #[unsafe(method(dismiss))]
        #[unsafe(method_family = none)]
        pub unsafe fn dismiss(&self);

        #[cfg(all(feature = "MSConversation", feature = "MSMessage"))]
        /// Informs the extension that a new message will be selected in the conversation.
        ///
        /// This method will not be called when the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript` or the `presentationContext` is `MSMessagesAppPresentationContextMedia`.
        ///
        /// Parameter `message`: The message selected.
        ///
        /// Parameter `conversation`: The conversation.
        #[unsafe(method(willSelectMessage:conversation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn willSelectMessage_conversation(
            &self,
            message: &MSMessage,
            conversation: &MSConversation,
        );

        #[cfg(all(feature = "MSConversation", feature = "MSMessage"))]
        /// Informs the extension that a new message has been selected in the conversation.
        ///
        /// This method will not be called when the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript` or the `presentationContext` is `MSMessagesAppPresentationContextMedia`.
        ///
        /// Parameter `message`: The message selected.
        ///
        /// Parameter `conversation`: The conversation.
        #[unsafe(method(didSelectMessage:conversation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn didSelectMessage_conversation(
            &self,
            message: &MSMessage,
            conversation: &MSConversation,
        );

        #[cfg(all(feature = "MSConversation", feature = "MSMessage"))]
        /// Informs the extension that a new message has arrived.
        ///
        /// This method will not be called when the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript` or the `presentationContext` is `MSMessagesAppPresentationContextMedia`.
        ///
        /// Parameter `message`: The message received.
        ///
        /// Parameter `conversation`: The conversation.
        #[unsafe(method(didReceiveMessage:conversation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn didReceiveMessage_conversation(
            &self,
            message: &MSMessage,
            conversation: &MSConversation,
        );

        #[cfg(all(feature = "MSConversation", feature = "MSMessage"))]
        /// Informs the extension that the message send has been triggered.
        ///
        /// This is called when a user interaction with Messages start the message send process. It does not guarantee the message will be successfully sent or delivered. This method will not be called when the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript` or the `presentationContext` is `MSMessagesAppPresentationContextMedia`.
        ///
        /// Parameter `message`: The message being sent.
        ///
        /// Parameter `conversation`: The conversation the message belongs to.
        #[unsafe(method(didStartSendingMessage:conversation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn didStartSendingMessage_conversation(
            &self,
            message: &MSMessage,
            conversation: &MSConversation,
        );

        #[cfg(all(feature = "MSConversation", feature = "MSMessage"))]
        /// Informs the extension that the user has removed the message from the input field.
        ///
        /// This method will not be called when the `presentationStyle` is MSMessagesAppPresentationStyleTranscript or the `presentationContext` is `MSMessagesAppPresentationContextMedia`.
        ///
        /// Parameter `message`: The message sent.
        ///
        /// Parameter `conversation`: The conversation.
        #[unsafe(method(didCancelSendingMessage:conversation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn didCancelSendingMessage_conversation(
            &self,
            message: &MSMessage,
            conversation: &MSConversation,
        );

        /// Called when the extension is about to transition to a new presentation style.
        ///
        /// This method will not be called when the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript`.
        ///
        /// Parameter `presentationStyle`: The new presentation style.
        #[unsafe(method(willTransitionToPresentationStyle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn willTransitionToPresentationStyle(
            &self,
            presentation_style: MSMessagesAppPresentationStyle,
        );

        /// Called when the extension finished transitioning to a presentation style.
        ///
        /// This method will not be called when the `presentationStyle` is `MSMessagesAppPresentationStyleTranscript`.
        ///
        /// Parameter `presentationStyle`: The new presentation style.
        #[unsafe(method(didTransitionToPresentationStyle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn didTransitionToPresentationStyle(
            &self,
            presentation_style: MSMessagesAppPresentationStyle,
        );
    );
}