objc2_ui_kit/generated/
UICalendarSelectionSingleDate.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicalendarselectionsingledate?language=objc)
12    #[unsafe(super(UICalendarSelection, NSObject))]
13    #[thread_kind = MainThreadOnly]
14    #[derive(Debug, PartialEq, Eq, Hash)]
15    #[cfg(feature = "UICalendarSelection")]
16    pub struct UICalendarSelectionSingleDate;
17);
18
19#[cfg(feature = "UICalendarSelection")]
20unsafe impl NSObjectProtocol for UICalendarSelectionSingleDate {}
21
22#[cfg(feature = "UICalendarSelection")]
23impl UICalendarSelectionSingleDate {
24    extern_methods!(
25        /// The object that acts as the delegate of the calendar view selection
26        #[unsafe(method(delegate))]
27        #[unsafe(method_family = none)]
28        pub unsafe fn delegate(
29            &self,
30        ) -> Option<Retained<ProtocolObject<dyn UICalendarSelectionSingleDateDelegate>>>;
31
32        /// The currently selected dates in the Calendar view. If this property is
33        /// `nil`then nothing in the calendar
34        /// view is currently selected. The default value is
35        /// `nil.`
36        #[unsafe(method(selectedDate))]
37        #[unsafe(method_family = none)]
38        pub unsafe fn selectedDate(&self) -> Option<Retained<NSDateComponents>>;
39
40        /// Setter for [`selectedDate`][Self::selectedDate].
41        #[unsafe(method(setSelectedDate:))]
42        #[unsafe(method_family = none)]
43        pub unsafe fn setSelectedDate(&self, selected_date: Option<&NSDateComponents>);
44
45        /// Sets the selected date to be displayed in the calendar, with an option to animate the setting.
46        #[unsafe(method(setSelectedDate:animated:))]
47        #[unsafe(method_family = none)]
48        pub unsafe fn setSelectedDate_animated(
49            &self,
50            selected_date: Option<&NSDateComponents>,
51            animated: bool,
52        );
53
54        /// Creates a new single selection with the specified delegate.
55        #[unsafe(method(initWithDelegate:))]
56        #[unsafe(method_family = init)]
57        pub unsafe fn initWithDelegate(
58            this: Allocated<Self>,
59            delegate: Option<&ProtocolObject<dyn UICalendarSelectionSingleDateDelegate>>,
60        ) -> Retained<Self>;
61    );
62}
63
64/// Methods declared on superclass `UICalendarSelection`.
65#[cfg(feature = "UICalendarSelection")]
66impl UICalendarSelectionSingleDate {
67    extern_methods!(
68        #[unsafe(method(init))]
69        #[unsafe(method_family = init)]
70        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
71
72        #[unsafe(method(new))]
73        #[unsafe(method_family = new)]
74        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
75    );
76}
77
78extern_protocol!(
79    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicalendarselectionsingledatedelegate?language=objc)
80    pub unsafe trait UICalendarSelectionSingleDateDelegate: NSObjectProtocol {
81        #[cfg(feature = "UICalendarSelection")]
82        /// Called after the user selects a date in the calendar view.
83        ///
84        ///
85        /// Parameter `selection`: The
86        /// `UICalendarSelectionMultiDate`
87        /// Parameter `dateComponents`: The date that was selected by the user.
88        /// `dateComponents`can be
89        /// `nil`when the selected date is deselected by the user.
90        #[unsafe(method(dateSelection:didSelectDate:))]
91        #[unsafe(method_family = none)]
92        unsafe fn dateSelection_didSelectDate(
93            &self,
94            selection: &UICalendarSelectionSingleDate,
95            date_components: Option<&NSDateComponents>,
96        );
97
98        #[cfg(feature = "UICalendarSelection")]
99        /// Determines if a date is selectable. Dates that are not selectable will be disabled in the calendar view.
100        /// By default,
101        /// `dateSelection:canSelectDate:`returns YES if dateComponents is non-nil.
102        ///
103        ///
104        /// Parameter `selection`: The
105        /// `UICalendarSelectionMultiDate`
106        /// Parameter `dateComponents`: The date to be checked by selection; a
107        /// `nil`date represents a deselected date.
108        ///
109        ///
110        /// Returns: YES if the date can be selected, NO otherwise.
111        #[optional]
112        #[unsafe(method(dateSelection:canSelectDate:))]
113        #[unsafe(method_family = none)]
114        unsafe fn dateSelection_canSelectDate(
115            &self,
116            selection: &UICalendarSelectionSingleDate,
117            date_components: Option<&NSDateComponents>,
118        ) -> bool;
119    }
120);