22import UIKit
33
44/// An object for configuring a selection of media items (photos and videos) from the Library or Camera.
5- public struct MediaPicker : CustomStringConvertible , Sendable {
5+ public struct MediaPicker : Sendable {
66
77 /// The type of picker interface to be displayed by the controller.
88 public let source : MediaPickerSource
@@ -25,15 +25,16 @@ public struct MediaPicker: CustomStringConvertible, Sendable {
2525 /// The video recording and transcoding quality.
2626 public let videoQuality : UIImagePickerController . QualityType
2727
28+ /// The user interface style for the image picker controller.
29+ public let userInterfaceStyle : UIUserInterfaceStyle ?
30+
2831 /// A closure that returns the created `UIImagePickerController` in the argument.
2932 public let didInitialize : ( @MainActor ( _ container: UIImagePickerController ) -> Void ) ?
3033
3134 /// Closure with result,
3235 /// called when the user has selected a still image or movie or has canceled the pick operation.
3336 public let didFinish : @MainActor ( _ result: MediaPickerResult ? ) -> Void
3437
35- public let description : String
36-
3738 /// Creates a configuration for selecting media items.
3839 /// - Parameters:
3940 /// - source: The type of picker interface to be displayed by the controller.
@@ -44,6 +45,7 @@ public struct MediaPicker: CustomStringConvertible, Sendable {
4445 /// - videoExportPreset: The preset to use when preparing video for export to your app.
4546 /// - videoMaximumDuration: The maximum duration, in seconds, for a video recording.
4647 /// - videoQuality: The video recording and transcoding quality.
48+ /// - userInterfaceStyle: The user interface style for the image picker controller.
4749 /// - didInitialize: Closure to configure the `UIImagePickerController` after initialization.
4850 /// - didFinish: Closure with result, called when the user
4951 /// has selected a still image or movie or has canceled the pick operation.
@@ -56,6 +58,7 @@ public struct MediaPicker: CustomStringConvertible, Sendable {
5658 videoExportPreset: String ? = nil ,
5759 videoMaximumDuration: TimeInterval = 600.0 ,
5860 videoQuality: UIImagePickerController . QualityType = . typeMedium,
61+ userInterfaceStyle: UIUserInterfaceStyle ? = nil ,
5962 didInitialize: ( @MainActor ( _ container: UIImagePickerController ) -> Void ) ? = nil ,
6063 didFinish: @escaping @MainActor ( _ result: MediaPickerResult ? ) -> Void
6164 ) {
@@ -66,11 +69,10 @@ public struct MediaPicker: CustomStringConvertible, Sendable {
6669 self . videoExportPreset = videoExportPreset
6770 self . videoMaximumDuration = videoMaximumDuration
6871 self . videoQuality = videoQuality
72+ self . userInterfaceStyle = userInterfaceStyle
6973
7074 self . didInitialize = didInitialize
7175 self . didFinish = didFinish
72-
73- description = " ImagePicker(from: \" \( source) \" ) "
7476 }
7577
7678 /// Creates a configuration for selecting media items.
@@ -81,6 +83,7 @@ public struct MediaPicker: CustomStringConvertible, Sendable {
8183 /// the user is allowed to edit a selected still image or movie.
8284 /// - videoMaximumDuration: The maximum duration, in seconds, for a video recording.
8385 /// - videoQuality: The video recording and transcoding quality.
86+ /// - userInterfaceStyle: The user interface style for the image picker controller.
8487 /// - didInitialize: Closure to configure the `UIImagePickerController` after initialization.
8588 /// - didFinish: Closure with result, called when the user
8689 /// has selected a still image or movie or has canceled the pick operation.
@@ -90,6 +93,7 @@ public struct MediaPicker: CustomStringConvertible, Sendable {
9093 allowsEditing: Bool = false ,
9194 videoMaximumDuration: TimeInterval = 600.0 ,
9295 videoQuality: UIImagePickerController . QualityType = . typeMedium,
96+ userInterfaceStyle: UIUserInterfaceStyle ? = nil ,
9397 didInitialize: ( @MainActor ( _ container: UIImagePickerController ) -> Void ) ? = nil ,
9498 didFinish: @escaping @MainActor ( _ result: MediaPickerResult ? ) -> Void
9599 ) {
@@ -100,11 +104,17 @@ public struct MediaPicker: CustomStringConvertible, Sendable {
100104 self . videoExportPreset = nil
101105 self . videoMaximumDuration = videoMaximumDuration
102106 self . videoQuality = videoQuality
107+ self . userInterfaceStyle = userInterfaceStyle
103108
104109 self . didInitialize = didInitialize
105110 self . didFinish = didFinish
111+ }
112+ }
113+
114+ extension MediaPicker : CustomStringConvertible {
106115
107- description = " ImagePicker(from: \" \( source) \" ) "
116+ public var description : String {
117+ " ImagePicker(from: \" \( source) \" ) "
108118 }
109119}
110120#endif
0 commit comments