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::*;

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

#[cfg(feature = "UICalendarSelection")]
extern_conformance!(
    unsafe impl NSObjectProtocol for UICalendarSelectionSingleDate {}
);

#[cfg(feature = "UICalendarSelection")]
impl UICalendarSelectionSingleDate {
    extern_methods!(
        /// The object that acts as the delegate of the calendar view selection
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn UICalendarSelectionSingleDateDelegate>>>;

        /// The currently selected dates in the Calendar view. If this property is
        /// `nil`then nothing in the calendar
        /// view is currently selected. The default value is
        /// `nil.`
        #[unsafe(method(selectedDate))]
        #[unsafe(method_family = none)]
        pub fn selectedDate(&self) -> Option<Retained<NSDateComponents>>;

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

        /// Sets the selected date to be displayed in the calendar, with an option to animate the setting.
        #[unsafe(method(setSelectedDate:animated:))]
        #[unsafe(method_family = none)]
        pub fn setSelectedDate_animated(
            &self,
            selected_date: Option<&NSDateComponents>,
            animated: bool,
        );

        /// Creates a new single selection with the specified delegate.
        #[unsafe(method(initWithDelegate:))]
        #[unsafe(method_family = init)]
        pub fn initWithDelegate(
            this: Allocated<Self>,
            delegate: Option<&ProtocolObject<dyn UICalendarSelectionSingleDateDelegate>>,
        ) -> Retained<Self>;
    );
}

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

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

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicalendarselectionsingledatedelegate?language=objc)
    pub unsafe trait UICalendarSelectionSingleDateDelegate:
        NSObjectProtocol + MainThreadOnly
    {
        #[cfg(feature = "UICalendarSelection")]
        /// Called after the user selects a date in the calendar view.
        ///
        ///
        /// Parameter `selection`: The
        /// `UICalendarSelectionMultiDate`
        /// Parameter `dateComponents`: The date that was selected by the user.
        /// `dateComponents`can be
        /// `nil`when the selected date is deselected by the user.
        #[unsafe(method(dateSelection:didSelectDate:))]
        #[unsafe(method_family = none)]
        fn dateSelection_didSelectDate(
            &self,
            selection: &UICalendarSelectionSingleDate,
            date_components: Option<&NSDateComponents>,
        );

        #[cfg(feature = "UICalendarSelection")]
        /// Determines if a date is selectable. Dates that are not selectable will be disabled in the calendar view.
        /// By default,
        /// `dateSelection:canSelectDate:`returns YES if dateComponents is non-nil.
        ///
        ///
        /// Parameter `selection`: The
        /// `UICalendarSelectionMultiDate`
        /// Parameter `dateComponents`: The date to be checked by selection; a
        /// `nil`date represents a deselected date.
        ///
        ///
        /// Returns: YES if the date can be selected, NO otherwise.
        #[optional]
        #[unsafe(method(dateSelection:canSelectDate:))]
        #[unsafe(method_family = none)]
        fn dateSelection_canSelectDate(
            &self,
            selection: &UICalendarSelectionSingleDate,
            date_components: Option<&NSDateComponents>,
        ) -> bool;
    }
);