objc2-ui-kit 0.3.2

Bindings to the UIKit 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::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextualactionhandler?language=objc)
#[cfg(all(feature = "UIResponder", feature = "UIView", feature = "block2"))]
pub type UIContextualActionHandler = *mut block2::DynBlock<
    dyn Fn(NonNull<UIContextualAction>, NonNull<UIView>, NonNull<block2::DynBlock<dyn Fn(Bool)>>),
>;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextualactionstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIContextualActionStyle(pub NSInteger);
impl UIContextualActionStyle {
    #[doc(alias = "UIContextualActionStyleNormal")]
    pub const Normal: Self = Self(0);
    #[doc(alias = "UIContextualActionStyleDestructive")]
    pub const Destructive: Self = Self(1);
}

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

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

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

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

impl UIContextualAction {
    extern_methods!(
        #[cfg(all(feature = "UIResponder", feature = "UIView", feature = "block2"))]
        /// # Safety
        ///
        /// `handler` must be a valid pointer.
        #[unsafe(method(contextualActionWithStyle:title:handler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn contextualActionWithStyle_title_handler(
            style: UIContextualActionStyle,
            title: Option<&NSString>,
            handler: UIContextualActionHandler,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        #[unsafe(method(style))]
        #[unsafe(method_family = none)]
        pub fn style(&self) -> UIContextualActionStyle;

        #[cfg(all(feature = "UIResponder", feature = "UIView", feature = "block2"))]
        /// # Safety
        ///
        /// - The returned block's argument 1 must be a valid pointer.
        /// - The returned block's argument 2 must be a valid pointer.
        /// - The returned block's argument 3 must be a valid pointer.
        #[unsafe(method(handler))]
        #[unsafe(method_family = none)]
        pub unsafe fn handler(&self) -> UIContextualActionHandler;

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

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

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

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

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

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

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

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