ios full screen
This commit is contained in:
@@ -115,7 +115,9 @@ struct RootView: View {
|
||||
FullscreenPlayerView(controller: controller) {
|
||||
exitFullscreen()
|
||||
}
|
||||
.onAppear(perform: enterFullscreen)
|
||||
.onAppear {
|
||||
AppDelegate.lockOrientation(.landscape)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -519,26 +521,14 @@ struct RootView: View {
|
||||
// MARK: - Fullscreen
|
||||
|
||||
private func enterFullscreen() {
|
||||
AppDelegate.orientationLock = UIDevice.current.userInterfaceIdiom == .pad ? .all : .landscape
|
||||
updateSupportedInterfaceOrientations()
|
||||
AppDelegate.lockOrientation(.landscape)
|
||||
showFullscreenPlayer = true
|
||||
}
|
||||
|
||||
private func exitFullscreen() {
|
||||
AppDelegate.orientationLock = UIDevice.current.userInterfaceIdiom == .pad ? .all : .portrait
|
||||
updateSupportedInterfaceOrientations()
|
||||
let restored: UIInterfaceOrientationMask =
|
||||
UIDevice.current.userInterfaceIdiom == .pad ? .all : .portrait
|
||||
AppDelegate.lockOrientation(restored)
|
||||
showFullscreenPlayer = false
|
||||
}
|
||||
|
||||
private func updateSupportedInterfaceOrientations() {
|
||||
let scenes = UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }
|
||||
let controllers = scenes.flatMap { $0.windows }.compactMap(\.rootViewController)
|
||||
for controller in controllers {
|
||||
if #available(iOS 16.0, *) {
|
||||
controller.setNeedsUpdateOfSupportedInterfaceOrientations()
|
||||
} else {
|
||||
UIViewController.attemptRotationToDeviceOrientation()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user