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

@@ -189,6 +189,10 @@ extension Defaults.Keys {
static let honorSystemOrientationLock = Key<Bool>("honorSystemOrientationLock", default: true)
static let enterFullscreenInLandscape = Key<Bool>("enterFullscreenInLandscape", default: UIDevice.current.userInterfaceIdiom == .phone)
static let rotateToPortraitOnExitFullScreen = Key<Bool>("rotateToPortraitOnExitFullScreen", default: UIDevice.current.userInterfaceIdiom == .phone)
static let rotateToLandscapeOnEnterFullScreen = Key<FullScreenRotationSetting>(
"rotateToLandscapeOnEnterFullScreen",
default: UIDevice.current.userInterfaceIdiom == .phone ? .landscapeRight : .disabled
)
#endif
static let showMPVPlaybackStats = Key<Bool>("showMPVPlaybackStats", default: false)
@@ -416,3 +420,24 @@ enum PlayerTapGestureAction: String, CaseIterable, Defaults.Serializable {
}
}
}
enum FullScreenRotationSetting: String, CaseIterable, Defaults.Serializable {
case disabled
case landscapeLeft
case landscapeRight
var interaceOrientation: UIInterfaceOrientation {
switch self {
case .landscapeLeft:
return .landscapeLeft
case .landscapeRight:
return .landscapeRight
default:
return .portrait
}
}
var isRotating: Bool {
self != .disabled
}
}