Have the UserIndicatorController use a separate window, switch to using one single instance throughout the application

This commit is contained in:
Stefan Ceriu
2023-11-09 15:10:50 +02:00
committed by Stefan Ceriu
parent 1102beb3dd
commit 4b26a798dc
44 changed files with 210 additions and 221 deletions
@@ -29,10 +29,10 @@ enum CameraPickerError: Error {
}
struct CameraPicker: UIViewControllerRepresentable {
private weak var userIndicatorController: UserIndicatorControllerProtocol?
private let userIndicatorController: UserIndicatorControllerProtocol
private let callback: (CameraPickerAction) -> Void
init(userIndicatorController: UserIndicatorControllerProtocol?, callback: @escaping (CameraPickerAction) -> Void) {
init(userIndicatorController: UserIndicatorControllerProtocol, callback: @escaping (CameraPickerAction) -> Void) {
self.userIndicatorController = userIndicatorController
self.callback = callback
}
@@ -68,9 +68,9 @@ struct CameraPicker: UIViewControllerRepresentable {
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
picker.delegate = nil
cameraPicker.userIndicatorController?.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading))
cameraPicker.userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading))
defer {
cameraPicker.userIndicatorController?.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
cameraPicker.userIndicatorController.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
}
if let videoURL = info[.mediaURL] as? URL {
@@ -27,10 +27,10 @@ enum DocumentPickerError: Error {
}
struct DocumentPicker: UIViewControllerRepresentable {
private weak var userIndicatorController: UserIndicatorControllerProtocol?
private let userIndicatorController: UserIndicatorControllerProtocol
private let callback: (DocumentPickerAction) -> Void
init(userIndicatorController: UserIndicatorControllerProtocol?, callback: @escaping (DocumentPickerAction) -> Void) {
init(userIndicatorController: UserIndicatorControllerProtocol, callback: @escaping (DocumentPickerAction) -> Void) {
self.userIndicatorController = userIndicatorController
self.callback = callback
}
@@ -72,9 +72,9 @@ struct DocumentPicker: UIViewControllerRepresentable {
picker.delegate = nil
documentPicker.userIndicatorController?.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading))
documentPicker.userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading))
defer {
documentPicker.userIndicatorController?.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
documentPicker.userIndicatorController.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
}
do {
@@ -28,7 +28,7 @@ enum MediaPickerScreenCoordinatorAction {
}
class MediaPickerScreenCoordinator: CoordinatorProtocol {
private weak var userIndicatorController: UserIndicatorControllerProtocol?
private let userIndicatorController: UserIndicatorControllerProtocol
private let source: MediaPickerScreenSource
private let callback: ((MediaPickerScreenCoordinatorAction) -> Void)?
@@ -92,6 +92,6 @@ class MediaPickerScreenCoordinator: CoordinatorProtocol {
}
private func showError() {
userIndicatorController?.submitIndicator(UserIndicator(title: L10n.screenMediaPickerErrorFailedSelection))
userIndicatorController.submitIndicator(UserIndicator(title: L10n.screenMediaPickerErrorFailedSelection))
}
}
@@ -29,10 +29,10 @@ enum PhotoLibraryPickerError: Error {
}
struct PhotoLibraryPicker: UIViewControllerRepresentable {
private weak var userIndicatorController: UserIndicatorControllerProtocol?
private let userIndicatorController: UserIndicatorControllerProtocol
private let callback: (PhotoLibraryPickerAction) -> Void
init(userIndicatorController: UserIndicatorControllerProtocol?, callback: @escaping (PhotoLibraryPickerAction) -> Void) {
init(userIndicatorController: UserIndicatorControllerProtocol, callback: @escaping (PhotoLibraryPickerAction) -> Void) {
self.userIndicatorController = userIndicatorController
self.callback = callback
}
@@ -73,9 +73,9 @@ struct PhotoLibraryPicker: UIViewControllerRepresentable {
picker.delegate = nil
photoLibraryPicker.userIndicatorController?.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading))
photoLibraryPicker.userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading))
defer {
photoLibraryPicker.userIndicatorController?.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
photoLibraryPicker.userIndicatorController.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
}
provider.loadFileRepresentation(forTypeIdentifier: contentType.identifier) { [weak self] url, error in