1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIImagePickerControllerSourceType(pub NSInteger);
impl UIImagePickerControllerSourceType {
    #[deprecated = "Will be removed in a future release, use PHPicker."]
    #[doc(alias = "UIImagePickerControllerSourceTypePhotoLibrary")]
    pub const PhotoLibrary: Self = Self(0);
    #[doc(alias = "UIImagePickerControllerSourceTypeCamera")]
    pub const Camera: Self = Self(1);
    #[deprecated = "Will be removed in a future release, use PHPicker."]
    #[doc(alias = "UIImagePickerControllerSourceTypeSavedPhotosAlbum")]
    pub const SavedPhotosAlbum: Self = Self(2);
}

unsafe impl Encode for UIImagePickerControllerSourceType {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UIImagePickerControllerSourceType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIImagePickerControllerQualityType(pub NSInteger);
impl UIImagePickerControllerQualityType {
    #[doc(alias = "UIImagePickerControllerQualityTypeHigh")]
    pub const High: Self = Self(0);
    #[doc(alias = "UIImagePickerControllerQualityTypeMedium")]
    pub const Medium: Self = Self(1);
    #[doc(alias = "UIImagePickerControllerQualityTypeLow")]
    pub const Low: Self = Self(2);
    pub const UIImagePickerControllerQualityType640x480: Self = Self(3);
    #[doc(alias = "UIImagePickerControllerQualityTypeIFrame1280x720")]
    pub const IFrame1280x720: Self = Self(4);
    #[doc(alias = "UIImagePickerControllerQualityTypeIFrame960x540")]
    pub const IFrame960x540: Self = Self(5);
}

unsafe impl Encode for UIImagePickerControllerQualityType {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UIImagePickerControllerQualityType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIImagePickerControllerCameraCaptureMode(pub NSInteger);
impl UIImagePickerControllerCameraCaptureMode {
    #[doc(alias = "UIImagePickerControllerCameraCaptureModePhoto")]
    pub const Photo: Self = Self(0);
    #[doc(alias = "UIImagePickerControllerCameraCaptureModeVideo")]
    pub const Video: Self = Self(1);
}

unsafe impl Encode for UIImagePickerControllerCameraCaptureMode {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UIImagePickerControllerCameraCaptureMode {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIImagePickerControllerCameraDevice(pub NSInteger);
impl UIImagePickerControllerCameraDevice {
    #[doc(alias = "UIImagePickerControllerCameraDeviceRear")]
    pub const Rear: Self = Self(0);
    #[doc(alias = "UIImagePickerControllerCameraDeviceFront")]
    pub const Front: Self = Self(1);
}

unsafe impl Encode for UIImagePickerControllerCameraDevice {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UIImagePickerControllerCameraDevice {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIImagePickerControllerCameraFlashMode(pub NSInteger);
impl UIImagePickerControllerCameraFlashMode {
    #[doc(alias = "UIImagePickerControllerCameraFlashModeOff")]
    pub const Off: Self = Self(-1);
    #[doc(alias = "UIImagePickerControllerCameraFlashModeAuto")]
    pub const Auto: Self = Self(0);
    #[doc(alias = "UIImagePickerControllerCameraFlashModeOn")]
    pub const On: Self = Self(1);
}

unsafe impl Encode for UIImagePickerControllerCameraFlashMode {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UIImagePickerControllerCameraFlashMode {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[deprecated = "Will be removed in a future release, use PHPicker."]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIImagePickerControllerImageURLExportPreset(pub NSInteger);
impl UIImagePickerControllerImageURLExportPreset {
    #[deprecated = "Will be removed in a future release, use PHPicker."]
    #[doc(alias = "UIImagePickerControllerImageURLExportPresetCompatible")]
    pub const Compatible: Self = Self(0);
    #[deprecated = "Will be removed in a future release, use PHPicker."]
    #[doc(alias = "UIImagePickerControllerImageURLExportPresetCurrent")]
    pub const Current: Self = Self(1);
}

unsafe impl Encode for UIImagePickerControllerImageURLExportPreset {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UIImagePickerControllerImageURLExportPreset {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_TYPED_ENUM
pub type UIImagePickerControllerInfoKey = NSString;

extern "C" {
    pub static UIImagePickerControllerMediaType: &'static UIImagePickerControllerInfoKey;
}

extern "C" {
    pub static UIImagePickerControllerOriginalImage: &'static UIImagePickerControllerInfoKey;
}

extern "C" {
    pub static UIImagePickerControllerEditedImage: &'static UIImagePickerControllerInfoKey;
}

extern "C" {
    pub static UIImagePickerControllerCropRect: &'static UIImagePickerControllerInfoKey;
}

extern "C" {
    pub static UIImagePickerControllerMediaURL: &'static UIImagePickerControllerInfoKey;
}

extern "C" {
    pub static UIImagePickerControllerReferenceURL: &'static UIImagePickerControllerInfoKey;
}

extern "C" {
    pub static UIImagePickerControllerMediaMetadata: &'static UIImagePickerControllerInfoKey;
}

extern "C" {
    pub static UIImagePickerControllerLivePhoto: &'static UIImagePickerControllerInfoKey;
}

extern "C" {
    pub static UIImagePickerControllerPHAsset: &'static UIImagePickerControllerInfoKey;
}

extern "C" {
    pub static UIImagePickerControllerImageURL: &'static UIImagePickerControllerInfoKey;
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(
        feature = "UINavigationController",
        feature = "UIResponder",
        feature = "UIViewController"
    ))]
    pub struct UIImagePickerController;

    #[cfg(all(
        feature = "UINavigationController",
        feature = "UIResponder",
        feature = "UIViewController"
    ))]
    unsafe impl ClassType for UIImagePickerController {
        #[inherits(UIViewController, UIResponder, NSObject)]
        type Super = UINavigationController;
        type Mutability = MainThreadOnly;
    }
);

#[cfg(all(
    feature = "UINavigationController",
    feature = "UIResponder",
    feature = "UIViewController"
))]
unsafe impl NSCoding for UIImagePickerController {}

#[cfg(all(
    feature = "UINavigationController",
    feature = "UIResponder",
    feature = "UIViewController"
))]
unsafe impl NSObjectProtocol for UIImagePickerController {}

#[cfg(all(
    feature = "UIAppearance",
    feature = "UINavigationController",
    feature = "UIResponder",
    feature = "UIViewController"
))]
unsafe impl UIAppearanceContainer for UIImagePickerController {}

#[cfg(all(
    feature = "UINavigationController",
    feature = "UIResponder",
    feature = "UIViewController"
))]
unsafe impl UIContentContainer for UIImagePickerController {}

#[cfg(all(
    feature = "UIFocus",
    feature = "UINavigationController",
    feature = "UIResponder",
    feature = "UIViewController"
))]
unsafe impl UIFocusEnvironment for UIImagePickerController {}

#[cfg(all(
    feature = "UINavigationController",
    feature = "UIResponder",
    feature = "UIViewController"
))]
unsafe impl UIResponderStandardEditActions for UIImagePickerController {}

#[cfg(all(
    feature = "UINavigationController",
    feature = "UIResponder",
    feature = "UITraitCollection",
    feature = "UIViewController"
))]
unsafe impl UITraitEnvironment for UIImagePickerController {}

extern_methods!(
    #[cfg(all(
        feature = "UINavigationController",
        feature = "UIResponder",
        feature = "UIViewController"
    ))]
    unsafe impl UIImagePickerController {
        #[method(isSourceTypeAvailable:)]
        pub unsafe fn isSourceTypeAvailable(
            source_type: UIImagePickerControllerSourceType,
            mtm: MainThreadMarker,
        ) -> bool;

        #[method_id(@__retain_semantics Other availableMediaTypesForSourceType:)]
        pub unsafe fn availableMediaTypesForSourceType(
            source_type: UIImagePickerControllerSourceType,
            mtm: MainThreadMarker,
        ) -> Option<Retained<NSArray<NSString>>>;

        #[method(isCameraDeviceAvailable:)]
        pub unsafe fn isCameraDeviceAvailable(
            camera_device: UIImagePickerControllerCameraDevice,
            mtm: MainThreadMarker,
        ) -> bool;

        #[method(isFlashAvailableForCameraDevice:)]
        pub unsafe fn isFlashAvailableForCameraDevice(
            camera_device: UIImagePickerControllerCameraDevice,
            mtm: MainThreadMarker,
        ) -> bool;

        #[method_id(@__retain_semantics Other availableCaptureModesForCameraDevice:)]
        pub unsafe fn availableCaptureModesForCameraDevice(
            camera_device: UIImagePickerControllerCameraDevice,
            mtm: MainThreadMarker,
        ) -> Option<Retained<NSArray<NSNumber>>>;

        #[method_id(@__retain_semantics Other delegate)]
        pub unsafe fn delegate(&self) -> Option<Retained<TodoProtocols>>;

        #[method(setDelegate:)]
        pub unsafe fn setDelegate(&self, delegate: Option<&TodoProtocols>);

        #[method(sourceType)]
        pub unsafe fn sourceType(&self) -> UIImagePickerControllerSourceType;

        #[method(setSourceType:)]
        pub unsafe fn setSourceType(&self, source_type: UIImagePickerControllerSourceType);

        #[method_id(@__retain_semantics Other mediaTypes)]
        pub unsafe fn mediaTypes(&self) -> Retained<NSArray<NSString>>;

        #[method(setMediaTypes:)]
        pub unsafe fn setMediaTypes(&self, media_types: &NSArray<NSString>);

        #[method(allowsEditing)]
        pub unsafe fn allowsEditing(&self) -> bool;

        #[method(setAllowsEditing:)]
        pub unsafe fn setAllowsEditing(&self, allows_editing: bool);

        #[deprecated]
        #[method(allowsImageEditing)]
        pub unsafe fn allowsImageEditing(&self) -> bool;

        #[deprecated]
        #[method(setAllowsImageEditing:)]
        pub unsafe fn setAllowsImageEditing(&self, allows_image_editing: bool);

        #[deprecated = "Will be removed in a future release, use PHPicker."]
        #[method(imageExportPreset)]
        pub unsafe fn imageExportPreset(&self) -> UIImagePickerControllerImageURLExportPreset;

        #[deprecated = "Will be removed in a future release, use PHPicker."]
        #[method(setImageExportPreset:)]
        pub unsafe fn setImageExportPreset(
            &self,
            image_export_preset: UIImagePickerControllerImageURLExportPreset,
        );

        #[method(videoMaximumDuration)]
        pub unsafe fn videoMaximumDuration(&self) -> NSTimeInterval;

        #[method(setVideoMaximumDuration:)]
        pub unsafe fn setVideoMaximumDuration(&self, video_maximum_duration: NSTimeInterval);

        #[method(videoQuality)]
        pub unsafe fn videoQuality(&self) -> UIImagePickerControllerQualityType;

        #[method(setVideoQuality:)]
        pub unsafe fn setVideoQuality(&self, video_quality: UIImagePickerControllerQualityType);

        #[deprecated = "Will be removed in a future release, use PHPicker."]
        #[method_id(@__retain_semantics Other videoExportPreset)]
        pub unsafe fn videoExportPreset(&self) -> Retained<NSString>;

        #[deprecated = "Will be removed in a future release, use PHPicker."]
        #[method(setVideoExportPreset:)]
        pub unsafe fn setVideoExportPreset(&self, video_export_preset: &NSString);

        #[method(showsCameraControls)]
        pub unsafe fn showsCameraControls(&self) -> bool;

        #[method(setShowsCameraControls:)]
        pub unsafe fn setShowsCameraControls(&self, shows_camera_controls: bool);

        #[cfg(feature = "UIView")]
        #[method_id(@__retain_semantics Other cameraOverlayView)]
        pub unsafe fn cameraOverlayView(&self) -> Option<Retained<UIView>>;

        #[cfg(feature = "UIView")]
        #[method(setCameraOverlayView:)]
        pub unsafe fn setCameraOverlayView(&self, camera_overlay_view: Option<&UIView>);

        #[method(cameraViewTransform)]
        pub unsafe fn cameraViewTransform(&self) -> CGAffineTransform;

        #[method(setCameraViewTransform:)]
        pub unsafe fn setCameraViewTransform(&self, camera_view_transform: CGAffineTransform);

        #[method(takePicture)]
        pub unsafe fn takePicture(&self);

        #[method(startVideoCapture)]
        pub unsafe fn startVideoCapture(&self) -> bool;

        #[method(stopVideoCapture)]
        pub unsafe fn stopVideoCapture(&self);

        #[method(cameraCaptureMode)]
        pub unsafe fn cameraCaptureMode(&self) -> UIImagePickerControllerCameraCaptureMode;

        #[method(setCameraCaptureMode:)]
        pub unsafe fn setCameraCaptureMode(
            &self,
            camera_capture_mode: UIImagePickerControllerCameraCaptureMode,
        );

        #[method(cameraDevice)]
        pub unsafe fn cameraDevice(&self) -> UIImagePickerControllerCameraDevice;

        #[method(setCameraDevice:)]
        pub unsafe fn setCameraDevice(&self, camera_device: UIImagePickerControllerCameraDevice);

        #[method(cameraFlashMode)]
        pub unsafe fn cameraFlashMode(&self) -> UIImagePickerControllerCameraFlashMode;

        #[method(setCameraFlashMode:)]
        pub unsafe fn setCameraFlashMode(
            &self,
            camera_flash_mode: UIImagePickerControllerCameraFlashMode,
        );
    }
);

extern_methods!(
    /// Methods declared on superclass `UINavigationController`
    #[cfg(all(
        feature = "UINavigationController",
        feature = "UIResponder",
        feature = "UIViewController"
    ))]
    unsafe impl UIImagePickerController {
        #[method_id(@__retain_semantics Init initWithNavigationBarClass:toolbarClass:)]
        pub unsafe fn initWithNavigationBarClass_toolbarClass(
            this: Allocated<Self>,
            navigation_bar_class: Option<&AnyClass>,
            toolbar_class: Option<&AnyClass>,
        ) -> Retained<Self>;

        #[method_id(@__retain_semantics Init initWithRootViewController:)]
        pub unsafe fn initWithRootViewController(
            this: Allocated<Self>,
            root_view_controller: &UIViewController,
        ) -> Retained<Self>;

        #[method_id(@__retain_semantics Init initWithNibName:bundle:)]
        pub unsafe fn initWithNibName_bundle(
            this: Allocated<Self>,
            nib_name_or_nil: Option<&NSString>,
            nib_bundle_or_nil: Option<&NSBundle>,
        ) -> Retained<Self>;

        #[method_id(@__retain_semantics Init initWithCoder:)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            a_decoder: &NSCoder,
        ) -> Option<Retained<Self>>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(all(
        feature = "UINavigationController",
        feature = "UIResponder",
        feature = "UIViewController"
    ))]
    unsafe impl UIImagePickerController {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    }
);

extern_protocol!(
    pub unsafe trait UIImagePickerControllerDelegate:
        NSObjectProtocol + IsMainThreadOnly
    {
        #[cfg(all(
            feature = "UIImage",
            feature = "UINavigationController",
            feature = "UIResponder",
            feature = "UIViewController"
        ))]
        #[deprecated]
        #[optional]
        #[method(imagePickerController:didFinishPickingImage:editingInfo:)]
        unsafe fn imagePickerController_didFinishPickingImage_editingInfo(
            &self,
            picker: &UIImagePickerController,
            image: &UIImage,
            editing_info: Option<&NSDictionary<UIImagePickerControllerInfoKey, AnyObject>>,
        );

        #[cfg(all(
            feature = "UINavigationController",
            feature = "UIResponder",
            feature = "UIViewController"
        ))]
        #[optional]
        #[method(imagePickerController:didFinishPickingMediaWithInfo:)]
        unsafe fn imagePickerController_didFinishPickingMediaWithInfo(
            &self,
            picker: &UIImagePickerController,
            info: &NSDictionary<UIImagePickerControllerInfoKey, AnyObject>,
        );

        #[cfg(all(
            feature = "UINavigationController",
            feature = "UIResponder",
            feature = "UIViewController"
        ))]
        #[optional]
        #[method(imagePickerControllerDidCancel:)]
        unsafe fn imagePickerControllerDidCancel(&self, picker: &UIImagePickerController);
    }

    unsafe impl ProtocolType for dyn UIImagePickerControllerDelegate {}
);

extern "C" {
    #[cfg(feature = "UIImage")]
    pub fn UIImageWriteToSavedPhotosAlbum(
        image: &UIImage,
        completion_target: Option<&AnyObject>,
        completion_selector: Option<Sel>,
        context_info: *mut c_void,
    );
}

extern "C" {
    pub fn UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(video_path: &NSString) -> Bool;
}

extern "C" {
    pub fn UISaveVideoAtPathToSavedPhotosAlbum(
        video_path: &NSString,
        completion_target: Option<&AnyObject>,
        completion_selector: Option<Sel>,
        context_info: *mut c_void,
    );
}