Improve orientation and safe area handling

Fix #369
Fix #382
This commit is contained in:
Arkadiusz Fal
2023-05-20 16:04:58 +02:00
parent b53b5eac56
commit f67b1d4feb
14 changed files with 176 additions and 118 deletions

View File

@@ -31,7 +31,7 @@ struct Orientation {
logger.info("rotating to \(orientationString)")
if #available(iOS 16, *) {
guard let windowScene = SafeArea.scene else { return }
guard let windowScene = Self.scene else { return }
let rotateOrientationMask = rotateOrientation == .portrait ? UIInterfaceOrientationMask.portrait :
rotateOrientation == .landscapeLeft ? .landscapeLeft :
rotateOrientation == .landscapeRight ? .landscapeRight :
@@ -46,4 +46,11 @@ struct Orientation {
UINavigationController.attemptRotationToDeviceOrientation()
}
private static var scene: UIWindowScene? {
UIApplication.shared.connectedScenes
.filter { $0.activationState == .foregroundActive }
.compactMap { $0 as? UIWindowScene }
.first
}
}