From 428b932493a6af7f181f4c7ed34029eee0cd9657 Mon Sep 17 00:00:00 2001 From: Aiden Vigue Date: Sat, 22 May 2021 13:48:46 -0400 Subject: [PATCH] Fix subtitle popover not appearing on iPadOS Also fixes black bars to left and right on devices w/o a notch. --- JellyfinPlayer/ContentView.swift | 1 + JellyfinPlayer/Info.plist | 4 ++-- JellyfinPlayer/JellyfinPlayerApp.swift | 7 +++++++ JellyfinPlayer/PlayerDemo.swift | 8 ++++---- JellyfinPlayer/VLCPlayer.swift | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/JellyfinPlayer/ContentView.swift b/JellyfinPlayer/ContentView.swift index 97fa5cb5..ef2a7045 100644 --- a/JellyfinPlayer/ContentView.swift +++ b/JellyfinPlayer/ContentView.swift @@ -115,6 +115,7 @@ class PreferenceUIHostingController: UIHostingController { @objc required dynamic init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) + super.modalPresentationStyle = .fullScreen } private class Box { diff --git a/JellyfinPlayer/Info.plist b/JellyfinPlayer/Info.plist index a3dfe4b3..6ac32889 100644 --- a/JellyfinPlayer/Info.plist +++ b/JellyfinPlayer/Info.plist @@ -40,7 +40,7 @@ UIApplicationSceneManifest UIApplicationSupportsMultipleScenes - + UIApplicationSupportsIndirectInputEvents @@ -57,8 +57,8 @@ UISupportedInterfaceOrientations UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + UIInterfaceOrientationLandscapeLeft UISupportedInterfaceOrientations~ipad diff --git a/JellyfinPlayer/JellyfinPlayerApp.swift b/JellyfinPlayer/JellyfinPlayerApp.swift index cddc3935..8e20f32d 100644 --- a/JellyfinPlayer/JellyfinPlayerApp.swift +++ b/JellyfinPlayer/JellyfinPlayerApp.swift @@ -11,6 +11,13 @@ class justSignedIn: ObservableObject { @Published var did: Bool = false } +extension UIDevice { + var hasNotch: Bool { + let bottom = UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0 + return bottom > 0 + } +} + class OrientationInfo: ObservableObject { enum Orientation { case portrait diff --git a/JellyfinPlayer/PlayerDemo.swift b/JellyfinPlayer/PlayerDemo.swift index 18533379..3d53896f 100644 --- a/JellyfinPlayer/PlayerDemo.swift +++ b/JellyfinPlayer/PlayerDemo.swift @@ -390,12 +390,12 @@ struct PlayerDemo: View { .accentColor(Color(red: 172/255, green: 92/255, blue: 195/255)) Text(timeText).fontWeight(.semibold).frame(width: 80).foregroundColor(.white) }.padding(EdgeInsets(top: -20, leading: 44, bottom: 42, trailing: 40)) - }.transition(.fade) - .padding(EdgeInsets(top: 0, leading: -30, bottom: 0, trailing: -30)) + } + .padding(EdgeInsets(top: 0, leading: UIDevice.current.hasNotch ? -30 : 0, bottom: 0, trailing: UIDevice.current.hasNotch ? -30 : 0)) .frame(maxWidth: .infinity, maxHeight: .infinity) .background(Color(UIColor.black).opacity(0.4)) .isHidden(inactivity) - }.padding(EdgeInsets(top: 0, leading: 34, bottom: 0, trailing: 34)) + }.padding(EdgeInsets(top: 0, leading: UIDevice.current.hasNotch ? 34 : 0, bottom: 0, trailing: UIDevice.current.hasNotch ? 34 : 0)) }.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity) .onAppear(perform: startStream) .navigationBarHidden(true) @@ -409,7 +409,7 @@ struct PlayerDemo: View { .edgesIgnoringSafeArea(.all) .onTapGesture(perform: resetTimer) .overrideViewPreference(.dark) - .popover( isPresented: self.$captionConfiguration, arrowEdge: .bottom) { + .fullScreenCover(isPresented: self.$captionConfiguration) { NavigationView() { VStack() { Form() { diff --git a/JellyfinPlayer/VLCPlayer.swift b/JellyfinPlayer/VLCPlayer.swift index 911dadda..4de81731 100644 --- a/JellyfinPlayer/VLCPlayer.swift +++ b/JellyfinPlayer/VLCPlayer.swift @@ -71,8 +71,8 @@ class PlayerUIView: UIView, VLCMediaPlayerDelegate { mediaPlayer.wrappedValue.perform(Selector(("setTextRendererFontSize:")), with: 14) mediaPlayer.wrappedValue.perform(Selector(("setTextRendererFont:")), with: "Copperplate") - mediaPlayer.wrappedValue.play() mediaPlayer.wrappedValue.jumpForward(Int32(startTime/10000000)) + mediaPlayer.wrappedValue.play() } }