Minor UI fixes, force orientation (#857)
This commit is contained in:
parent
10a1418d04
commit
a2f9da506c
|
@ -41,9 +41,9 @@ final class VideoPlayerCoordinator: NavigationCoordinatable {
|
||||||
}
|
}
|
||||||
.ignoresSafeArea()
|
.ignoresSafeArea()
|
||||||
.hideSystemOverlays()
|
.hideSystemOverlays()
|
||||||
// .onAppear {
|
.onAppear {
|
||||||
// AppDelegate.changeOrientation(.landscape)
|
AppDelegate.enterPlaybackOrientation()
|
||||||
// }
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
|
@ -38,17 +38,37 @@ class AppDelegate: NSObject, UIApplicationDelegate {
|
||||||
AppDelegate.orientationLock
|
AppDelegate.orientationLock
|
||||||
}
|
}
|
||||||
|
|
||||||
static func changeOrientation(_ orientation: UIInterfaceOrientationMask) {
|
static func enterPlaybackOrientation() {
|
||||||
|
AppDelegate.changeOrientation(.landscape)
|
||||||
|
}
|
||||||
|
|
||||||
// guard UIDevice.isPhone else { return }
|
static func leavePlaybackOrientation() {
|
||||||
//
|
if UIDevice.isIPad {
|
||||||
// Self.orientationLock = orientation
|
AppDelegate.changeOrientation(.allButUpsideDown)
|
||||||
//
|
} else {
|
||||||
// if #available(iOS 16, *) {
|
// On iPhone, users likely want to return to portrait mode after leaving playback.
|
||||||
// let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
|
// However, we don't want to lock them into portrait mode, so switch back after a delay.
|
||||||
// windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: orientation))
|
AppDelegate.changeOrientation(.portrait)
|
||||||
// } else {
|
|
||||||
// UIDevice.current.setValue(UIInterfaceOrientation.landscapeRight.rawValue, forKey: "orientation")
|
// 0.25 seconds is about the time to switch from landscape to portrait.
|
||||||
// }
|
// Changing orientation again too early will cause the top time/battery bar to remain
|
||||||
|
// at the side instead of moving up top, like it should.
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
|
||||||
|
AppDelegate.changeOrientation(.allButUpsideDown)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static func changeOrientation(_ orientation: UIInterfaceOrientationMask) {
|
||||||
|
guard UIDevice.isPhone || UIDevice.isIPad else { return }
|
||||||
|
|
||||||
|
orientationLock = orientation
|
||||||
|
|
||||||
|
if #available(iOS 16, *) {
|
||||||
|
let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
|
||||||
|
windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: orientation))
|
||||||
|
} else {
|
||||||
|
UIDevice.current.setValue(UIInterfaceOrientation.landscapeRight.rawValue, forKey: "orientation")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,9 @@ extension VideoPlayer.Overlay {
|
||||||
}
|
}
|
||||||
.padding(.leading, safeAreaInsets.leading)
|
.padding(.leading, safeAreaInsets.leading)
|
||||||
.padding(.trailing, safeAreaInsets.trailing)
|
.padding(.trailing, safeAreaInsets.trailing)
|
||||||
|
.if(UIDevice.isIPad) { view in
|
||||||
|
view.padding(.horizontal)
|
||||||
|
}
|
||||||
|
|
||||||
ScrollViewReader { proxy in
|
ScrollViewReader { proxy in
|
||||||
ScrollView(.horizontal, showsIndicators: false) {
|
ScrollView(.horizontal, showsIndicators: false) {
|
||||||
|
@ -118,6 +121,9 @@ extension VideoPlayer.Overlay {
|
||||||
.padding(.leading, safeAreaInsets.leading)
|
.padding(.leading, safeAreaInsets.leading)
|
||||||
.padding(.trailing, safeAreaInsets.trailing)
|
.padding(.trailing, safeAreaInsets.trailing)
|
||||||
.padding(.bottom)
|
.padding(.bottom)
|
||||||
|
.if(UIDevice.isIPad) { view in
|
||||||
|
view.padding(.horizontal)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.onChange(of: currentOverlayType) { newValue in
|
.onChange(of: currentOverlayType) { newValue in
|
||||||
guard newValue == .chapters else { return }
|
guard newValue == .chapters else { return }
|
||||||
|
|
|
@ -29,13 +29,13 @@ extension VideoPlayer.Overlay {
|
||||||
HStack(alignment: .center) {
|
HStack(alignment: .center) {
|
||||||
Button {
|
Button {
|
||||||
videoPlayerProxy.stop()
|
videoPlayerProxy.stop()
|
||||||
router.dismissCoordinator {
|
AppDelegate.leavePlaybackOrientation()
|
||||||
AppDelegate.changeOrientation(.portrait)
|
router.dismissCoordinator()
|
||||||
}
|
|
||||||
} label: {
|
} label: {
|
||||||
Image(systemName: "xmark")
|
Image(systemName: "xmark")
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
|
.contentShape(Rectangle())
|
||||||
.buttonStyle(ScalingButtonStyle(scale: 0.8))
|
.buttonStyle(ScalingButtonStyle(scale: 0.8))
|
||||||
|
|
||||||
Text(viewModel.item.displayTitle)
|
Text(viewModel.item.displayTitle)
|
||||||
|
|
|
@ -130,9 +130,8 @@ struct VideoPlayer: View {
|
||||||
{
|
{
|
||||||
videoPlayerManager.selectNextViewModel()
|
videoPlayerManager.selectNextViewModel()
|
||||||
} else {
|
} else {
|
||||||
router.dismissCoordinator {
|
AppDelegate.leavePlaybackOrientation()
|
||||||
AppDelegate.changeOrientation(.portrait)
|
router.dismissCoordinator()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue