auto-landscape rotate, overlay fade in/out, and appearance setting fix
This commit is contained in:
parent
01e52e59b7
commit
604f41bffd
|
@ -19,8 +19,11 @@ struct JellyfinPlayerApp: App {
|
||||||
|
|
||||||
var body: some Scene {
|
var body: some Scene {
|
||||||
WindowGroup {
|
WindowGroup {
|
||||||
MainCoordinator().view()
|
EmptyView()
|
||||||
.ignoresSafeArea()
|
.ignoresSafeArea()
|
||||||
|
.withHostingWindow({ window in
|
||||||
|
window?.rootViewController = PreferenceUIHostingController(wrappedView: MainCoordinator().view())
|
||||||
|
})
|
||||||
.onAppear {
|
.onAppear {
|
||||||
setupAppearance()
|
setupAppearance()
|
||||||
}
|
}
|
||||||
|
@ -34,7 +37,9 @@ struct JellyfinPlayerApp: App {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setupAppearance() {
|
private func setupAppearance() {
|
||||||
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = appAppearance.style
|
let scenes = UIApplication.shared.connectedScenes
|
||||||
|
let windowScene = scenes.first as? UIWindowScene
|
||||||
|
windowScene?.windows.first?.overrideUserInterfaceStyle = appAppearance.style
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,14 +85,6 @@ class VLCPlayerViewController: UIViewController {
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: viewWillAppear
|
|
||||||
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
|
||||||
super.viewWillAppear(animated)
|
|
||||||
|
|
||||||
// AppUtility.lockOrientation(.all, andRotateTo: .landscapeLeft)
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: viewWillDisappear
|
// MARK: viewWillDisappear
|
||||||
|
|
||||||
override func viewWillDisappear(_ animated: Bool) {
|
override func viewWillDisappear(_ animated: Bool) {
|
||||||
|
@ -102,8 +94,6 @@ class VLCPlayerViewController: UIViewController {
|
||||||
defaultNotificationCenter.removeObserver(self, name: UIApplication.willTerminateNotification, object: nil)
|
defaultNotificationCenter.removeObserver(self, name: UIApplication.willTerminateNotification, object: nil)
|
||||||
defaultNotificationCenter.removeObserver(self, name: UIApplication.willResignActiveNotification, object: nil)
|
defaultNotificationCenter.removeObserver(self, name: UIApplication.willResignActiveNotification, object: nil)
|
||||||
defaultNotificationCenter.removeObserver(self, name: UIApplication.didEnterBackgroundNotification, object: nil)
|
defaultNotificationCenter.removeObserver(self, name: UIApplication.didEnterBackgroundNotification, object: nil)
|
||||||
|
|
||||||
// AppUtility.lockOrientation(.all)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: viewDidLoad
|
// MARK: viewDidLoad
|
||||||
|
@ -210,12 +200,18 @@ class VLCPlayerViewController: UIViewController {
|
||||||
// MARK: setupOverlayHostingController
|
// MARK: setupOverlayHostingController
|
||||||
private func setupOverlayHostingController(viewModel: VideoPlayerViewModel) {
|
private func setupOverlayHostingController(viewModel: VideoPlayerViewModel) {
|
||||||
|
|
||||||
|
// TODO: Look at injecting viewModel into the environment so it updates the current overlay
|
||||||
if let currentOverlayHostingController = currentOverlayHostingController {
|
if let currentOverlayHostingController = currentOverlayHostingController {
|
||||||
currentOverlayHostingController.view.isHidden = true
|
// UX fade-out
|
||||||
|
UIView.animate(withDuration: 0.5) {
|
||||||
|
currentOverlayHostingController.view.alpha = 0
|
||||||
|
} completion: { _ in
|
||||||
|
currentOverlayHostingController.view.isHidden = true
|
||||||
|
|
||||||
currentOverlayHostingController.view.removeFromSuperview()
|
currentOverlayHostingController.view.removeFromSuperview()
|
||||||
currentOverlayHostingController.removeFromParent()
|
currentOverlayHostingController.removeFromParent()
|
||||||
self.currentOverlayHostingController = nil
|
// self.currentOverlayHostingController = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let newOverlayView = VLCPlayerCompactOverlayView(viewModel: viewModel)
|
let newOverlayView = VLCPlayerCompactOverlayView(viewModel: viewModel)
|
||||||
|
@ -223,6 +219,10 @@ class VLCPlayerViewController: UIViewController {
|
||||||
|
|
||||||
newOverlayHostingController.view.translatesAutoresizingMaskIntoConstraints = false
|
newOverlayHostingController.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
newOverlayHostingController.view.backgroundColor = UIColor.clear
|
newOverlayHostingController.view.backgroundColor = UIColor.clear
|
||||||
|
|
||||||
|
// UX fade-in
|
||||||
|
newOverlayHostingController.view.alpha = 0
|
||||||
|
|
||||||
addChild(newOverlayHostingController)
|
addChild(newOverlayHostingController)
|
||||||
view.addSubview(newOverlayHostingController.view)
|
view.addSubview(newOverlayHostingController.view)
|
||||||
newOverlayHostingController.didMove(toParent: self)
|
newOverlayHostingController.didMove(toParent: self)
|
||||||
|
@ -234,6 +234,11 @@ class VLCPlayerViewController: UIViewController {
|
||||||
newOverlayHostingController.view.rightAnchor.constraint(equalTo: videoContentView.rightAnchor)
|
newOverlayHostingController.view.rightAnchor.constraint(equalTo: videoContentView.rightAnchor)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
// UX fade-in
|
||||||
|
UIView.animate(withDuration: 0.5) {
|
||||||
|
newOverlayHostingController.view.alpha = 1
|
||||||
|
}
|
||||||
|
|
||||||
self.currentOverlayHostingController = newOverlayHostingController
|
self.currentOverlayHostingController = newOverlayHostingController
|
||||||
|
|
||||||
// There is a behavior when setting this that the navigation bar
|
// There is a behavior when setting this that the navigation bar
|
||||||
|
|
|
@ -34,6 +34,7 @@ final class VideoPlayerCoordinator: NavigationCoordinatable {
|
||||||
.statusBar(hidden: true)
|
.statusBar(hidden: true)
|
||||||
.ignoresSafeArea()
|
.ignoresSafeArea()
|
||||||
.prefersHomeIndicatorAutoHidden(true)
|
.prefersHomeIndicatorAutoHidden(true)
|
||||||
|
.supportedOrientations(.landscape)
|
||||||
}.ignoresSafeArea()
|
}.ignoresSafeArea()
|
||||||
} else {
|
} else {
|
||||||
PreferenceUIHostingControllerView {
|
PreferenceUIHostingControllerView {
|
||||||
|
@ -42,6 +43,7 @@ final class VideoPlayerCoordinator: NavigationCoordinatable {
|
||||||
.statusBar(hidden: true)
|
.statusBar(hidden: true)
|
||||||
.ignoresSafeArea()
|
.ignoresSafeArea()
|
||||||
.prefersHomeIndicatorAutoHidden(true)
|
.prefersHomeIndicatorAutoHidden(true)
|
||||||
|
.supportedOrientations(.landscape)
|
||||||
}.ignoresSafeArea()
|
}.ignoresSafeArea()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue