//! 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/uiactivitysectiontypes?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIActivitySectionTypes(pub NSUInteger);
bitflags::bitflags! {
    impl UIActivitySectionTypes: NSUInteger {
        #[doc(alias = "UIActivitySectionTypesNone")]
        const None = 0;
        #[doc(alias = "UIActivitySectionTypesPeopleSuggestions")]
        const PeopleSuggestions = 1<<0;
    }
}

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiactivityviewcontrollercompletionhandler?language=objc)
#[cfg(all(feature = "UIActivity", feature = "block2"))]
pub type UIActivityViewControllerCompletionHandler =
    *mut block2::DynBlock<dyn Fn(*mut UIActivityType, Bool)>;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiactivityviewcontrollercompletionwithitemshandler?language=objc)
#[cfg(all(feature = "UIActivity", feature = "block2"))]
pub type UIActivityViewControllerCompletionWithItemsHandler =
    *mut block2::DynBlock<dyn Fn(*mut UIActivityType, Bool, *mut NSArray, *mut NSError)>;

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

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

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

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

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

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

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

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

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
impl UIActivityViewController {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

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

        #[cfg(feature = "UIActivity")]
        /// # Safety
        ///
        /// `activity_items` generic should be of the correct type.
        #[unsafe(method(initWithActivityItems:applicationActivities:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithActivityItems_applicationActivities(
            this: Allocated<Self>,
            activity_items: &NSArray,
            application_activities: Option<&NSArray<UIActivity>>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "UIActivity", feature = "block2"))]
        /// # Safety
        ///
        /// The returned block's argument 1 must be a valid pointer or null.
        #[deprecated]
        #[unsafe(method(completionHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn completionHandler(&self) -> UIActivityViewControllerCompletionHandler;

        #[cfg(all(feature = "UIActivity", feature = "block2"))]
        /// Setter for [`completionHandler`][Self::completionHandler].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `completion_handler` must be a valid pointer or null.
        #[deprecated]
        #[unsafe(method(setCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setCompletionHandler(
            &self,
            completion_handler: UIActivityViewControllerCompletionHandler,
        );

        #[cfg(all(feature = "UIActivity", feature = "block2"))]
        /// # Safety
        ///
        /// - The returned block's argument 1 must be a valid pointer or null.
        /// - The returned block's argument 3 must be a valid pointer or null.
        /// - The returned block's argument 4 must be a valid pointer or null.
        #[unsafe(method(completionWithItemsHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn completionWithItemsHandler(
            &self,
        ) -> UIActivityViewControllerCompletionWithItemsHandler;

        #[cfg(all(feature = "UIActivity", feature = "block2"))]
        /// Setter for [`completionWithItemsHandler`][Self::completionWithItemsHandler].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `completion_with_items_handler` must be a valid pointer or null.
        #[unsafe(method(setCompletionWithItemsHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setCompletionWithItemsHandler(
            &self,
            completion_with_items_handler: UIActivityViewControllerCompletionWithItemsHandler,
        );

        #[cfg(feature = "UIActivity")]
        #[unsafe(method(excludedActivityTypes))]
        #[unsafe(method_family = none)]
        pub fn excludedActivityTypes(&self) -> Option<Retained<NSArray<UIActivityType>>>;

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

        /// Hides some sections of the activity view controller. Default is none
        #[unsafe(method(excludedActivitySectionTypes))]
        #[unsafe(method_family = none)]
        pub fn excludedActivitySectionTypes(&self) -> UIActivitySectionTypes;

        /// Setter for [`excludedActivitySectionTypes`][Self::excludedActivitySectionTypes].
        #[unsafe(method(setExcludedActivitySectionTypes:))]
        #[unsafe(method_family = none)]
        pub fn setExcludedActivitySectionTypes(
            &self,
            excluded_activity_section_types: UIActivitySectionTypes,
        );

        /// In some contexts, the activity view controller can elevate a specific activity in the header view to enhance it.
        /// The prominent activity can only be chosen by the system.
        /// Defaults to YES.
        #[unsafe(method(allowsProminentActivity))]
        #[unsafe(method_family = none)]
        pub fn allowsProminentActivity(&self) -> bool;

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

/// Methods declared on superclass `NSObject`.
#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
impl UIActivityViewController {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

/// UIActivityItemsConfiguration.
#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
impl UIActivityViewController {
    extern_methods!(
        #[cfg(feature = "UIActivityItemsConfigurationReading")]
        #[unsafe(method(initWithActivityItemsConfiguration:))]
        #[unsafe(method_family = init)]
        pub fn initWithActivityItemsConfiguration(
            this: Allocated<Self>,
            activity_items_configuration: &ProtocolObject<dyn UIActivityItemsConfigurationReading>,
        ) -> Retained<Self>;
    );
}
