parent
f2f8f8be14
commit
30e944ffc4
|
@ -38,6 +38,8 @@ struct SupportedOrientationsPreferenceKey: PreferenceKey {
|
|||
|
||||
static var defaultValue: UIInterfaceOrientationMask = .allButUpsideDown
|
||||
|
||||
static func reduce(value: inout UIInterfaceOrientationMask, nextValue: () -> UIInterfaceOrientationMask) {}
|
||||
static func reduce(value: inout UIInterfaceOrientationMask, nextValue: () -> UIInterfaceOrientationMask) {
|
||||
value = nextValue()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -81,6 +81,8 @@ public class UIPreferencesHostingController: UIHostingController<AnyView> {
|
|||
didSet {
|
||||
if #available(iOS 16, *) {
|
||||
setNeedsUpdateOfSupportedInterfaceOrientations()
|
||||
} else {
|
||||
AppRotationUtility.lockOrientation(_orientations)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,3 +113,27 @@ public class UIPreferencesHostingController: UIHostingController<AnyView> {
|
|||
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO: remove after iOS 15 support removed
|
||||
|
||||
#if os(iOS)
|
||||
enum AppRotationUtility {
|
||||
|
||||
static func lockOrientation(_ orientationLock: UIInterfaceOrientationMask) {
|
||||
|
||||
guard UIDevice.current.userInterfaceIdiom == .phone else { return }
|
||||
|
||||
let rotateOrientation: UIInterfaceOrientation
|
||||
|
||||
switch orientationLock {
|
||||
case .landscape:
|
||||
rotateOrientation = .landscapeRight
|
||||
default:
|
||||
rotateOrientation = .portrait
|
||||
}
|
||||
|
||||
UIDevice.current.setValue(rotateOrientation.rawValue, forKey: "orientation")
|
||||
UINavigationController.attemptRotationToDeviceOrientation()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -26,10 +26,10 @@ final class LiveVideoPlayerCoordinator: NavigationCoordinatable {
|
|||
self.videoPlayerManager = manager
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
func makeStart() -> some View {
|
||||
#if os(iOS)
|
||||
|
||||
@ViewBuilder
|
||||
private var versionedView: some View {
|
||||
if #available(iOS 16, *) {
|
||||
PreferencesView {
|
||||
Group {
|
||||
if Defaults[.VideoPlayer.videoPlayerType] == .swiftfin {
|
||||
|
@ -41,6 +41,27 @@ final class LiveVideoPlayerCoordinator: NavigationCoordinatable {
|
|||
.preferredColorScheme(.dark)
|
||||
.supportedOrientations(UIDevice.isPhone ? .landscape : .allButUpsideDown)
|
||||
}
|
||||
} else {
|
||||
Group {
|
||||
if Defaults[.VideoPlayer.videoPlayerType] == .swiftfin {
|
||||
LiveVideoPlayer(manager: self.videoPlayerManager)
|
||||
} else {
|
||||
LiveNativeVideoPlayer(manager: self.videoPlayerManager)
|
||||
}
|
||||
}
|
||||
.preferredColorScheme(.dark)
|
||||
.supportedOrientations(UIDevice.isPhone ? .landscape : .allButUpsideDown)
|
||||
.preferredColorScheme(.dark)
|
||||
.supportedOrientations(UIDevice.isPhone ? .landscape : .allButUpsideDown)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ViewBuilder
|
||||
func makeStart() -> some View {
|
||||
#if os(iOS)
|
||||
|
||||
versionedView
|
||||
.ignoresSafeArea()
|
||||
.backport
|
||||
.persistentSystemOverlays(.hidden)
|
||||
|
|
|
@ -26,15 +26,12 @@ final class VideoPlayerCoordinator: NavigationCoordinatable {
|
|||
self.videoPlayerManager = manager
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
func makeStart() -> some View {
|
||||
#if os(iOS)
|
||||
// TODO: removed after iOS 15 support removed
|
||||
|
||||
// Some settings have to apply to the root PreferencesView and this
|
||||
// one - separately.
|
||||
// It is assumed that because Stinsen adds a lot of views that the
|
||||
// PreferencesView isn't in the right place in the VC chain so that
|
||||
// it can apply the settings, even SwiftUI settings.
|
||||
#if os(iOS)
|
||||
@ViewBuilder
|
||||
private var versionedView: some View {
|
||||
if #available(iOS 16, *) {
|
||||
PreferencesView {
|
||||
Group {
|
||||
if Defaults[.VideoPlayer.videoPlayerType] == .swiftfin {
|
||||
|
@ -46,6 +43,30 @@ final class VideoPlayerCoordinator: NavigationCoordinatable {
|
|||
.preferredColorScheme(.dark)
|
||||
.supportedOrientations(UIDevice.isPhone ? .landscape : .allButUpsideDown)
|
||||
}
|
||||
} else {
|
||||
Group {
|
||||
if Defaults[.VideoPlayer.videoPlayerType] == .swiftfin {
|
||||
VideoPlayer(manager: self.videoPlayerManager)
|
||||
} else {
|
||||
NativeVideoPlayer(manager: self.videoPlayerManager)
|
||||
}
|
||||
}
|
||||
.preferredColorScheme(.dark)
|
||||
.supportedOrientations(UIDevice.isPhone ? .landscape : .allButUpsideDown)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ViewBuilder
|
||||
func makeStart() -> some View {
|
||||
#if os(iOS)
|
||||
|
||||
// Some settings have to apply to the root PreferencesView and this
|
||||
// one - separately.
|
||||
// It is assumed that because Stinsen adds a lot of views that the
|
||||
// PreferencesView isn't in the right place in the VC chain so that
|
||||
// it can apply the settings, even SwiftUI settings.
|
||||
versionedView
|
||||
.ignoresSafeArea()
|
||||
.backport
|
||||
.persistentSystemOverlays(.hidden)
|
||||
|
|
|
@ -86,4 +86,6 @@ extension Notifications.Key {
|
|||
static let didDeleteServer = NotificationKey("didDeleteServer")
|
||||
|
||||
static let didChangeUserProfileImage = NotificationKey("didChangeUserProfileImage")
|
||||
|
||||
static let didStartPlayback = NotificationKey("didStartPlayback")
|
||||
}
|
||||
|
|
|
@ -71,13 +71,31 @@ struct SwiftfinApp: App {
|
|||
}
|
||||
}
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
// TODO: removed after iOS 15 support removed
|
||||
|
||||
@ViewBuilder
|
||||
private var versionedView: some View {
|
||||
if #available(iOS 16, *) {
|
||||
PreferencesView {
|
||||
MainCoordinator()
|
||||
.view()
|
||||
.supportedOrientations(UIDevice.isPad ? .allButUpsideDown : .portrait)
|
||||
}
|
||||
} else {
|
||||
PreferencesView {
|
||||
PreferencesView {
|
||||
MainCoordinator()
|
||||
.view()
|
||||
.supportedOrientations(UIDevice.isPad ? .allButUpsideDown : .portrait)
|
||||
}
|
||||
.ignoresSafeArea()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
versionedView
|
||||
.ignoresSafeArea()
|
||||
.onNotification(UIApplication.didEnterBackgroundNotification) { _ in
|
||||
Defaults[.backgroundTimeStamp] = Date.now
|
||||
|
|
Loading…
Reference in New Issue