Skip to content

Commit 489cb4e

Browse files
committed
Fix errors from ScreenPresentAction
1 parent f17debb commit 489cb4e

3 files changed

Lines changed: 20 additions & 20 deletions

File tree

Sources/Addons/MediaPicker/MediaPicker.swift

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import 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

Sources/Addons/MediaPicker/ScreenShowMediaPickerAction.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ public struct ScreenShowMediaPickerAction<Container: UIViewController>: ScreenAc
149149
mediaPickerContainer.videoMaximumDuration = mediaPicker.videoMaximumDuration
150150
mediaPickerContainer.videoQuality = mediaPicker.videoQuality
151151

152+
if let userInterfaceStyle = mediaPicker.userInterfaceStyle {
153+
mediaPickerContainer.overrideUserInterfaceStyle = userInterfaceStyle
154+
}
155+
152156
return mediaPickerContainer
153157
}
154158

Sources/Screen/Actions/Modal/ScreenPresentAction.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,6 @@ public struct ScreenPresentAction<
3737
navigator.logInfo("Presenting \(screen) on \(type(of: container))")
3838

3939
let presented = screen.build(navigator: navigator)
40-
var completed = false
41-
42-
let completion = { result in
43-
guard !completed else {
44-
return
45-
}
46-
47-
completed = true
48-
completion(result)
49-
}
5040

5141
container.present(presented, animated: animated) {
5242
if container.presented === presented {
@@ -55,10 +45,6 @@ public struct ScreenPresentAction<
5545
completion(.containerAlreadyPresenting(container, for: self))
5646
}
5747
}
58-
59-
if container.presented !== presented {
60-
completion(.containerAlreadyPresenting(container, for: self))
61-
}
6248
}
6349
}
6450

0 commit comments

Comments
 (0)