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
10use crate::*;
11
12#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct UIImagePickerControllerSourceType(pub NSInteger);
17impl UIImagePickerControllerSourceType {
18 #[doc(alias = "UIImagePickerControllerSourceTypePhotoLibrary")]
19 #[deprecated = "Will be removed in a future release, use PHPicker."]
20 pub const PhotoLibrary: Self = Self(0);
21 #[doc(alias = "UIImagePickerControllerSourceTypeCamera")]
22 pub const Camera: Self = Self(1);
23 #[doc(alias = "UIImagePickerControllerSourceTypeSavedPhotosAlbum")]
24 #[deprecated = "Will be removed in a future release, use PHPicker."]
25 pub const SavedPhotosAlbum: Self = Self(2);
26}
27
28unsafe impl Encode for UIImagePickerControllerSourceType {
29 const ENCODING: Encoding = NSInteger::ENCODING;
30}
31
32unsafe impl RefEncode for UIImagePickerControllerSourceType {
33 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36#[repr(transparent)]
39#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
40pub struct UIImagePickerControllerQualityType(pub NSInteger);
41impl UIImagePickerControllerQualityType {
42 #[doc(alias = "UIImagePickerControllerQualityTypeHigh")]
43 pub const TypeHigh: Self = Self(0);
44 #[doc(alias = "UIImagePickerControllerQualityTypeMedium")]
45 pub const TypeMedium: Self = Self(1);
46 #[doc(alias = "UIImagePickerControllerQualityTypeLow")]
47 pub const TypeLow: Self = Self(2);
48 #[doc(alias = "UIImagePickerControllerQualityType640x480")]
49 pub const Type640x480: Self = Self(3);
50 #[doc(alias = "UIImagePickerControllerQualityTypeIFrame1280x720")]
51 pub const TypeIFrame1280x720: Self = Self(4);
52 #[doc(alias = "UIImagePickerControllerQualityTypeIFrame960x540")]
53 pub const TypeIFrame960x540: Self = Self(5);
54}
55
56unsafe impl Encode for UIImagePickerControllerQualityType {
57 const ENCODING: Encoding = NSInteger::ENCODING;
58}
59
60unsafe impl RefEncode for UIImagePickerControllerQualityType {
61 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64#[repr(transparent)]
67#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
68pub struct UIImagePickerControllerCameraCaptureMode(pub NSInteger);
69impl UIImagePickerControllerCameraCaptureMode {
70 #[doc(alias = "UIImagePickerControllerCameraCaptureModePhoto")]
71 pub const Photo: Self = Self(0);
72 #[doc(alias = "UIImagePickerControllerCameraCaptureModeVideo")]
73 pub const Video: Self = Self(1);
74}
75
76unsafe impl Encode for UIImagePickerControllerCameraCaptureMode {
77 const ENCODING: Encoding = NSInteger::ENCODING;
78}
79
80unsafe impl RefEncode for UIImagePickerControllerCameraCaptureMode {
81 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
82}
83
84#[repr(transparent)]
87#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
88pub struct UIImagePickerControllerCameraDevice(pub NSInteger);
89impl UIImagePickerControllerCameraDevice {
90 #[doc(alias = "UIImagePickerControllerCameraDeviceRear")]
91 pub const Rear: Self = Self(0);
92 #[doc(alias = "UIImagePickerControllerCameraDeviceFront")]
93 pub const Front: Self = Self(1);
94}
95
96unsafe impl Encode for UIImagePickerControllerCameraDevice {
97 const ENCODING: Encoding = NSInteger::ENCODING;
98}
99
100unsafe impl RefEncode for UIImagePickerControllerCameraDevice {
101 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
102}
103
104#[repr(transparent)]
107#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
108pub struct UIImagePickerControllerCameraFlashMode(pub NSInteger);
109impl UIImagePickerControllerCameraFlashMode {
110 #[doc(alias = "UIImagePickerControllerCameraFlashModeOff")]
111 pub const Off: Self = Self(-1);
112 #[doc(alias = "UIImagePickerControllerCameraFlashModeAuto")]
113 pub const Auto: Self = Self(0);
114 #[doc(alias = "UIImagePickerControllerCameraFlashModeOn")]
115 pub const On: Self = Self(1);
116}
117
118unsafe impl Encode for UIImagePickerControllerCameraFlashMode {
119 const ENCODING: Encoding = NSInteger::ENCODING;
120}
121
122unsafe impl RefEncode for UIImagePickerControllerCameraFlashMode {
123 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
124}
125
126#[deprecated = "Will be removed in a future release, use PHPicker."]
129#[repr(transparent)]
130#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
131pub struct UIImagePickerControllerImageURLExportPreset(pub NSInteger);
132impl UIImagePickerControllerImageURLExportPreset {
133 #[doc(alias = "UIImagePickerControllerImageURLExportPresetCompatible")]
134 #[deprecated = "Will be removed in a future release, use PHPicker."]
135 pub const Compatible: Self = Self(0);
136 #[doc(alias = "UIImagePickerControllerImageURLExportPresetCurrent")]
137 #[deprecated = "Will be removed in a future release, use PHPicker."]
138 pub const Current: Self = Self(1);
139}
140
141unsafe impl Encode for UIImagePickerControllerImageURLExportPreset {
142 const ENCODING: Encoding = NSInteger::ENCODING;
143}
144
145unsafe impl RefEncode for UIImagePickerControllerImageURLExportPreset {
146 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
147}
148
149pub type UIImagePickerControllerInfoKey = NSString;
152
153extern "C" {
154 pub static UIImagePickerControllerMediaType: &'static UIImagePickerControllerInfoKey;
156}
157
158extern "C" {
159 pub static UIImagePickerControllerOriginalImage: &'static UIImagePickerControllerInfoKey;
161}
162
163extern "C" {
164 pub static UIImagePickerControllerEditedImage: &'static UIImagePickerControllerInfoKey;
166}
167
168extern "C" {
169 pub static UIImagePickerControllerCropRect: &'static UIImagePickerControllerInfoKey;
171}
172
173extern "C" {
174 pub static UIImagePickerControllerMediaURL: &'static UIImagePickerControllerInfoKey;
176}
177
178extern "C" {
179 pub static UIImagePickerControllerReferenceURL: &'static UIImagePickerControllerInfoKey;
181}
182
183extern "C" {
184 pub static UIImagePickerControllerMediaMetadata: &'static UIImagePickerControllerInfoKey;
186}
187
188extern "C" {
189 pub static UIImagePickerControllerLivePhoto: &'static UIImagePickerControllerInfoKey;
191}
192
193extern "C" {
194 pub static UIImagePickerControllerPHAsset: &'static UIImagePickerControllerInfoKey;
196}
197
198extern "C" {
199 pub static UIImagePickerControllerImageURL: &'static UIImagePickerControllerInfoKey;
201}
202
203extern_class!(
204 #[unsafe(super(UINavigationController, UIViewController, UIResponder, NSObject))]
206 #[thread_kind = MainThreadOnly]
207 #[derive(Debug, PartialEq, Eq, Hash)]
208 #[cfg(all(
209 feature = "UINavigationController",
210 feature = "UIResponder",
211 feature = "UIViewController"
212 ))]
213 pub struct UIImagePickerController;
214);
215
216#[cfg(all(
217 feature = "UINavigationController",
218 feature = "UIResponder",
219 feature = "UIViewController"
220))]
221extern_conformance!(
222 unsafe impl NSCoding for UIImagePickerController {}
223);
224
225#[cfg(all(
226 feature = "UINavigationController",
227 feature = "UIResponder",
228 feature = "UIViewController"
229))]
230extern_conformance!(
231 unsafe impl NSObjectProtocol for UIImagePickerController {}
232);
233
234#[cfg(all(
235 feature = "UIAppearance",
236 feature = "UINavigationController",
237 feature = "UIResponder",
238 feature = "UIViewController"
239))]
240extern_conformance!(
241 unsafe impl UIAppearanceContainer for UIImagePickerController {}
242);
243
244#[cfg(all(
245 feature = "UINavigationController",
246 feature = "UIResponder",
247 feature = "UIViewController"
248))]
249extern_conformance!(
250 unsafe impl UIContentContainer for UIImagePickerController {}
251);
252
253#[cfg(all(
254 feature = "UIFocus",
255 feature = "UINavigationController",
256 feature = "UIResponder",
257 feature = "UIViewController"
258))]
259extern_conformance!(
260 unsafe impl UIFocusEnvironment for UIImagePickerController {}
261);
262
263#[cfg(all(
264 feature = "UINavigationController",
265 feature = "UIResponder",
266 feature = "UIViewController"
267))]
268extern_conformance!(
269 unsafe impl UIResponderStandardEditActions for UIImagePickerController {}
270);
271
272#[cfg(all(
273 feature = "UINavigationController",
274 feature = "UIResponder",
275 feature = "UITraitCollection",
276 feature = "UIViewController"
277))]
278extern_conformance!(
279 unsafe impl UITraitEnvironment for UIImagePickerController {}
280);
281
282#[cfg(all(
283 feature = "UINavigationController",
284 feature = "UIResponder",
285 feature = "UIViewController"
286))]
287impl UIImagePickerController {
288 extern_methods!(
289 #[unsafe(method(isSourceTypeAvailable:))]
290 #[unsafe(method_family = none)]
291 pub unsafe fn isSourceTypeAvailable(
292 source_type: UIImagePickerControllerSourceType,
293 mtm: MainThreadMarker,
294 ) -> bool;
295
296 #[unsafe(method(availableMediaTypesForSourceType:))]
297 #[unsafe(method_family = none)]
298 pub unsafe fn availableMediaTypesForSourceType(
299 source_type: UIImagePickerControllerSourceType,
300 mtm: MainThreadMarker,
301 ) -> Option<Retained<NSArray<NSString>>>;
302
303 #[unsafe(method(isCameraDeviceAvailable:))]
304 #[unsafe(method_family = none)]
305 pub unsafe fn isCameraDeviceAvailable(
306 camera_device: UIImagePickerControllerCameraDevice,
307 mtm: MainThreadMarker,
308 ) -> bool;
309
310 #[unsafe(method(isFlashAvailableForCameraDevice:))]
311 #[unsafe(method_family = none)]
312 pub unsafe fn isFlashAvailableForCameraDevice(
313 camera_device: UIImagePickerControllerCameraDevice,
314 mtm: MainThreadMarker,
315 ) -> bool;
316
317 #[unsafe(method(availableCaptureModesForCameraDevice:))]
318 #[unsafe(method_family = none)]
319 pub unsafe fn availableCaptureModesForCameraDevice(
320 camera_device: UIImagePickerControllerCameraDevice,
321 mtm: MainThreadMarker,
322 ) -> Option<Retained<NSArray<NSNumber>>>;
323
324 #[unsafe(method(delegate))]
325 #[unsafe(method_family = none)]
326 pub unsafe fn delegate(
327 &self,
328 ) -> Option<
329 Retained<
330 AnyObject, >,
332 >;
333
334 #[unsafe(method(setDelegate:))]
337 #[unsafe(method_family = none)]
338 pub unsafe fn setDelegate(
339 &self,
340 delegate: Option<
341 &AnyObject, >,
343 );
344
345 #[unsafe(method(sourceType))]
346 #[unsafe(method_family = none)]
347 pub unsafe fn sourceType(&self) -> UIImagePickerControllerSourceType;
348
349 #[unsafe(method(setSourceType:))]
351 #[unsafe(method_family = none)]
352 pub unsafe fn setSourceType(&self, source_type: UIImagePickerControllerSourceType);
353
354 #[unsafe(method(mediaTypes))]
355 #[unsafe(method_family = none)]
356 pub unsafe fn mediaTypes(&self) -> Retained<NSArray<NSString>>;
357
358 #[unsafe(method(setMediaTypes:))]
360 #[unsafe(method_family = none)]
361 pub unsafe fn setMediaTypes(&self, media_types: &NSArray<NSString>);
362
363 #[unsafe(method(allowsEditing))]
364 #[unsafe(method_family = none)]
365 pub unsafe fn allowsEditing(&self) -> bool;
366
367 #[unsafe(method(setAllowsEditing:))]
369 #[unsafe(method_family = none)]
370 pub unsafe fn setAllowsEditing(&self, allows_editing: bool);
371
372 #[deprecated]
373 #[unsafe(method(allowsImageEditing))]
374 #[unsafe(method_family = none)]
375 pub unsafe fn allowsImageEditing(&self) -> bool;
376
377 #[deprecated]
379 #[unsafe(method(setAllowsImageEditing:))]
380 #[unsafe(method_family = none)]
381 pub unsafe fn setAllowsImageEditing(&self, allows_image_editing: bool);
382
383 #[deprecated = "Will be removed in a future release, use PHPicker."]
384 #[unsafe(method(imageExportPreset))]
385 #[unsafe(method_family = none)]
386 pub unsafe fn imageExportPreset(&self) -> UIImagePickerControllerImageURLExportPreset;
387
388 #[deprecated = "Will be removed in a future release, use PHPicker."]
390 #[unsafe(method(setImageExportPreset:))]
391 #[unsafe(method_family = none)]
392 pub unsafe fn setImageExportPreset(
393 &self,
394 image_export_preset: UIImagePickerControllerImageURLExportPreset,
395 );
396
397 #[unsafe(method(videoMaximumDuration))]
398 #[unsafe(method_family = none)]
399 pub unsafe fn videoMaximumDuration(&self) -> NSTimeInterval;
400
401 #[unsafe(method(setVideoMaximumDuration:))]
403 #[unsafe(method_family = none)]
404 pub unsafe fn setVideoMaximumDuration(&self, video_maximum_duration: NSTimeInterval);
405
406 #[unsafe(method(videoQuality))]
407 #[unsafe(method_family = none)]
408 pub unsafe fn videoQuality(&self) -> UIImagePickerControllerQualityType;
409
410 #[unsafe(method(setVideoQuality:))]
412 #[unsafe(method_family = none)]
413 pub unsafe fn setVideoQuality(&self, video_quality: UIImagePickerControllerQualityType);
414
415 #[deprecated = "Will be removed in a future release, use PHPicker."]
416 #[unsafe(method(videoExportPreset))]
417 #[unsafe(method_family = none)]
418 pub unsafe fn videoExportPreset(&self) -> Retained<NSString>;
419
420 #[deprecated = "Will be removed in a future release, use PHPicker."]
422 #[unsafe(method(setVideoExportPreset:))]
423 #[unsafe(method_family = none)]
424 pub unsafe fn setVideoExportPreset(&self, video_export_preset: &NSString);
425
426 #[unsafe(method(showsCameraControls))]
427 #[unsafe(method_family = none)]
428 pub unsafe fn showsCameraControls(&self) -> bool;
429
430 #[unsafe(method(setShowsCameraControls:))]
432 #[unsafe(method_family = none)]
433 pub unsafe fn setShowsCameraControls(&self, shows_camera_controls: bool);
434
435 #[cfg(feature = "UIView")]
436 #[unsafe(method(cameraOverlayView))]
437 #[unsafe(method_family = none)]
438 pub unsafe fn cameraOverlayView(&self) -> Option<Retained<UIView>>;
439
440 #[cfg(feature = "UIView")]
441 #[unsafe(method(setCameraOverlayView:))]
443 #[unsafe(method_family = none)]
444 pub unsafe fn setCameraOverlayView(&self, camera_overlay_view: Option<&UIView>);
445
446 #[cfg(feature = "objc2-core-foundation")]
447 #[unsafe(method(cameraViewTransform))]
448 #[unsafe(method_family = none)]
449 pub unsafe fn cameraViewTransform(&self) -> CGAffineTransform;
450
451 #[cfg(feature = "objc2-core-foundation")]
452 #[unsafe(method(setCameraViewTransform:))]
454 #[unsafe(method_family = none)]
455 pub unsafe fn setCameraViewTransform(&self, camera_view_transform: CGAffineTransform);
456
457 #[unsafe(method(takePicture))]
458 #[unsafe(method_family = none)]
459 pub unsafe fn takePicture(&self);
460
461 #[unsafe(method(startVideoCapture))]
462 #[unsafe(method_family = none)]
463 pub unsafe fn startVideoCapture(&self) -> bool;
464
465 #[unsafe(method(stopVideoCapture))]
466 #[unsafe(method_family = none)]
467 pub unsafe fn stopVideoCapture(&self);
468
469 #[unsafe(method(cameraCaptureMode))]
470 #[unsafe(method_family = none)]
471 pub unsafe fn cameraCaptureMode(&self) -> UIImagePickerControllerCameraCaptureMode;
472
473 #[unsafe(method(setCameraCaptureMode:))]
475 #[unsafe(method_family = none)]
476 pub unsafe fn setCameraCaptureMode(
477 &self,
478 camera_capture_mode: UIImagePickerControllerCameraCaptureMode,
479 );
480
481 #[unsafe(method(cameraDevice))]
482 #[unsafe(method_family = none)]
483 pub unsafe fn cameraDevice(&self) -> UIImagePickerControllerCameraDevice;
484
485 #[unsafe(method(setCameraDevice:))]
487 #[unsafe(method_family = none)]
488 pub unsafe fn setCameraDevice(&self, camera_device: UIImagePickerControllerCameraDevice);
489
490 #[unsafe(method(cameraFlashMode))]
491 #[unsafe(method_family = none)]
492 pub unsafe fn cameraFlashMode(&self) -> UIImagePickerControllerCameraFlashMode;
493
494 #[unsafe(method(setCameraFlashMode:))]
496 #[unsafe(method_family = none)]
497 pub unsafe fn setCameraFlashMode(
498 &self,
499 camera_flash_mode: UIImagePickerControllerCameraFlashMode,
500 );
501 );
502}
503
504#[cfg(all(
506 feature = "UINavigationController",
507 feature = "UIResponder",
508 feature = "UIViewController"
509))]
510impl UIImagePickerController {
511 extern_methods!(
512 #[unsafe(method(initWithNavigationBarClass:toolbarClass:))]
513 #[unsafe(method_family = init)]
514 pub unsafe fn initWithNavigationBarClass_toolbarClass(
515 this: Allocated<Self>,
516 navigation_bar_class: Option<&AnyClass>,
517 toolbar_class: Option<&AnyClass>,
518 ) -> Retained<Self>;
519
520 #[unsafe(method(initWithRootViewController:))]
521 #[unsafe(method_family = init)]
522 pub unsafe fn initWithRootViewController(
523 this: Allocated<Self>,
524 root_view_controller: &UIViewController,
525 ) -> Retained<Self>;
526
527 #[unsafe(method(initWithNibName:bundle:))]
528 #[unsafe(method_family = init)]
529 pub unsafe fn initWithNibName_bundle(
530 this: Allocated<Self>,
531 nib_name_or_nil: Option<&NSString>,
532 nib_bundle_or_nil: Option<&NSBundle>,
533 ) -> Retained<Self>;
534
535 #[unsafe(method(initWithCoder:))]
536 #[unsafe(method_family = init)]
537 pub unsafe fn initWithCoder(
538 this: Allocated<Self>,
539 a_decoder: &NSCoder,
540 ) -> Option<Retained<Self>>;
541 );
542}
543
544#[cfg(all(
546 feature = "UINavigationController",
547 feature = "UIResponder",
548 feature = "UIViewController"
549))]
550impl UIImagePickerController {
551 extern_methods!(
552 #[unsafe(method(init))]
553 #[unsafe(method_family = init)]
554 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
555
556 #[unsafe(method(new))]
557 #[unsafe(method_family = new)]
558 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
559 );
560}
561
562extern_protocol!(
563 pub unsafe trait UIImagePickerControllerDelegate:
565 NSObjectProtocol + MainThreadOnly
566 {
567 #[cfg(all(
568 feature = "UIImage",
569 feature = "UINavigationController",
570 feature = "UIResponder",
571 feature = "UIViewController"
572 ))]
573 #[deprecated]
574 #[optional]
575 #[unsafe(method(imagePickerController:didFinishPickingImage:editingInfo:))]
576 #[unsafe(method_family = none)]
577 unsafe fn imagePickerController_didFinishPickingImage_editingInfo(
578 &self,
579 picker: &UIImagePickerController,
580 image: &UIImage,
581 editing_info: Option<&NSDictionary<UIImagePickerControllerInfoKey, AnyObject>>,
582 );
583
584 #[cfg(all(
585 feature = "UINavigationController",
586 feature = "UIResponder",
587 feature = "UIViewController"
588 ))]
589 #[optional]
590 #[unsafe(method(imagePickerController:didFinishPickingMediaWithInfo:))]
591 #[unsafe(method_family = none)]
592 unsafe fn imagePickerController_didFinishPickingMediaWithInfo(
593 &self,
594 picker: &UIImagePickerController,
595 info: &NSDictionary<UIImagePickerControllerInfoKey, AnyObject>,
596 );
597
598 #[cfg(all(
599 feature = "UINavigationController",
600 feature = "UIResponder",
601 feature = "UIViewController"
602 ))]
603 #[optional]
604 #[unsafe(method(imagePickerControllerDidCancel:))]
605 #[unsafe(method_family = none)]
606 unsafe fn imagePickerControllerDidCancel(&self, picker: &UIImagePickerController);
607 }
608);
609
610#[cfg(feature = "UIImage")]
611impl UIImage {
612 #[doc(alias = "UIImageWriteToSavedPhotosAlbum")]
613 #[cfg(feature = "UIImage")]
614 #[inline]
615 pub unsafe fn write_to_saved_photos_album(
616 self: &UIImage,
617 completion_target: Option<&AnyObject>,
618 completion_selector: Option<Sel>,
619 context_info: *mut c_void,
620 ) {
621 extern "C-unwind" {
622 fn UIImageWriteToSavedPhotosAlbum(
623 image: &UIImage,
624 completion_target: Option<&AnyObject>,
625 completion_selector: Option<Sel>,
626 context_info: *mut c_void,
627 );
628 }
629 unsafe {
630 UIImageWriteToSavedPhotosAlbum(
631 self,
632 completion_target,
633 completion_selector,
634 context_info,
635 )
636 }
637 }
638}
639
640#[inline]
641pub unsafe extern "C-unwind" fn UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(
642 video_path: &NSString,
643) -> bool {
644 extern "C-unwind" {
645 fn UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(video_path: &NSString) -> Bool;
646 }
647 unsafe { UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(video_path) }.as_bool()
648}
649
650extern "C-unwind" {
651 pub fn UISaveVideoAtPathToSavedPhotosAlbum(
652 video_path: &NSString,
653 completion_target: Option<&AnyObject>,
654 completion_selector: Option<Sel>,
655 context_info: *mut c_void,
656 );
657}
658
659extern "C-unwind" {
660 #[cfg(feature = "UIImage")]
661 #[deprecated = "renamed to `UIImage::write_to_saved_photos_album`"]
662 pub fn UIImageWriteToSavedPhotosAlbum(
663 image: &UIImage,
664 completion_target: Option<&AnyObject>,
665 completion_selector: Option<Sel>,
666 context_info: *mut c_void,
667 );
668}