1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct UIPageViewControllerNavigationOrientation(pub NSInteger);
15impl UIPageViewControllerNavigationOrientation {
16 #[doc(alias = "UIPageViewControllerNavigationOrientationHorizontal")]
17 pub const Horizontal: Self = Self(0);
18 #[doc(alias = "UIPageViewControllerNavigationOrientationVertical")]
19 pub const Vertical: Self = Self(1);
20}
21
22unsafe impl Encode for UIPageViewControllerNavigationOrientation {
23 const ENCODING: Encoding = NSInteger::ENCODING;
24}
25
26unsafe impl RefEncode for UIPageViewControllerNavigationOrientation {
27 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
28}
29
30#[repr(transparent)]
33#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
34pub struct UIPageViewControllerSpineLocation(pub NSInteger);
35impl UIPageViewControllerSpineLocation {
36 #[doc(alias = "UIPageViewControllerSpineLocationNone")]
37 pub const None: Self = Self(0);
38 #[doc(alias = "UIPageViewControllerSpineLocationMin")]
39 pub const Min: Self = Self(1);
40 #[doc(alias = "UIPageViewControllerSpineLocationMid")]
41 pub const Mid: Self = Self(2);
42 #[doc(alias = "UIPageViewControllerSpineLocationMax")]
43 pub const Max: Self = Self(3);
44}
45
46unsafe impl Encode for UIPageViewControllerSpineLocation {
47 const ENCODING: Encoding = NSInteger::ENCODING;
48}
49
50unsafe impl RefEncode for UIPageViewControllerSpineLocation {
51 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
52}
53
54#[repr(transparent)]
57#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
58pub struct UIPageViewControllerNavigationDirection(pub NSInteger);
59impl UIPageViewControllerNavigationDirection {
60 #[doc(alias = "UIPageViewControllerNavigationDirectionForward")]
61 pub const Forward: Self = Self(0);
62 #[doc(alias = "UIPageViewControllerNavigationDirectionReverse")]
63 pub const Reverse: Self = Self(1);
64}
65
66unsafe impl Encode for UIPageViewControllerNavigationDirection {
67 const ENCODING: Encoding = NSInteger::ENCODING;
68}
69
70unsafe impl RefEncode for UIPageViewControllerNavigationDirection {
71 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
72}
73
74#[repr(transparent)]
77#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
78pub struct UIPageViewControllerTransitionStyle(pub NSInteger);
79impl UIPageViewControllerTransitionStyle {
80 #[doc(alias = "UIPageViewControllerTransitionStylePageCurl")]
81 pub const PageCurl: Self = Self(0);
82 #[doc(alias = "UIPageViewControllerTransitionStyleScroll")]
83 pub const Scroll: Self = Self(1);
84}
85
86unsafe impl Encode for UIPageViewControllerTransitionStyle {
87 const ENCODING: Encoding = NSInteger::ENCODING;
88}
89
90unsafe impl RefEncode for UIPageViewControllerTransitionStyle {
91 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
92}
93
94pub type UIPageViewControllerOptionsKey = NSString;
97
98extern "C" {
99 pub static UIPageViewControllerOptionSpineLocationKey: &'static UIPageViewControllerOptionsKey;
101}
102
103extern "C" {
104 pub static UIPageViewControllerOptionInterPageSpacingKey:
106 &'static UIPageViewControllerOptionsKey;
107}
108
109extern_class!(
110 #[unsafe(super(UIViewController, UIResponder, NSObject))]
112 #[thread_kind = MainThreadOnly]
113 #[derive(Debug, PartialEq, Eq, Hash)]
114 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
115 pub struct UIPageViewController;
116);
117
118#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
119unsafe impl NSCoding for UIPageViewController {}
120
121#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
122unsafe impl NSObjectProtocol for UIPageViewController {}
123
124#[cfg(all(
125 feature = "UIAppearance",
126 feature = "UIResponder",
127 feature = "UIViewController"
128))]
129unsafe impl UIAppearanceContainer for UIPageViewController {}
130
131#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
132unsafe impl UIContentContainer for UIPageViewController {}
133
134#[cfg(all(
135 feature = "UIFocus",
136 feature = "UIResponder",
137 feature = "UIViewController"
138))]
139unsafe impl UIFocusEnvironment for UIPageViewController {}
140
141#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
142unsafe impl UIResponderStandardEditActions for UIPageViewController {}
143
144#[cfg(all(
145 feature = "UIResponder",
146 feature = "UITraitCollection",
147 feature = "UIViewController"
148))]
149unsafe impl UITraitEnvironment for UIPageViewController {}
150
151#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
152impl UIPageViewController {
153 extern_methods!(
154 #[unsafe(method(initWithTransitionStyle:navigationOrientation:options:))]
155 #[unsafe(method_family = init)]
156 pub unsafe fn initWithTransitionStyle_navigationOrientation_options(
157 this: Allocated<Self>,
158 style: UIPageViewControllerTransitionStyle,
159 navigation_orientation: UIPageViewControllerNavigationOrientation,
160 options: Option<&NSDictionary<UIPageViewControllerOptionsKey, AnyObject>>,
161 ) -> Retained<Self>;
162
163 #[unsafe(method(initWithCoder:))]
164 #[unsafe(method_family = init)]
165 pub unsafe fn initWithCoder(
166 this: Allocated<Self>,
167 coder: &NSCoder,
168 ) -> Option<Retained<Self>>;
169
170 #[unsafe(method(delegate))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn delegate(
173 &self,
174 ) -> Option<Retained<ProtocolObject<dyn UIPageViewControllerDelegate>>>;
175
176 #[unsafe(method(setDelegate:))]
179 #[unsafe(method_family = none)]
180 pub unsafe fn setDelegate(
181 &self,
182 delegate: Option<&ProtocolObject<dyn UIPageViewControllerDelegate>>,
183 );
184
185 #[unsafe(method(dataSource))]
186 #[unsafe(method_family = none)]
187 pub unsafe fn dataSource(
188 &self,
189 ) -> Option<Retained<ProtocolObject<dyn UIPageViewControllerDataSource>>>;
190
191 #[unsafe(method(setDataSource:))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn setDataSource(
196 &self,
197 data_source: Option<&ProtocolObject<dyn UIPageViewControllerDataSource>>,
198 );
199
200 #[unsafe(method(transitionStyle))]
201 #[unsafe(method_family = none)]
202 pub unsafe fn transitionStyle(&self) -> UIPageViewControllerTransitionStyle;
203
204 #[unsafe(method(navigationOrientation))]
205 #[unsafe(method_family = none)]
206 pub unsafe fn navigationOrientation(&self) -> UIPageViewControllerNavigationOrientation;
207
208 #[unsafe(method(spineLocation))]
209 #[unsafe(method_family = none)]
210 pub unsafe fn spineLocation(&self) -> UIPageViewControllerSpineLocation;
211
212 #[unsafe(method(isDoubleSided))]
213 #[unsafe(method_family = none)]
214 pub unsafe fn isDoubleSided(&self) -> bool;
215
216 #[unsafe(method(setDoubleSided:))]
218 #[unsafe(method_family = none)]
219 pub unsafe fn setDoubleSided(&self, double_sided: bool);
220
221 #[cfg(feature = "UIGestureRecognizer")]
222 #[unsafe(method(gestureRecognizers))]
223 #[unsafe(method_family = none)]
224 pub unsafe fn gestureRecognizers(&self) -> Retained<NSArray<UIGestureRecognizer>>;
225
226 #[unsafe(method(viewControllers))]
227 #[unsafe(method_family = none)]
228 pub unsafe fn viewControllers(&self) -> Option<Retained<NSArray<UIViewController>>>;
229
230 #[cfg(feature = "block2")]
231 #[unsafe(method(setViewControllers:direction:animated:completion:))]
232 #[unsafe(method_family = none)]
233 pub unsafe fn setViewControllers_direction_animated_completion(
234 &self,
235 view_controllers: Option<&NSArray<UIViewController>>,
236 direction: UIPageViewControllerNavigationDirection,
237 animated: bool,
238 completion: Option<&block2::Block<dyn Fn(Bool)>>,
239 );
240 );
241}
242
243#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
245impl UIPageViewController {
246 extern_methods!(
247 #[unsafe(method(initWithNibName:bundle:))]
248 #[unsafe(method_family = init)]
249 pub unsafe fn initWithNibName_bundle(
250 this: Allocated<Self>,
251 nib_name_or_nil: Option<&NSString>,
252 nib_bundle_or_nil: Option<&NSBundle>,
253 ) -> Retained<Self>;
254 );
255}
256
257#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
259impl UIPageViewController {
260 extern_methods!(
261 #[unsafe(method(init))]
262 #[unsafe(method_family = init)]
263 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
264
265 #[unsafe(method(new))]
266 #[unsafe(method_family = new)]
267 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
268 );
269}
270
271extern_protocol!(
272 pub unsafe trait UIPageViewControllerDelegate:
274 NSObjectProtocol + MainThreadOnly
275 {
276 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
277 #[optional]
278 #[unsafe(method(pageViewController:willTransitionToViewControllers:))]
279 #[unsafe(method_family = none)]
280 unsafe fn pageViewController_willTransitionToViewControllers(
281 &self,
282 page_view_controller: &UIPageViewController,
283 pending_view_controllers: &NSArray<UIViewController>,
284 );
285
286 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
287 #[optional]
288 #[unsafe(method(pageViewController:didFinishAnimating:previousViewControllers:transitionCompleted:))]
289 #[unsafe(method_family = none)]
290 unsafe fn pageViewController_didFinishAnimating_previousViewControllers_transitionCompleted(
291 &self,
292 page_view_controller: &UIPageViewController,
293 finished: bool,
294 previous_view_controllers: &NSArray<UIViewController>,
295 completed: bool,
296 );
297
298 #[cfg(all(
299 feature = "UIOrientation",
300 feature = "UIResponder",
301 feature = "UIViewController"
302 ))]
303 #[optional]
304 #[unsafe(method(pageViewController:spineLocationForInterfaceOrientation:))]
305 #[unsafe(method_family = none)]
306 unsafe fn pageViewController_spineLocationForInterfaceOrientation(
307 &self,
308 page_view_controller: &UIPageViewController,
309 orientation: UIInterfaceOrientation,
310 ) -> UIPageViewControllerSpineLocation;
311
312 #[cfg(all(
313 feature = "UIOrientation",
314 feature = "UIResponder",
315 feature = "UIViewController"
316 ))]
317 #[optional]
318 #[unsafe(method(pageViewControllerSupportedInterfaceOrientations:))]
319 #[unsafe(method_family = none)]
320 unsafe fn pageViewControllerSupportedInterfaceOrientations(
321 &self,
322 page_view_controller: &UIPageViewController,
323 ) -> UIInterfaceOrientationMask;
324
325 #[cfg(all(
326 feature = "UIOrientation",
327 feature = "UIResponder",
328 feature = "UIViewController"
329 ))]
330 #[optional]
331 #[unsafe(method(pageViewControllerPreferredInterfaceOrientationForPresentation:))]
332 #[unsafe(method_family = none)]
333 unsafe fn pageViewControllerPreferredInterfaceOrientationForPresentation(
334 &self,
335 page_view_controller: &UIPageViewController,
336 ) -> UIInterfaceOrientation;
337 }
338);
339
340extern_protocol!(
341 pub unsafe trait UIPageViewControllerDataSource:
343 NSObjectProtocol + MainThreadOnly
344 {
345 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
346 #[unsafe(method(pageViewController:viewControllerBeforeViewController:))]
347 #[unsafe(method_family = none)]
348 unsafe fn pageViewController_viewControllerBeforeViewController(
349 &self,
350 page_view_controller: &UIPageViewController,
351 view_controller: &UIViewController,
352 ) -> Option<Retained<UIViewController>>;
353
354 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
355 #[unsafe(method(pageViewController:viewControllerAfterViewController:))]
356 #[unsafe(method_family = none)]
357 unsafe fn pageViewController_viewControllerAfterViewController(
358 &self,
359 page_view_controller: &UIPageViewController,
360 view_controller: &UIViewController,
361 ) -> Option<Retained<UIViewController>>;
362
363 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
364 #[optional]
365 #[unsafe(method(presentationCountForPageViewController:))]
366 #[unsafe(method_family = none)]
367 unsafe fn presentationCountForPageViewController(
368 &self,
369 page_view_controller: &UIPageViewController,
370 ) -> NSInteger;
371
372 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
373 #[optional]
374 #[unsafe(method(presentationIndexForPageViewController:))]
375 #[unsafe(method_family = none)]
376 unsafe fn presentationIndexForPageViewController(
377 &self,
378 page_view_controller: &UIPageViewController,
379 ) -> NSInteger;
380 }
381);