Lock screen rotation for the camera (#2353)

This commit is contained in:
Mauro
2024-01-18 14:24:15 +01:00
committed by GitHub
parent 65e9c3baab
commit 3ae33f1309
19 changed files with 180 additions and 53 deletions
@@ -18,12 +18,14 @@ import Combine
import SwiftUI
class WindowManager: WindowManagerProtocol {
private let appDelegate: AppDelegate
weak var windowScene: UIWindowScene?
weak var delegate: WindowManagerDelegate?
private(set) var mainWindow: UIWindow!
private(set) var overlayWindow: UIWindow!
private(set) var alternateWindow: UIWindow!
var windows: [UIWindow] {
[mainWindow, overlayWindow, alternateWindow]
}
@@ -34,7 +36,12 @@ class WindowManager: WindowManagerProtocol {
/// A duration that allows window switching to wait a couple of frames to avoid a transition through black.
private let windowHideDelay = Duration.milliseconds(33)
init(appDelegate: AppDelegate) {
self.appDelegate = appDelegate
}
func configure(with windowScene: UIWindowScene) {
self.windowScene = windowScene
mainWindow = windowScene.keyWindow
mainWindow.tintColor = .compound.textActionPrimary
@@ -80,6 +87,14 @@ class WindowManager: WindowManagerProtocol {
mainWindow.isHidden = true
}
}
func setOrientation(_ orientation: UIInterfaceOrientationMask) {
windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: orientation))
}
func lockOrientation(_ orientation: UIInterfaceOrientationMask) {
appDelegate.orientationLock = orientation
}
}
private class PassthroughWindow: UIWindow {