//! 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/uialertactionstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIAlertActionStyle(pub NSInteger);
impl UIAlertActionStyle {
    #[doc(alias = "UIAlertActionStyleDefault")]
    pub const Default: Self = Self(0);
    #[doc(alias = "UIAlertActionStyleCancel")]
    pub const Cancel: Self = Self(1);
    #[doc(alias = "UIAlertActionStyleDestructive")]
    pub const Destructive: Self = Self(2);
}

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

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

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

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

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

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

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

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

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

extern_conformance!(
    unsafe impl NSCopying for UIAlertAction {}
);

unsafe impl CopyingHelper for UIAlertAction {
    type Result = Self;
}

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

impl UIAlertAction {
    extern_methods!(
        #[cfg(feature = "block2")]
        #[unsafe(method(actionWithTitle:style:handler:))]
        #[unsafe(method_family = none)]
        pub fn actionWithTitle_style_handler(
            title: Option<&NSString>,
            style: UIAlertActionStyle,
            handler: Option<&block2::DynBlock<dyn Fn(NonNull<UIAlertAction>)>>,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

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

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

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

        /// Setter for [`isEnabled`][Self::isEnabled].
        #[unsafe(method(setEnabled:))]
        #[unsafe(method_family = none)]
        pub fn setEnabled(&self, enabled: bool);
    );
}

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

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uialertcontroller?language=objc)
    #[unsafe(super(UIViewController, UIResponder, NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
    pub struct UIAlertController;
);

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
extern_conformance!(
    unsafe impl NSCoding for UIAlertController {}
);

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
extern_conformance!(
    unsafe impl NSObjectProtocol for UIAlertController {}
);

#[cfg(all(
    feature = "UIAppearance",
    feature = "UIResponder",
    feature = "UIViewController"
))]
extern_conformance!(
    unsafe impl UIAppearanceContainer for UIAlertController {}
);

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
extern_conformance!(
    unsafe impl UIContentContainer for UIAlertController {}
);

#[cfg(all(
    feature = "UIFocus",
    feature = "UIResponder",
    feature = "UIViewController"
))]
extern_conformance!(
    unsafe impl UIFocusEnvironment for UIAlertController {}
);

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
extern_conformance!(
    unsafe impl UIResponderStandardEditActions for UIAlertController {}
);

#[cfg(all(
    feature = "UIResponder",
    feature = "UITraitCollection",
    feature = "UIViewController"
))]
extern_conformance!(
    unsafe impl UITraitEnvironment for UIAlertController {}
);

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
impl UIAlertController {
    extern_methods!(
        #[unsafe(method(alertControllerWithTitle:message:preferredStyle:))]
        #[unsafe(method_family = none)]
        pub fn alertControllerWithTitle_message_preferredStyle(
            title: Option<&NSString>,
            message: Option<&NSString>,
            preferred_style: UIAlertControllerStyle,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        #[unsafe(method(addAction:))]
        #[unsafe(method_family = none)]
        pub fn addAction(&self, action: &UIAlertAction);

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

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

        /// Setter for [`preferredAction`][Self::preferredAction].
        #[unsafe(method(setPreferredAction:))]
        #[unsafe(method_family = none)]
        pub fn setPreferredAction(&self, preferred_action: Option<&UIAlertAction>);

        #[cfg(all(
            feature = "UIControl",
            feature = "UITextField",
            feature = "UIView",
            feature = "block2"
        ))]
        #[unsafe(method(addTextFieldWithConfigurationHandler:))]
        #[unsafe(method_family = none)]
        pub fn addTextFieldWithConfigurationHandler(
            &self,
            configuration_handler: Option<&block2::DynBlock<dyn Fn(NonNull<UITextField>)>>,
        );

        #[cfg(all(feature = "UIControl", feature = "UITextField", feature = "UIView"))]
        #[unsafe(method(textFields))]
        #[unsafe(method_family = none)]
        pub fn textFields(&self) -> Option<Retained<NSArray<UITextField>>>;

        #[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>);

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

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

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

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

        /// Setter for [`severity`][Self::severity].
        #[unsafe(method(setSeverity:))]
        #[unsafe(method_family = none)]
        pub fn setSeverity(&self, severity: UIAlertControllerSeverity);
    );
}

/// Methods declared on superclass `UIViewController`.
#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
impl UIAlertController {
    extern_methods!(
        #[unsafe(method(initWithNibName:bundle:))]
        #[unsafe(method_family = init)]
        pub 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(all(feature = "UIResponder", feature = "UIViewController"))]
impl UIAlertController {
    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>;
    );
}

/// SpringLoading.
#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
impl UIAlertController {
    extern_methods!();
}

#[cfg(all(
    feature = "UIResponder",
    feature = "UISpringLoadedInteractionSupporting",
    feature = "UIViewController"
))]
extern_conformance!(
    unsafe impl UISpringLoadedInteractionSupporting for UIAlertController {}
);
