1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9#[cfg(feature = "objc2-uniform-type-identifiers")]
10use objc2_uniform_type_identifiers::*;
11
12use crate::*;
13
14extern "C" {
15 pub static UIDocumentBrowserErrorDomain: &'static NSErrorDomain;
17}
18
19#[repr(transparent)]
22#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
23pub struct UIDocumentBrowserErrorCode(pub NSInteger);
24impl UIDocumentBrowserErrorCode {
25 #[doc(alias = "UIDocumentBrowserErrorGeneric")]
26 pub const Generic: Self = Self(1);
27 #[doc(alias = "UIDocumentBrowserErrorNoLocationAvailable")]
28 pub const NoLocationAvailable: Self = Self(2);
29}
30
31unsafe impl Encode for UIDocumentBrowserErrorCode {
32 const ENCODING: Encoding = NSInteger::ENCODING;
33}
34
35unsafe impl RefEncode for UIDocumentBrowserErrorCode {
36 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
37}
38
39#[repr(transparent)]
42#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
43pub struct UIDocumentBrowserImportMode(pub NSUInteger);
44impl UIDocumentBrowserImportMode {
45 #[doc(alias = "UIDocumentBrowserImportModeNone")]
46 pub const None: Self = Self(0);
47 #[doc(alias = "UIDocumentBrowserImportModeCopy")]
48 pub const Copy: Self = Self(1);
49 #[doc(alias = "UIDocumentBrowserImportModeMove")]
50 pub const Move: Self = Self(2);
51}
52
53unsafe impl Encode for UIDocumentBrowserImportMode {
54 const ENCODING: Encoding = NSUInteger::ENCODING;
55}
56
57unsafe impl RefEncode for UIDocumentBrowserImportMode {
58 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
59}
60
61#[repr(transparent)]
64#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
65pub struct UIDocumentBrowserUserInterfaceStyle(pub NSUInteger);
66impl UIDocumentBrowserUserInterfaceStyle {
67 #[doc(alias = "UIDocumentBrowserUserInterfaceStyleWhite")]
68 pub const White: Self = Self(0);
69 #[doc(alias = "UIDocumentBrowserUserInterfaceStyleLight")]
70 pub const Light: Self = Self(1);
71 #[doc(alias = "UIDocumentBrowserUserInterfaceStyleDark")]
72 pub const Dark: Self = Self(2);
73}
74
75unsafe impl Encode for UIDocumentBrowserUserInterfaceStyle {
76 const ENCODING: Encoding = NSUInteger::ENCODING;
77}
78
79unsafe impl RefEncode for UIDocumentBrowserUserInterfaceStyle {
80 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
81}
82
83extern_class!(
84 #[unsafe(super(UIViewController, UIResponder, NSObject))]
88 #[derive(Debug, PartialEq, Eq, Hash)]
89 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
90 pub struct UIDocumentBrowserViewController;
91);
92
93#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
94extern_conformance!(
95 unsafe impl NSCoding for UIDocumentBrowserViewController {}
96);
97
98#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
99extern_conformance!(
100 unsafe impl NSObjectProtocol for UIDocumentBrowserViewController {}
101);
102
103#[cfg(all(
104 feature = "UIAppearance",
105 feature = "UIResponder",
106 feature = "UIViewController"
107))]
108extern_conformance!(
109 unsafe impl UIAppearanceContainer for UIDocumentBrowserViewController {}
110);
111
112#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
113extern_conformance!(
114 unsafe impl UIContentContainer for UIDocumentBrowserViewController {}
115);
116
117#[cfg(all(
118 feature = "UIFocus",
119 feature = "UIResponder",
120 feature = "UIViewController"
121))]
122extern_conformance!(
123 unsafe impl UIFocusEnvironment for UIDocumentBrowserViewController {}
124);
125
126#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
127extern_conformance!(
128 unsafe impl UIResponderStandardEditActions for UIDocumentBrowserViewController {}
129);
130
131#[cfg(all(
132 feature = "UIResponder",
133 feature = "UITraitCollection",
134 feature = "UIViewController"
135))]
136extern_conformance!(
137 unsafe impl UITraitEnvironment for UIDocumentBrowserViewController {}
138);
139
140#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
141impl UIDocumentBrowserViewController {
142 extern_methods!(
143 #[deprecated]
145 #[unsafe(method(initForOpeningFilesWithContentTypes:))]
146 #[unsafe(method_family = init)]
147 pub fn initForOpeningFilesWithContentTypes(
148 this: Allocated<Self>,
149 allowed_content_types: Option<&NSArray<NSString>>,
150 ) -> Retained<Self>;
151
152 #[cfg(feature = "objc2-uniform-type-identifiers")]
153 #[unsafe(method(initForOpeningContentTypes:))]
155 #[unsafe(method_family = init)]
156 pub fn initForOpeningContentTypes(
157 this: Allocated<Self>,
158 content_types: Option<&NSArray<UTType>>,
159 ) -> Retained<Self>;
160
161 #[unsafe(method(initWithNibName:bundle:))]
163 #[unsafe(method_family = init)]
164 pub unsafe fn initWithNibName_bundle(
165 this: Allocated<Self>,
166 nib_name: Option<&NSString>,
167 bundle: Option<&NSBundle>,
168 ) -> Retained<Self>;
169
170 #[unsafe(method(delegate))]
171 #[unsafe(method_family = none)]
172 pub fn delegate(
173 &self,
174 ) -> Option<Retained<ProtocolObject<dyn UIDocumentBrowserViewControllerDelegate>>>;
175
176 #[unsafe(method(setDelegate:))]
180 #[unsafe(method_family = none)]
181 pub fn setDelegate(
182 &self,
183 delegate: Option<&ProtocolObject<dyn UIDocumentBrowserViewControllerDelegate>>,
184 );
185
186 #[unsafe(method(allowsDocumentCreation))]
188 #[unsafe(method_family = none)]
189 pub fn allowsDocumentCreation(&self) -> bool;
190
191 #[unsafe(method(setAllowsDocumentCreation:))]
193 #[unsafe(method_family = none)]
194 pub fn setAllowsDocumentCreation(&self, allows_document_creation: bool);
195
196 #[cfg(feature = "UIDocument")]
197 #[unsafe(method(activeDocumentCreationIntent))]
199 #[unsafe(method_family = none)]
200 pub fn activeDocumentCreationIntent(&self) -> Option<Retained<UIDocumentCreationIntent>>;
201
202 #[unsafe(method(allowsPickingMultipleItems))]
204 #[unsafe(method_family = none)]
205 pub fn allowsPickingMultipleItems(&self) -> bool;
206
207 #[unsafe(method(setAllowsPickingMultipleItems:))]
209 #[unsafe(method_family = none)]
210 pub fn setAllowsPickingMultipleItems(&self, allows_picking_multiple_items: bool);
211
212 #[deprecated = "allowedContentTypes is no longer supported"]
213 #[unsafe(method(allowedContentTypes))]
214 #[unsafe(method_family = none)]
215 pub fn allowedContentTypes(&self) -> Retained<NSArray<NSString>>;
216
217 #[deprecated]
222 #[unsafe(method(recentDocumentsContentTypes))]
223 #[unsafe(method_family = none)]
224 pub fn recentDocumentsContentTypes(&self) -> Retained<NSArray<NSString>>;
225
226 #[cfg(feature = "objc2-uniform-type-identifiers")]
227 #[unsafe(method(contentTypesForRecentDocuments))]
232 #[unsafe(method_family = none)]
233 pub fn contentTypesForRecentDocuments(&self) -> Retained<NSArray<UTType>>;
234
235 #[unsafe(method(shouldShowFileExtensions))]
237 #[unsafe(method_family = none)]
238 pub fn shouldShowFileExtensions(&self) -> bool;
239
240 #[unsafe(method(setShouldShowFileExtensions:))]
242 #[unsafe(method_family = none)]
243 pub fn setShouldShowFileExtensions(&self, should_show_file_extensions: bool);
244
245 #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
246 #[unsafe(method(additionalLeadingNavigationBarButtonItems))]
248 #[unsafe(method_family = none)]
249 pub fn additionalLeadingNavigationBarButtonItems(
250 &self,
251 ) -> Retained<NSArray<UIBarButtonItem>>;
252
253 #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
254 #[unsafe(method(setAdditionalLeadingNavigationBarButtonItems:))]
256 #[unsafe(method_family = none)]
257 pub fn setAdditionalLeadingNavigationBarButtonItems(
258 &self,
259 additional_leading_navigation_bar_button_items: &NSArray<UIBarButtonItem>,
260 );
261
262 #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
263 #[unsafe(method(additionalTrailingNavigationBarButtonItems))]
265 #[unsafe(method_family = none)]
266 pub fn additionalTrailingNavigationBarButtonItems(
267 &self,
268 ) -> Retained<NSArray<UIBarButtonItem>>;
269
270 #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
271 #[unsafe(method(setAdditionalTrailingNavigationBarButtonItems:))]
273 #[unsafe(method_family = none)]
274 pub fn setAdditionalTrailingNavigationBarButtonItems(
275 &self,
276 additional_trailing_navigation_bar_button_items: &NSArray<UIBarButtonItem>,
277 );
278
279 #[cfg(feature = "block2")]
280 #[unsafe(method(revealDocumentAtURL:importIfNeeded:completion:))]
283 #[unsafe(method_family = none)]
284 pub fn revealDocumentAtURL_importIfNeeded_completion(
285 &self,
286 url: &NSURL,
287 import_if_needed: bool,
288 completion: Option<&block2::DynBlock<dyn Fn(*mut NSURL, *mut NSError)>>,
289 );
290
291 #[cfg(feature = "block2")]
292 #[unsafe(method(importDocumentAtURL:nextToDocumentAtURL:mode:completionHandler:))]
294 #[unsafe(method_family = none)]
295 pub fn importDocumentAtURL_nextToDocumentAtURL_mode_completionHandler(
296 &self,
297 document_url: &NSURL,
298 neighbour_url: &NSURL,
299 import_mode: UIDocumentBrowserImportMode,
300 completion: &block2::DynBlock<dyn Fn(*mut NSURL, *mut NSError)>,
301 );
302
303 #[cfg(feature = "block2")]
304 #[unsafe(method(renameDocumentAtURL:proposedName:completionHandler:))]
308 #[unsafe(method_family = none)]
309 pub fn renameDocumentAtURL_proposedName_completionHandler(
310 &self,
311 document_url: &NSURL,
312 proposed_name: &NSString,
313 completion_handler: &block2::DynBlock<dyn Fn(*mut NSURL, *mut NSError)>,
314 );
315
316 #[unsafe(method(transitionControllerForDocumentAtURL:))]
318 #[unsafe(method_family = none)]
319 pub fn transitionControllerForDocumentAtURL(
320 &self,
321 document_url: &NSURL,
322 ) -> Retained<UIDocumentBrowserTransitionController>;
323
324 #[deprecated]
325 #[unsafe(method(transitionControllerForDocumentURL:))]
326 #[unsafe(method_family = none)]
327 pub fn transitionControllerForDocumentURL(
328 &self,
329 document_url: &NSURL,
330 ) -> Retained<UIDocumentBrowserTransitionController>;
331
332 #[cfg(feature = "UIDocumentBrowserAction")]
333 #[unsafe(method(customActions))]
335 #[unsafe(method_family = none)]
336 pub fn customActions(&self) -> Retained<NSArray<UIDocumentBrowserAction>>;
337
338 #[cfg(feature = "UIDocumentBrowserAction")]
339 #[unsafe(method(setCustomActions:))]
343 #[unsafe(method_family = none)]
344 pub fn setCustomActions(&self, custom_actions: &NSArray<UIDocumentBrowserAction>);
345
346 #[unsafe(method(browserUserInterfaceStyle))]
348 #[unsafe(method_family = none)]
349 pub fn browserUserInterfaceStyle(&self) -> UIDocumentBrowserUserInterfaceStyle;
350
351 #[unsafe(method(setBrowserUserInterfaceStyle:))]
353 #[unsafe(method_family = none)]
354 pub fn setBrowserUserInterfaceStyle(
355 &self,
356 browser_user_interface_style: UIDocumentBrowserUserInterfaceStyle,
357 );
358
359 #[unsafe(method(localizedCreateDocumentActionTitle))]
361 #[unsafe(method_family = none)]
362 pub fn localizedCreateDocumentActionTitle(&self) -> Retained<NSString>;
363
364 #[unsafe(method(setLocalizedCreateDocumentActionTitle:))]
368 #[unsafe(method_family = none)]
369 pub fn setLocalizedCreateDocumentActionTitle(
370 &self,
371 localized_create_document_action_title: &NSString,
372 );
373
374 #[cfg(feature = "objc2-core-foundation")]
375 #[unsafe(method(defaultDocumentAspectRatio))]
377 #[unsafe(method_family = none)]
378 pub fn defaultDocumentAspectRatio(&self) -> CGFloat;
379
380 #[cfg(feature = "objc2-core-foundation")]
381 #[unsafe(method(setDefaultDocumentAspectRatio:))]
383 #[unsafe(method_family = none)]
384 pub fn setDefaultDocumentAspectRatio(&self, default_document_aspect_ratio: CGFloat);
385 );
386}
387
388#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
390impl UIDocumentBrowserViewController {
391 extern_methods!(
392 #[unsafe(method(initWithCoder:))]
396 #[unsafe(method_family = init)]
397 pub unsafe fn initWithCoder(
398 this: Allocated<Self>,
399 coder: &NSCoder,
400 ) -> Option<Retained<Self>>;
401 );
402}
403
404#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
406impl UIDocumentBrowserViewController {
407 extern_methods!(
408 #[unsafe(method(init))]
409 #[unsafe(method_family = init)]
410 pub fn init(this: Allocated<Self>) -> Retained<Self>;
411
412 #[unsafe(method(new))]
413 #[unsafe(method_family = new)]
414 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
415 );
416}
417
418extern_protocol!(
419 pub unsafe trait UIDocumentBrowserViewControllerDelegate: NSObjectProtocol {
421 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
422 #[deprecated]
426 #[optional]
427 #[unsafe(method(documentBrowser:didPickDocumentURLs:))]
428 #[unsafe(method_family = none)]
429 fn documentBrowser_didPickDocumentURLs(
430 &self,
431 controller: &UIDocumentBrowserViewController,
432 document_ur_ls: &NSArray<NSURL>,
433 );
434
435 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
436 #[optional]
437 #[unsafe(method(documentBrowser:didPickDocumentsAtURLs:))]
438 #[unsafe(method_family = none)]
439 fn documentBrowser_didPickDocumentsAtURLs(
440 &self,
441 controller: &UIDocumentBrowserViewController,
442 document_ur_ls: &NSArray<NSURL>,
443 );
444
445 #[cfg(all(
446 feature = "UIResponder",
447 feature = "UIViewController",
448 feature = "block2"
449 ))]
450 #[optional]
461 #[unsafe(method(documentBrowser:didRequestDocumentCreationWithHandler:))]
462 #[unsafe(method_family = none)]
463 fn documentBrowser_didRequestDocumentCreationWithHandler(
464 &self,
465 controller: &UIDocumentBrowserViewController,
466 import_handler: &block2::DynBlock<dyn Fn(*mut NSURL, UIDocumentBrowserImportMode)>,
467 );
468
469 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
470 #[optional]
471 #[unsafe(method(documentBrowser:didImportDocumentAtURL:toDestinationURL:))]
472 #[unsafe(method_family = none)]
473 fn documentBrowser_didImportDocumentAtURL_toDestinationURL(
474 &self,
475 controller: &UIDocumentBrowserViewController,
476 source_url: &NSURL,
477 destination_url: &NSURL,
478 );
479
480 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
481 #[optional]
482 #[unsafe(method(documentBrowser:failedToImportDocumentAtURL:error:))]
483 #[unsafe(method_family = none)]
484 fn documentBrowser_failedToImportDocumentAtURL_error(
485 &self,
486 controller: &UIDocumentBrowserViewController,
487 document_url: &NSURL,
488 error: Option<&NSError>,
489 );
490
491 #[cfg(all(
492 feature = "UIActivity",
493 feature = "UIResponder",
494 feature = "UIViewController"
495 ))]
496 #[optional]
498 #[unsafe(method(documentBrowser:applicationActivitiesForDocumentURLs:))]
499 #[unsafe(method_family = none)]
500 fn documentBrowser_applicationActivitiesForDocumentURLs(
501 &self,
502 controller: &UIDocumentBrowserViewController,
503 document_ur_ls: &NSArray<NSURL>,
504 ) -> Retained<NSArray<UIActivity>>;
505
506 #[cfg(all(
507 feature = "UIActivityViewController",
508 feature = "UIResponder",
509 feature = "UIViewController"
510 ))]
511 #[optional]
513 #[unsafe(method(documentBrowser:willPresentActivityViewController:))]
514 #[unsafe(method_family = none)]
515 fn documentBrowser_willPresentActivityViewController(
516 &self,
517 controller: &UIDocumentBrowserViewController,
518 activity_view_controller: &UIActivityViewController,
519 );
520 }
521);
522
523extern_class!(
524 #[unsafe(super(NSObject))]
532 #[thread_kind = MainThreadOnly]
533 #[derive(Debug, PartialEq, Eq, Hash)]
534 pub struct UIDocumentBrowserTransitionController;
535);
536
537extern_conformance!(
538 unsafe impl NSObjectProtocol for UIDocumentBrowserTransitionController {}
539);
540
541#[cfg(feature = "UIViewControllerTransitioning")]
542extern_conformance!(
543 unsafe impl UIViewControllerAnimatedTransitioning for UIDocumentBrowserTransitionController {}
544);
545
546impl UIDocumentBrowserTransitionController {
547 extern_methods!(
548 #[unsafe(method(init))]
549 #[unsafe(method_family = init)]
550 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
551
552 #[unsafe(method(loadingProgress))]
554 #[unsafe(method_family = none)]
555 pub fn loadingProgress(&self) -> Option<Retained<NSProgress>>;
556
557 #[unsafe(method(setLoadingProgress:))]
559 #[unsafe(method_family = none)]
560 pub fn setLoadingProgress(&self, loading_progress: Option<&NSProgress>);
561
562 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
563 #[unsafe(method(targetView))]
567 #[unsafe(method_family = none)]
568 pub fn targetView(&self) -> Option<Retained<UIView>>;
569
570 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
571 #[unsafe(method(setTargetView:))]
575 #[unsafe(method_family = none)]
576 pub fn setTargetView(&self, target_view: Option<&UIView>);
577 );
578}
579
580impl UIDocumentBrowserTransitionController {
582 extern_methods!(
583 #[unsafe(method(new))]
584 #[unsafe(method_family = new)]
585 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
586 );
587}