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"))]
119extern_conformance!(
120 unsafe impl NSCoding for UIPageViewController {}
121);
122
123#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
124extern_conformance!(
125 unsafe impl NSObjectProtocol for UIPageViewController {}
126);
127
128#[cfg(all(
129 feature = "UIAppearance",
130 feature = "UIResponder",
131 feature = "UIViewController"
132))]
133extern_conformance!(
134 unsafe impl UIAppearanceContainer for UIPageViewController {}
135);
136
137#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
138extern_conformance!(
139 unsafe impl UIContentContainer for UIPageViewController {}
140);
141
142#[cfg(all(
143 feature = "UIFocus",
144 feature = "UIResponder",
145 feature = "UIViewController"
146))]
147extern_conformance!(
148 unsafe impl UIFocusEnvironment for UIPageViewController {}
149);
150
151#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
152extern_conformance!(
153 unsafe impl UIResponderStandardEditActions for UIPageViewController {}
154);
155
156#[cfg(all(
157 feature = "UIResponder",
158 feature = "UITraitCollection",
159 feature = "UIViewController"
160))]
161extern_conformance!(
162 unsafe impl UITraitEnvironment for UIPageViewController {}
163);
164
165#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
166impl UIPageViewController {
167 extern_methods!(
168 #[unsafe(method(initWithTransitionStyle:navigationOrientation:options:))]
169 #[unsafe(method_family = init)]
170 pub unsafe fn initWithTransitionStyle_navigationOrientation_options(
171 this: Allocated<Self>,
172 style: UIPageViewControllerTransitionStyle,
173 navigation_orientation: UIPageViewControllerNavigationOrientation,
174 options: Option<&NSDictionary<UIPageViewControllerOptionsKey, AnyObject>>,
175 ) -> Retained<Self>;
176
177 #[unsafe(method(initWithCoder:))]
178 #[unsafe(method_family = init)]
179 pub unsafe fn initWithCoder(
180 this: Allocated<Self>,
181 coder: &NSCoder,
182 ) -> Option<Retained<Self>>;
183
184 #[unsafe(method(delegate))]
185 #[unsafe(method_family = none)]
186 pub unsafe fn delegate(
187 &self,
188 ) -> Option<Retained<ProtocolObject<dyn UIPageViewControllerDelegate>>>;
189
190 #[unsafe(method(setDelegate:))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn setDelegate(
195 &self,
196 delegate: Option<&ProtocolObject<dyn UIPageViewControllerDelegate>>,
197 );
198
199 #[unsafe(method(dataSource))]
200 #[unsafe(method_family = none)]
201 pub unsafe fn dataSource(
202 &self,
203 ) -> Option<Retained<ProtocolObject<dyn UIPageViewControllerDataSource>>>;
204
205 #[unsafe(method(setDataSource:))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn setDataSource(
210 &self,
211 data_source: Option<&ProtocolObject<dyn UIPageViewControllerDataSource>>,
212 );
213
214 #[unsafe(method(transitionStyle))]
215 #[unsafe(method_family = none)]
216 pub unsafe fn transitionStyle(&self) -> UIPageViewControllerTransitionStyle;
217
218 #[unsafe(method(navigationOrientation))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn navigationOrientation(&self) -> UIPageViewControllerNavigationOrientation;
221
222 #[unsafe(method(spineLocation))]
223 #[unsafe(method_family = none)]
224 pub unsafe fn spineLocation(&self) -> UIPageViewControllerSpineLocation;
225
226 #[unsafe(method(isDoubleSided))]
227 #[unsafe(method_family = none)]
228 pub unsafe fn isDoubleSided(&self) -> bool;
229
230 #[unsafe(method(setDoubleSided:))]
232 #[unsafe(method_family = none)]
233 pub unsafe fn setDoubleSided(&self, double_sided: bool);
234
235 #[cfg(feature = "UIGestureRecognizer")]
236 #[unsafe(method(gestureRecognizers))]
237 #[unsafe(method_family = none)]
238 pub unsafe fn gestureRecognizers(&self) -> Retained<NSArray<UIGestureRecognizer>>;
239
240 #[unsafe(method(viewControllers))]
241 #[unsafe(method_family = none)]
242 pub unsafe fn viewControllers(&self) -> Option<Retained<NSArray<UIViewController>>>;
243
244 #[cfg(feature = "block2")]
245 #[unsafe(method(setViewControllers:direction:animated:completion:))]
246 #[unsafe(method_family = none)]
247 pub unsafe fn setViewControllers_direction_animated_completion(
248 &self,
249 view_controllers: Option<&NSArray<UIViewController>>,
250 direction: UIPageViewControllerNavigationDirection,
251 animated: bool,
252 completion: Option<&block2::DynBlock<dyn Fn(Bool)>>,
253 );
254 );
255}
256
257#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
259impl UIPageViewController {
260 extern_methods!(
261 #[unsafe(method(initWithNibName:bundle:))]
262 #[unsafe(method_family = init)]
263 pub unsafe fn initWithNibName_bundle(
264 this: Allocated<Self>,
265 nib_name_or_nil: Option<&NSString>,
266 nib_bundle_or_nil: Option<&NSBundle>,
267 ) -> Retained<Self>;
268 );
269}
270
271#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
273impl UIPageViewController {
274 extern_methods!(
275 #[unsafe(method(init))]
276 #[unsafe(method_family = init)]
277 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
278
279 #[unsafe(method(new))]
280 #[unsafe(method_family = new)]
281 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
282 );
283}
284
285extern_protocol!(
286 pub unsafe trait UIPageViewControllerDelegate:
288 NSObjectProtocol + MainThreadOnly
289 {
290 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
291 #[optional]
292 #[unsafe(method(pageViewController:willTransitionToViewControllers:))]
293 #[unsafe(method_family = none)]
294 unsafe fn pageViewController_willTransitionToViewControllers(
295 &self,
296 page_view_controller: &UIPageViewController,
297 pending_view_controllers: &NSArray<UIViewController>,
298 );
299
300 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
301 #[optional]
302 #[unsafe(method(pageViewController:didFinishAnimating:previousViewControllers:transitionCompleted:))]
303 #[unsafe(method_family = none)]
304 unsafe fn pageViewController_didFinishAnimating_previousViewControllers_transitionCompleted(
305 &self,
306 page_view_controller: &UIPageViewController,
307 finished: bool,
308 previous_view_controllers: &NSArray<UIViewController>,
309 completed: bool,
310 );
311
312 #[cfg(all(
313 feature = "UIOrientation",
314 feature = "UIResponder",
315 feature = "UIViewController"
316 ))]
317 #[optional]
318 #[unsafe(method(pageViewController:spineLocationForInterfaceOrientation:))]
319 #[unsafe(method_family = none)]
320 unsafe fn pageViewController_spineLocationForInterfaceOrientation(
321 &self,
322 page_view_controller: &UIPageViewController,
323 orientation: UIInterfaceOrientation,
324 ) -> UIPageViewControllerSpineLocation;
325
326 #[cfg(all(
327 feature = "UIOrientation",
328 feature = "UIResponder",
329 feature = "UIViewController"
330 ))]
331 #[optional]
332 #[unsafe(method(pageViewControllerSupportedInterfaceOrientations:))]
333 #[unsafe(method_family = none)]
334 unsafe fn pageViewControllerSupportedInterfaceOrientations(
335 &self,
336 page_view_controller: &UIPageViewController,
337 ) -> UIInterfaceOrientationMask;
338
339 #[cfg(all(
340 feature = "UIOrientation",
341 feature = "UIResponder",
342 feature = "UIViewController"
343 ))]
344 #[optional]
345 #[unsafe(method(pageViewControllerPreferredInterfaceOrientationForPresentation:))]
346 #[unsafe(method_family = none)]
347 unsafe fn pageViewControllerPreferredInterfaceOrientationForPresentation(
348 &self,
349 page_view_controller: &UIPageViewController,
350 ) -> UIInterfaceOrientation;
351 }
352);
353
354extern_protocol!(
355 pub unsafe trait UIPageViewControllerDataSource:
357 NSObjectProtocol + MainThreadOnly
358 {
359 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
360 #[unsafe(method(pageViewController:viewControllerBeforeViewController:))]
361 #[unsafe(method_family = none)]
362 unsafe fn pageViewController_viewControllerBeforeViewController(
363 &self,
364 page_view_controller: &UIPageViewController,
365 view_controller: &UIViewController,
366 ) -> Option<Retained<UIViewController>>;
367
368 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
369 #[unsafe(method(pageViewController:viewControllerAfterViewController:))]
370 #[unsafe(method_family = none)]
371 unsafe fn pageViewController_viewControllerAfterViewController(
372 &self,
373 page_view_controller: &UIPageViewController,
374 view_controller: &UIViewController,
375 ) -> Option<Retained<UIViewController>>;
376
377 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
378 #[optional]
379 #[unsafe(method(presentationCountForPageViewController:))]
380 #[unsafe(method_family = none)]
381 unsafe fn presentationCountForPageViewController(
382 &self,
383 page_view_controller: &UIPageViewController,
384 ) -> NSInteger;
385
386 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
387 #[optional]
388 #[unsafe(method(presentationIndexForPageViewController:))]
389 #[unsafe(method_family = none)]
390 unsafe fn presentationIndexForPageViewController(
391 &self,
392 page_view_controller: &UIPageViewController,
393 ) -> NSInteger;
394 }
395);