mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 11:58:32 +00:00
Lock screen rotation for the camera (#2353)
This commit is contained in:
@@ -28,13 +28,18 @@ enum MediaPickerScreenCoordinatorAction {
|
||||
}
|
||||
|
||||
class MediaPickerScreenCoordinator: CoordinatorProtocol {
|
||||
private let orientationManager: OrientationManagerProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
private let source: MediaPickerScreenSource
|
||||
private let callback: ((MediaPickerScreenCoordinatorAction) -> Void)?
|
||||
private let callback: (MediaPickerScreenCoordinatorAction) -> Void
|
||||
|
||||
init(userIndicatorController: UserIndicatorControllerProtocol, source: MediaPickerScreenSource, callback: @escaping (MediaPickerScreenCoordinatorAction) -> Void) {
|
||||
init(userIndicatorController: UserIndicatorControllerProtocol,
|
||||
source: MediaPickerScreenSource,
|
||||
orientationManager: OrientationManagerProtocol,
|
||||
callback: @escaping (MediaPickerScreenCoordinatorAction) -> Void) {
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.source = source
|
||||
self.orientationManager = orientationManager
|
||||
self.callback = callback
|
||||
}
|
||||
|
||||
@@ -42,6 +47,23 @@ class MediaPickerScreenCoordinator: CoordinatorProtocol {
|
||||
AnyView(mediaPicker)
|
||||
}
|
||||
|
||||
func start() {
|
||||
guard source == .camera else {
|
||||
return
|
||||
}
|
||||
|
||||
orientationManager.setOrientation(.portrait)
|
||||
orientationManager.lockOrientation(.portrait)
|
||||
}
|
||||
|
||||
func stop() {
|
||||
guard source == .camera else {
|
||||
return
|
||||
}
|
||||
|
||||
orientationManager.lockOrientation(.all)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var mediaPicker: some View {
|
||||
switch source {
|
||||
@@ -51,12 +73,12 @@ class MediaPickerScreenCoordinator: CoordinatorProtocol {
|
||||
PhotoLibraryPicker(userIndicatorController: userIndicatorController) { [weak self] action in
|
||||
switch action {
|
||||
case .cancel:
|
||||
self?.callback?(.cancel)
|
||||
self?.callback(.cancel)
|
||||
case .error(let error):
|
||||
MXLog.error("Failed selecting media from the photo library with error: \(error)")
|
||||
self?.showError()
|
||||
case .selectFile(let url):
|
||||
self?.callback?(.selectMediaAtURL(url))
|
||||
self?.callback(.selectMediaAtURL(url))
|
||||
}
|
||||
}
|
||||
case .documents:
|
||||
@@ -65,12 +87,12 @@ class MediaPickerScreenCoordinator: CoordinatorProtocol {
|
||||
DocumentPicker(userIndicatorController: userIndicatorController) { action in
|
||||
switch action {
|
||||
case .cancel:
|
||||
self.callback?(.cancel)
|
||||
self.callback(.cancel)
|
||||
case .error(let error):
|
||||
MXLog.error("Failed selecting media from the document picker with error: \(error)")
|
||||
self.showError()
|
||||
case .selectFile(let url):
|
||||
self.callback?(.selectMediaAtURL(url))
|
||||
self.callback(.selectMediaAtURL(url))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,12 +102,12 @@ class MediaPickerScreenCoordinator: CoordinatorProtocol {
|
||||
CameraPicker(userIndicatorController: userIndicatorController) { [weak self] action in
|
||||
switch action {
|
||||
case .cancel:
|
||||
self?.callback?(.cancel)
|
||||
self?.callback(.cancel)
|
||||
case .error(let error):
|
||||
MXLog.error("Failed selecting media from the camera picker with error: \(error)")
|
||||
self?.showError()
|
||||
case .selectFile(let url):
|
||||
self?.callback?(.selectMediaAtURL(url))
|
||||
self?.callback(.selectMediaAtURL(url))
|
||||
}
|
||||
}
|
||||
.background(.black, ignoresSafeAreaEdges: .bottom)
|
||||
|
||||
+4
-1
@@ -23,6 +23,7 @@ struct RoomDetailsEditScreenCoordinatorParameters {
|
||||
weak var navigationStackCoordinator: NavigationStackCoordinator?
|
||||
let roomProxy: RoomProxyProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
let orientationManager: OrientationManagerProtocol
|
||||
}
|
||||
|
||||
enum RoomDetailsEditScreenCoordinatorAction {
|
||||
@@ -72,7 +73,9 @@ final class RoomDetailsEditScreenCoordinator: CoordinatorProtocol {
|
||||
private func displayMediaPickerWithSource(_ source: MediaPickerScreenSource) {
|
||||
let stackCoordinator = NavigationStackCoordinator()
|
||||
|
||||
let mediaPickerCoordinator = MediaPickerScreenCoordinator(userIndicatorController: parameters.userIndicatorController, source: source) { [weak self] action in
|
||||
let mediaPickerCoordinator = MediaPickerScreenCoordinator(userIndicatorController: parameters.userIndicatorController,
|
||||
source: source,
|
||||
orientationManager: parameters.orientationManager) { [weak self] action in
|
||||
guard let self else { return }
|
||||
switch action {
|
||||
case .cancel:
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@ import Combine
|
||||
import SwiftUI
|
||||
|
||||
struct UserDetailsEditScreenCoordinatorParameters {
|
||||
let orientationManager: OrientationManagerProtocol
|
||||
let clientProxy: ClientProxyProtocol
|
||||
let mediaProvider: MediaProviderProtocol
|
||||
weak var navigationStackCoordinator: NavigationStackCoordinator?
|
||||
@@ -61,7 +62,7 @@ final class UserDetailsEditScreenCoordinator: CoordinatorProtocol {
|
||||
private func displayMediaPickerWithSource(_ source: MediaPickerScreenSource) {
|
||||
let stackCoordinator = NavigationStackCoordinator()
|
||||
|
||||
let mediaPickerCoordinator = MediaPickerScreenCoordinator(userIndicatorController: parameters.userIndicatorController, source: source) { [weak self] action in
|
||||
let mediaPickerCoordinator = MediaPickerScreenCoordinator(userIndicatorController: parameters.userIndicatorController, source: source, orientationManager: parameters.orientationManager) { [weak self] action in
|
||||
guard let self else { return }
|
||||
switch action {
|
||||
case .cancel:
|
||||
|
||||
@@ -18,6 +18,7 @@ import Combine
|
||||
import SwiftUI
|
||||
|
||||
struct StartChatScreenCoordinatorParameters {
|
||||
let orientationManager: OrientationManagerProtocol
|
||||
let userSession: UserSessionProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
weak var navigationStackCoordinator: NavigationStackCoordinator?
|
||||
@@ -146,7 +147,7 @@ final class StartChatScreenCoordinator: CoordinatorProtocol {
|
||||
private func displayMediaPickerWithSource(_ source: MediaPickerScreenSource) {
|
||||
let stackCoordinator = NavigationStackCoordinator()
|
||||
|
||||
let mediaPickerCoordinator = MediaPickerScreenCoordinator(userIndicatorController: parameters.userIndicatorController, source: source) { [weak self] action in
|
||||
let mediaPickerCoordinator = MediaPickerScreenCoordinator(userIndicatorController: parameters.userIndicatorController, source: source, orientationManager: parameters.orientationManager) { [weak self] action in
|
||||
guard let self else { return }
|
||||
switch action {
|
||||
case .cancel:
|
||||
|
||||
Reference in New Issue
Block a user