From 5d8c6088765ec617756084716f36f4cd5529580d Mon Sep 17 00:00:00 2001 From: Aiden Vigue Date: Sat, 22 May 2021 13:55:21 -0400 Subject: [PATCH] Fix wrong orientation mode on app start. --- JellyfinPlayer/ContentView.swift | 9 +++++++++ JellyfinPlayer/EpisodeItemView.swift | 5 +++++ JellyfinPlayer/SeriesItemView.swift | 10 ++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/JellyfinPlayer/ContentView.swift b/JellyfinPlayer/ContentView.swift index ef2a7045..fe0893bd 100644 --- a/JellyfinPlayer/ContentView.swift +++ b/JellyfinPlayer/ContentView.swift @@ -172,6 +172,7 @@ extension View { struct ContentView: View { @Environment(\.managedObjectContext) private var viewContext + @EnvironmentObject var orientationInfo: OrientationInfo @StateObject private var globalData = GlobalData() @EnvironmentObject var jsi: justSignedIn @@ -200,6 +201,14 @@ struct ContentView: View { } func startup() { + + let size = UIScreen.main.bounds.size + if size.width < size.height { + orientationInfo.orientation = .portrait; + } else { + orientationInfo.orientation = .landscape; + } + if(_viewDidLoad.wrappedValue) { return } diff --git a/JellyfinPlayer/EpisodeItemView.swift b/JellyfinPlayer/EpisodeItemView.swift index 603068af..99a184dc 100644 --- a/JellyfinPlayer/EpisodeItemView.swift +++ b/JellyfinPlayer/EpisodeItemView.swift @@ -84,6 +84,11 @@ struct EpisodeItemView: View { } func loadData() { + if(UIDevice.current.orientation.isLandscape) { + orientationInfo.orientation = .landscape; + } else { + orientationInfo.orientation = .portrait; + } if(_vc.wrappedValue != nil) { _vc.wrappedValue?._prefersHomeIndicatorAutoHidden = false; _vc.wrappedValue?._orientations = .allButUpsideDown; diff --git a/JellyfinPlayer/SeriesItemView.swift b/JellyfinPlayer/SeriesItemView.swift index 7934d57d..fc82cb83 100644 --- a/JellyfinPlayer/SeriesItemView.swift +++ b/JellyfinPlayer/SeriesItemView.swift @@ -122,10 +122,12 @@ struct SeriesItemView: View { .fontWeight(.semibold) .foregroundColor(.primary) .lineLimit(1) - Text(String(item.ProductionYear)) - .foregroundColor(.secondary) - .font(.caption) - .fontWeight(.medium) + if(item.ProductionYear != 0) { + Text(String(item.ProductionYear)) + .foregroundColor(.secondary) + .font(.caption) + .fontWeight(.medium) + } }.frame(width: 100) } }