//! 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/uipageviewcontrollernavigationorientation?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIPageViewControllerNavigationOrientation(pub NSInteger);
impl UIPageViewControllerNavigationOrientation {
    #[doc(alias = "UIPageViewControllerNavigationOrientationHorizontal")]
    pub const Horizontal: Self = Self(0);
    #[doc(alias = "UIPageViewControllerNavigationOrientationVertical")]
    pub const Vertical: Self = Self(1);
}

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipageviewcontrollerspinelocation?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIPageViewControllerSpineLocation(pub NSInteger);
impl UIPageViewControllerSpineLocation {
    #[doc(alias = "UIPageViewControllerSpineLocationNone")]
    pub const None: Self = Self(0);
    #[doc(alias = "UIPageViewControllerSpineLocationMin")]
    pub const Min: Self = Self(1);
    #[doc(alias = "UIPageViewControllerSpineLocationMid")]
    pub const Mid: Self = Self(2);
    #[doc(alias = "UIPageViewControllerSpineLocationMax")]
    pub const Max: Self = Self(3);
}

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

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

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

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

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

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

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipageviewcontrolleroptionskey?language=objc)
// NS_TYPED_ENUM
pub type UIPageViewControllerOptionsKey = NSString;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipageviewcontrolleroptionspinelocationkey?language=objc)
    pub static UIPageViewControllerOptionSpineLocationKey: &'static UIPageViewControllerOptionsKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipageviewcontrolleroptioninterpagespacingkey?language=objc)
    pub static UIPageViewControllerOptionInterPageSpacingKey:
        &'static UIPageViewControllerOptionsKey;
}

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

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

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

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

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

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

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

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

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
impl UIPageViewController {
    extern_methods!(
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(initWithTransitionStyle:navigationOrientation:options:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithTransitionStyle_navigationOrientation_options(
            this: Allocated<Self>,
            style: UIPageViewControllerTransitionStyle,
            navigation_orientation: UIPageViewControllerNavigationOrientation,
            options: Option<&NSDictionary<UIPageViewControllerOptionsKey, AnyObject>>,
        ) -> 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>>;

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

        /// 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 UIPageViewControllerDelegate>>,
        );

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

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

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

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

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

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

        /// Setter for [`isDoubleSided`][Self::isDoubleSided].
        #[unsafe(method(setDoubleSided:))]
        #[unsafe(method_family = none)]
        pub fn setDoubleSided(&self, double_sided: bool);

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

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

        #[cfg(feature = "block2")]
        #[unsafe(method(setViewControllers:direction:animated:completion:))]
        #[unsafe(method_family = none)]
        pub fn setViewControllers_direction_animated_completion(
            &self,
            view_controllers: Option<&NSArray<UIViewController>>,
            direction: UIPageViewControllerNavigationDirection,
            animated: bool,
            completion: Option<&block2::DynBlock<dyn Fn(Bool)>>,
        );
    );
}

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

/// Methods declared on superclass `NSObject`.
#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
impl UIPageViewController {
    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_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipageviewcontrollerdelegate?language=objc)
    pub unsafe trait UIPageViewControllerDelegate:
        NSObjectProtocol + MainThreadOnly
    {
        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[optional]
        #[unsafe(method(pageViewController:willTransitionToViewControllers:))]
        #[unsafe(method_family = none)]
        fn pageViewController_willTransitionToViewControllers(
            &self,
            page_view_controller: &UIPageViewController,
            pending_view_controllers: &NSArray<UIViewController>,
        );

        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[optional]
        #[unsafe(method(pageViewController:didFinishAnimating:previousViewControllers:transitionCompleted:))]
        #[unsafe(method_family = none)]
        fn pageViewController_didFinishAnimating_previousViewControllers_transitionCompleted(
            &self,
            page_view_controller: &UIPageViewController,
            finished: bool,
            previous_view_controllers: &NSArray<UIViewController>,
            completed: bool,
        );

        #[cfg(all(
            feature = "UIOrientation",
            feature = "UIResponder",
            feature = "UIViewController"
        ))]
        #[optional]
        #[unsafe(method(pageViewController:spineLocationForInterfaceOrientation:))]
        #[unsafe(method_family = none)]
        fn pageViewController_spineLocationForInterfaceOrientation(
            &self,
            page_view_controller: &UIPageViewController,
            orientation: UIInterfaceOrientation,
        ) -> UIPageViewControllerSpineLocation;

        #[cfg(all(
            feature = "UIOrientation",
            feature = "UIResponder",
            feature = "UIViewController"
        ))]
        #[optional]
        #[unsafe(method(pageViewControllerSupportedInterfaceOrientations:))]
        #[unsafe(method_family = none)]
        fn pageViewControllerSupportedInterfaceOrientations(
            &self,
            page_view_controller: &UIPageViewController,
        ) -> UIInterfaceOrientationMask;

        #[cfg(all(
            feature = "UIOrientation",
            feature = "UIResponder",
            feature = "UIViewController"
        ))]
        #[optional]
        #[unsafe(method(pageViewControllerPreferredInterfaceOrientationForPresentation:))]
        #[unsafe(method_family = none)]
        fn pageViewControllerPreferredInterfaceOrientationForPresentation(
            &self,
            page_view_controller: &UIPageViewController,
        ) -> UIInterfaceOrientation;
    }
);

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipageviewcontrollerdatasource?language=objc)
    pub unsafe trait UIPageViewControllerDataSource:
        NSObjectProtocol + MainThreadOnly
    {
        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[unsafe(method(pageViewController:viewControllerBeforeViewController:))]
        #[unsafe(method_family = none)]
        fn pageViewController_viewControllerBeforeViewController(
            &self,
            page_view_controller: &UIPageViewController,
            view_controller: &UIViewController,
        ) -> Option<Retained<UIViewController>>;

        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[unsafe(method(pageViewController:viewControllerAfterViewController:))]
        #[unsafe(method_family = none)]
        fn pageViewController_viewControllerAfterViewController(
            &self,
            page_view_controller: &UIPageViewController,
            view_controller: &UIViewController,
        ) -> Option<Retained<UIViewController>>;

        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[optional]
        #[unsafe(method(presentationCountForPageViewController:))]
        #[unsafe(method_family = none)]
        fn presentationCountForPageViewController(
            &self,
            page_view_controller: &UIPageViewController,
        ) -> NSInteger;

        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[optional]
        #[unsafe(method(presentationIndexForPageViewController:))]
        #[unsafe(method_family = none)]
        fn presentationIndexForPageViewController(
            &self,
            page_view_controller: &UIPageViewController,
        ) -> NSInteger;
    }
);
