diff --git a/JellyfinPlayer/ContentView.swift b/JellyfinPlayer/ContentView.swift index 3f8c0328..4ce6233c 100644 --- a/JellyfinPlayer/ContentView.swift +++ b/JellyfinPlayer/ContentView.swift @@ -193,15 +193,7 @@ struct ContentView: View { @State private var libraryPrefillID: String = ""; @State private var showSettingsPopover: Bool = false; @State private var viewDidLoad: Bool = false; - - @Environment(\.verticalSizeClass) var verticalSizeClass: UserInterfaceSizeClass? - @Environment(\.horizontalSizeClass) var horizontalSizeClass: UserInterfaceSizeClass? - var isPortrait: Bool { - let result = verticalSizeClass == .regular && horizontalSizeClass == .compact - return result - } - func startup() { let size = UIScreen.main.bounds.size if size.width < size.height { @@ -358,7 +350,7 @@ struct ContentView: View { if(!needsToSelectServer && !isSignInErrored) { VStack(alignment: .leading) { ScrollView() { - Spacer().frame(height: isPortrait ? 0 : 15) + Spacer().frame(height: orientationInfo.orientation == .portrait ? 0 : 15) ContinueWatchingView() NextUpView().padding(EdgeInsets(top: 4, leading: 0, bottom: 0, trailing: 0)) ForEach(librariesShowRecentlyAdded, id: \.self) { library_id in diff --git a/JellyfinPlayer/EpisodeItemView.swift b/JellyfinPlayer/EpisodeItemView.swift index 2e6d6b98..a9dfdd5e 100644 --- a/JellyfinPlayer/EpisodeItemView.swift +++ b/JellyfinPlayer/EpisodeItemView.swift @@ -18,14 +18,8 @@ struct EpisodeItemView: View { var item: ResumeItem; @EnvironmentObject var orientationInfo: OrientationInfo var fullItem: DetailItem; - @State private var playing: Bool = false { - didSet { - if(_playing.wrappedValue == false) { - unlockOrientations() - } - } - }; - @State private var vc: PreferenceUIHostingController? = nil; + @State private var playing: Bool = false; + @State private var progressString: String = ""; @State private var viewDidLoad: Bool = false; @@ -83,24 +77,7 @@ struct EpisodeItemView: View { fullItem = DetailItem(); } - func lockOrientations() { - if(_vc.wrappedValue != nil) { - _vc.wrappedValue?._prefersHomeIndicatorAutoHidden = true; - _vc.wrappedValue?._orientations = .landscapeRight; - _vc.wrappedValue?._viewPreference = .dark; - } - } - - func unlockOrientations() { - if(_vc.wrappedValue != nil) { - _vc.wrappedValue?._prefersHomeIndicatorAutoHidden = false; - _vc.wrappedValue?._orientations = .allButUpsideDown; - _vc.wrappedValue?._viewPreference = .unspecified; - } - } - func loadData() { - unlockOrientations(); if(_viewDidLoad.wrappedValue == true) { return } @@ -215,7 +192,10 @@ struct EpisodeItemView: View { var body: some View { if(playing) { - VideoPlayerView(item: fullItem, playing: $playing).onAppear(perform: lockOrientations) + VideoPlayerView(item: fullItem, playing: $playing) + .supportedOrientations(.landscape) + .overrideViewPreference(.dark) + .prefersHomeIndicatorAutoHidden(true) } else { LoadingView(isShowing: $isLoading) { VStack(alignment:.leading) { @@ -589,14 +569,13 @@ struct EpisodeItemView: View { } .navigationBarTitleDisplayMode(.inline) .navigationTitle("\(fullItem.Name) - S\(String(fullItem.ParentIndexNumber ?? 0)):E\(String(fullItem.IndexNumber ?? 0)) - \(fullItem.SeriesName ?? "")") - .withHostingWindow() { window in - let rootVC = window?.rootViewController; - let UIHostingcontroller: PreferenceUIHostingController = rootVC as! PreferenceUIHostingController; - vc = UIHostingcontroller; - }.introspectTabBarController { (UITabBarController) in + .introspectTabBarController { (UITabBarController) in UITabBarController.tabBar.isHidden = true } - }.onAppear(perform: loadData).supportedOrientations(.allButUpsideDown) + }.onAppear(perform: loadData) + .supportedOrientations(.allButUpsideDown) + .overrideViewPreference(.unspecified) + .prefersHomeIndicatorAutoHidden(false) } } } diff --git a/JellyfinPlayer/MovieItemView.swift b/JellyfinPlayer/MovieItemView.swift index 45d9b144..7c1387d5 100644 --- a/JellyfinPlayer/MovieItemView.swift +++ b/JellyfinPlayer/MovieItemView.swift @@ -66,14 +66,8 @@ struct MovieItemView: View { @State private var isLoading: Bool = true; var item: ResumeItem; var fullItem: DetailItem; - @State private var playing: Bool = false { - didSet { - if(_playing.wrappedValue == false) { - unlockOrientations() - } - } - }; - @State private var vc: PreferenceUIHostingController? = nil; + @State private var playing: Bool = false; + @State private var progressString: String = ""; @State private var viewDidLoad: Bool = false; @@ -129,25 +123,8 @@ struct MovieItemView: View { self.item = item; fullItem = DetailItem(); } - - func lockOrientations() { - if(_vc.wrappedValue != nil) { - _vc.wrappedValue?._prefersHomeIndicatorAutoHidden = true; - _vc.wrappedValue?._orientations = .landscapeRight; - _vc.wrappedValue?._viewPreference = .dark; - } - } - - func unlockOrientations() { - if(_vc.wrappedValue != nil) { - _vc.wrappedValue?._prefersHomeIndicatorAutoHidden = false; - _vc.wrappedValue?._orientations = .allButUpsideDown; - _vc.wrappedValue?._viewPreference = .unspecified; - } - } - + func loadData() { - unlockOrientations() if(_viewDidLoad.wrappedValue == true) { return; } @@ -261,7 +238,11 @@ struct MovieItemView: View { var body: some View { if(playing) { - VideoPlayerView(item: fullItem, playing: $playing).onAppear(perform: lockOrientations).onDisappear(perform: unlockOrientations) + VideoPlayerView(item: fullItem, playing: $playing) + .supportedOrientations(.landscape) + .preferredColorScheme(.dark) + .overrideViewPreference(.dark) + .prefersHomeIndicatorAutoHidden(true) } else { LoadingView(isShowing: $isLoading) { VStack(alignment:.leading) { @@ -625,7 +606,7 @@ struct MovieItemView: View { } Spacer().frame(height: 195); }.frame(maxHeight: .infinity) - }.padding(.trailing, 55) + } }.padding(.top, 12).padding(.leading, UIDevice.current.userInterfaceIdiom == .pad ? 16 : 55).edgesIgnoringSafeArea(.leading) } } @@ -634,14 +615,13 @@ struct MovieItemView: View { } .navigationBarTitleDisplayMode(.inline) .navigationTitle(fullItem.Name) - .withHostingWindow() { window in - let rootVC = window?.rootViewController; - let UIHostingcontroller: PreferenceUIHostingController = rootVC as! PreferenceUIHostingController; - vc = UIHostingcontroller; - }.introspectTabBarController { (UITabBarController) in + .introspectTabBarController { (UITabBarController) in UITabBarController.tabBar.isHidden = false } - }.onAppear(perform: loadData).supportedOrientations(.allButUpsideDown) + }.onAppear(perform: loadData) + .supportedOrientations(.allButUpsideDown) + .overrideViewPreference(.unspecified) + .prefersHomeIndicatorAutoHidden(false) } } } diff --git a/JellyfinPlayer/VideoPlayerView.swift b/JellyfinPlayer/VideoPlayerView.swift index 2e892ee3..95b748b7 100644 --- a/JellyfinPlayer/VideoPlayerView.swift +++ b/JellyfinPlayer/VideoPlayerView.swift @@ -490,10 +490,7 @@ struct VideoPlayerView: View { .onAppear(perform: startStream) .navigationBarHidden(true) .navigationBarBackButtonHidden(true) - .prefersHomeIndicatorAutoHidden(true) .edgesIgnoringSafeArea(.all) - .supportedOrientations(.landscapeRight) - .preferredColorScheme(.dark) .introspectTabBarController { (UITabBarController) in UITabBarController.tabBar.isHidden = true }