objc2_event_kit_ui/generated/
EKEventEditViewController.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::*;
6#[cfg(feature = "objc2-event-kit")]
7use objc2_event_kit::*;
8use objc2_foundation::*;
9#[cfg(feature = "objc2-ui-kit")]
10use objc2_ui_kit::*;
11
12use crate::*;
13
14/// Represents actions that should cause the edit view controller to be dismissed
15///
16/// See also [Apple's documentation](https://developer.apple.com/documentation/eventkitui/ekeventeditviewaction?language=objc)
17// NS_ENUM
18#[repr(transparent)]
19#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
20pub struct EKEventEditViewAction(pub NSInteger);
21impl EKEventEditViewAction {
22    #[doc(alias = "EKEventEditViewActionCanceled")]
23    pub const Canceled: Self = Self(0);
24    #[doc(alias = "EKEventEditViewActionSaved")]
25    pub const Saved: Self = Self(1);
26    #[doc(alias = "EKEventEditViewActionDeleted")]
27    pub const Deleted: Self = Self(2);
28    #[doc(alias = "EKEventEditViewActionCancelled")]
29    pub const Cancelled: Self = Self(EKEventEditViewAction::Canceled.0);
30}
31
32unsafe impl Encode for EKEventEditViewAction {
33    const ENCODING: Encoding = NSInteger::ENCODING;
34}
35
36unsafe impl RefEncode for EKEventEditViewAction {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40extern_class!(
41    /// [Apple's documentation](https://developer.apple.com/documentation/eventkitui/ekeventeditviewcontroller?language=objc)
42    #[unsafe(super(UINavigationController, UIViewController, UIResponder, NSObject))]
43    #[derive(Debug, PartialEq, Eq, Hash)]
44    #[cfg(feature = "objc2-ui-kit")]
45    pub struct EKEventEditViewController;
46);
47
48#[cfg(feature = "objc2-ui-kit")]
49unsafe impl NSCoding for EKEventEditViewController {}
50
51#[cfg(feature = "objc2-ui-kit")]
52unsafe impl NSObjectProtocol for EKEventEditViewController {}
53
54#[cfg(feature = "objc2-ui-kit")]
55unsafe impl UIAppearanceContainer for EKEventEditViewController {}
56
57#[cfg(feature = "objc2-ui-kit")]
58unsafe impl UIContentContainer for EKEventEditViewController {}
59
60#[cfg(feature = "objc2-ui-kit")]
61unsafe impl UIFocusEnvironment for EKEventEditViewController {}
62
63#[cfg(feature = "objc2-ui-kit")]
64unsafe impl UIResponderStandardEditActions for EKEventEditViewController {}
65
66#[cfg(feature = "objc2-ui-kit")]
67unsafe impl UITraitEnvironment for EKEventEditViewController {}
68
69#[cfg(feature = "objc2-ui-kit")]
70impl EKEventEditViewController {
71    extern_methods!(
72        #[unsafe(method(editViewDelegate))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn editViewDelegate(
75            &self,
76        ) -> Option<Retained<ProtocolObject<dyn EKEventEditViewDelegate>>>;
77
78        /// This is a [weak property][objc2::topics::weak_property].
79        /// Setter for [`editViewDelegate`][Self::editViewDelegate].
80        #[unsafe(method(setEditViewDelegate:))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn setEditViewDelegate(
83            &self,
84            edit_view_delegate: Option<&ProtocolObject<dyn EKEventEditViewDelegate>>,
85        );
86
87        #[cfg(feature = "objc2-event-kit")]
88        /// The event store to use to save events.
89        ///
90        /// You must set this before presenting the view controller.
91        #[unsafe(method(eventStore))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn eventStore(&self) -> Option<Retained<EKEventStore>>;
94
95        #[cfg(feature = "objc2-event-kit")]
96        /// Setter for [`eventStore`][Self::eventStore].
97        #[unsafe(method(setEventStore:))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn setEventStore(&self, event_store: Option<&EKEventStore>);
100
101        #[cfg(feature = "objc2-event-kit")]
102        /// The event to edit.
103        ///
104        /// You must set this before presenting the view controller. You can leave
105        /// it set to nil and a new event will be created for you. If you pass an event
106        /// here and it does not belong to the event store (if set) an exception will be
107        /// raised.
108        #[unsafe(method(event))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn event(&self) -> Option<Retained<EKEvent>>;
111
112        #[cfg(feature = "objc2-event-kit")]
113        /// Setter for [`event`][Self::event].
114        #[unsafe(method(setEvent:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn setEvent(&self, event: Option<&EKEvent>);
117
118        /// Ends the editing session discarding any changes to the event.
119        ///
120        /// This method simulates the user tapping the Cancel button. The delegate will not
121        /// receive the eventEditViewController:didCompleteWithAction: message, so you are
122        /// responsible for dismissing the controller after calling this method.
123        #[unsafe(method(cancelEditing))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn cancelEditing(&self);
126    );
127}
128
129/// Methods declared on superclass `UINavigationController`.
130#[cfg(feature = "objc2-ui-kit")]
131impl EKEventEditViewController {
132    extern_methods!(
133        #[unsafe(method(initWithNavigationBarClass:toolbarClass:))]
134        #[unsafe(method_family = init)]
135        pub unsafe fn initWithNavigationBarClass_toolbarClass(
136            this: Allocated<Self>,
137            navigation_bar_class: Option<&AnyClass>,
138            toolbar_class: Option<&AnyClass>,
139        ) -> Retained<Self>;
140
141        #[unsafe(method(initWithRootViewController:))]
142        #[unsafe(method_family = init)]
143        pub unsafe fn initWithRootViewController(
144            this: Allocated<Self>,
145            root_view_controller: &UIViewController,
146        ) -> Retained<Self>;
147
148        #[unsafe(method(initWithNibName:bundle:))]
149        #[unsafe(method_family = init)]
150        pub unsafe fn initWithNibName_bundle(
151            this: Allocated<Self>,
152            nib_name_or_nil: Option<&NSString>,
153            nib_bundle_or_nil: Option<&NSBundle>,
154        ) -> Retained<Self>;
155
156        #[unsafe(method(initWithCoder:))]
157        #[unsafe(method_family = init)]
158        pub unsafe fn initWithCoder(
159            this: Allocated<Self>,
160            a_decoder: &NSCoder,
161        ) -> Option<Retained<Self>>;
162    );
163}
164
165/// Methods declared on superclass `NSObject`.
166#[cfg(feature = "objc2-ui-kit")]
167impl EKEventEditViewController {
168    extern_methods!(
169        #[unsafe(method(init))]
170        #[unsafe(method_family = init)]
171        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
172
173        #[unsafe(method(new))]
174        #[unsafe(method_family = new)]
175        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
176    );
177}
178
179extern_protocol!(
180    /// View controller to create/edit events.
181    ///
182    /// You can present this view controller to create a new event or edit an existing
183    /// event. You should present it modally. To create a new event, you can either pass
184    /// nil for the event parameter or pass a partially constructed event. If the event
185    /// you pass has no calendar set, the default calendar as set in Settings will be used.
186    ///
187    /// See also [Apple's documentation](https://developer.apple.com/documentation/eventkitui/ekeventeditviewdelegate?language=objc)
188    pub unsafe trait EKEventEditViewDelegate: NSObjectProtocol {
189        #[cfg(feature = "objc2-ui-kit")]
190        /// Called to let delegate know the controller is done editing.
191        ///
192        /// When the user presses Cancel, presses Done, or deletes the event, this method
193        /// is called. Your delegate is responsible for dismissing the controller. If the editing
194        /// session is terminated programmatically using cancelEditing,
195        /// this method will not be called.
196        ///
197        ///
198        /// Parameter `controller`: the controller in question
199        ///
200        /// Parameter `action`: the action that is causing the dismissal
201        #[unsafe(method(eventEditViewController:didCompleteWithAction:))]
202        #[unsafe(method_family = none)]
203        unsafe fn eventEditViewController_didCompleteWithAction(
204            &self,
205            controller: &EKEventEditViewController,
206            action: EKEventEditViewAction,
207        );
208
209        #[cfg(all(feature = "objc2-event-kit", feature = "objc2-ui-kit"))]
210        /// Allows you to supply your own default calendar for new events.
211        ///
212        /// This delegate method allows you to control what the editor chooses for the default calendar
213        /// if it needs to fill in a calendar. This might be necessary if you either don't pass an initial
214        /// event to the view controller, or you do, but you did not supply a calendar. In these cases, we
215        /// we set the calendar to a default. If this is not implemented by the delegate, the controller
216        /// will use the store's defaultCalendarForNewEvents.
217        #[optional]
218        #[unsafe(method(eventEditViewControllerDefaultCalendarForNewEvents:))]
219        #[unsafe(method_family = none)]
220        unsafe fn eventEditViewControllerDefaultCalendarForNewEvents(
221            &self,
222            controller: &EKEventEditViewController,
223        ) -> Retained<EKCalendar>;
224    }
225);