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::*;
#[cfg(feature = "objc2-cloud-kit")]
use objc2_cloud_kit::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicloudsharingpermissionoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UICloudSharingPermissionOptions(pub NSUInteger);
bitflags::bitflags! {
    impl UICloudSharingPermissionOptions: NSUInteger {
        #[doc(alias = "UICloudSharingPermissionStandard")]
        const Standard = 0;
        #[doc(alias = "UICloudSharingPermissionAllowPublic")]
        const AllowPublic = 1<<0;
        #[doc(alias = "UICloudSharingPermissionAllowPrivate")]
        const AllowPrivate = 1<<1;
        #[doc(alias = "UICloudSharingPermissionAllowReadOnly")]
        const AllowReadOnly = 1<<2;
        #[doc(alias = "UICloudSharingPermissionAllowReadWrite")]
        const AllowReadWrite = 1<<3;
    }
}

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

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

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicloudsharingcontrollerdelegate?language=objc)
    pub unsafe trait UICloudSharingControllerDelegate:
        NSObjectProtocol + MainThreadOnly
    {
        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[unsafe(method(cloudSharingController:failedToSaveShareWithError:))]
        #[unsafe(method_family = none)]
        fn cloudSharingController_failedToSaveShareWithError(
            &self,
            csc: &UICloudSharingController,
            error: &NSError,
        );

        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[unsafe(method(itemTitleForCloudSharingController:))]
        #[unsafe(method_family = none)]
        fn itemTitleForCloudSharingController(
            &self,
            csc: &UICloudSharingController,
        ) -> Option<Retained<NSString>>;

        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[optional]
        #[unsafe(method(itemThumbnailDataForCloudSharingController:))]
        #[unsafe(method_family = none)]
        fn itemThumbnailDataForCloudSharingController(
            &self,
            csc: &UICloudSharingController,
        ) -> Option<Retained<NSData>>;

        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[optional]
        #[unsafe(method(itemTypeForCloudSharingController:))]
        #[unsafe(method_family = none)]
        fn itemTypeForCloudSharingController(
            &self,
            csc: &UICloudSharingController,
        ) -> Option<Retained<NSString>>;

        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[optional]
        #[unsafe(method(cloudSharingControllerDidSaveShare:))]
        #[unsafe(method_family = none)]
        fn cloudSharingControllerDidSaveShare(&self, csc: &UICloudSharingController);

        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[optional]
        #[unsafe(method(cloudSharingControllerDidStopSharing:))]
        #[unsafe(method_family = none)]
        fn cloudSharingControllerDidStopSharing(&self, csc: &UICloudSharingController);
    }
);

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

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

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

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

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

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

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

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

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
impl UICloudSharingController {
    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>>;

        #[cfg(all(feature = "block2", feature = "objc2-cloud-kit"))]
        /// # Safety
        ///
        /// - `preparation_handler` block's argument 2 block's argument 1 must be a valid pointer or null.
        /// - `preparation_handler` block's argument 2 block's argument 2 must be a valid pointer or null.
        /// - `preparation_handler` block's argument 2 block's argument 3 must be a valid pointer or null.
        #[deprecated = "Use -[UIActivityViewController initWithActivityItemsConfiguration:] and pass it a UIActivityItemsConfigurationReading-conforming object with an NSItemProvider and registered preparation handler"]
        #[unsafe(method(initWithPreparationHandler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithPreparationHandler(
            this: Allocated<Self>,
            preparation_handler: &block2::DynBlock<
                dyn Fn(
                    NonNull<UICloudSharingController>,
                    NonNull<block2::DynBlock<dyn Fn(*mut CKShare, *mut CKContainer, *mut NSError)>>,
                ),
            >,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-cloud-kit")]
        #[unsafe(method(initWithShare:container:))]
        #[unsafe(method_family = init)]
        pub fn initWithShare_container(
            this: Allocated<Self>,
            share: &CKShare,
            container: &CKContainer,
        ) -> Retained<Self>;

        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn UICloudSharingControllerDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn UICloudSharingControllerDelegate>>,
        );

        #[cfg(feature = "objc2-cloud-kit")]
        #[unsafe(method(share))]
        #[unsafe(method_family = none)]
        pub fn share(&self) -> Option<Retained<CKShare>>;

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

        /// Setter for [`availablePermissions`][Self::availablePermissions].
        #[unsafe(method(setAvailablePermissions:))]
        #[unsafe(method_family = none)]
        pub fn setAvailablePermissions(
            &self,
            available_permissions: UICloudSharingPermissionOptions,
        );

        #[cfg(feature = "UIActivityItemProvider")]
        #[unsafe(method(activityItemSource))]
        #[unsafe(method_family = none)]
        pub fn activityItemSource(&self) -> Retained<ProtocolObject<dyn UIActivityItemSource>>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
impl UICloudSharingController {
    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>;
    );
}