Lock orientation button

This commit is contained in:
Arkadiusz Fal
2022-07-11 01:26:35 +02:00
parent 5bfc1a3206
commit fc175be76b
3 changed files with 41 additions and 10 deletions

View File

@@ -207,6 +207,7 @@ struct PlayerControls: View {
#if os(iOS)
pipButton
lockOrientationButton
#endif
Spacer()
@@ -262,6 +263,21 @@ struct PlayerControls: View {
}
}
#if os(iOS)
private var lockOrientationButton: some View {
button("Lock Rotation", systemImage: player.lockedOrientation.isNil ? "lock.rotation.open" : "lock.rotation", active: !player.lockedOrientation.isNil) {
if player.lockedOrientation.isNil {
let orientationMask = OrientationTracker.shared.currentInterfaceOrientationMask
player.lockedOrientation = orientationMask
Orientation.lockOrientation(orientationMask)
} else {
player.lockedOrientation = nil
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: OrientationTracker.shared.currentInterfaceOrientation)
}
}
}
#endif
var floatingControls: some View {
HStack {
HStack(spacing: 20) {