Fix wrong orientation mode on app start.

This commit is contained in:
Aiden Vigue 2021-05-22 13:55:21 -04:00
parent 428b932493
commit 5d8c608876
3 changed files with 20 additions and 4 deletions

View File

@ -172,6 +172,7 @@ extension View {
struct ContentView: View { struct ContentView: View {
@Environment(\.managedObjectContext) private var viewContext @Environment(\.managedObjectContext) private var viewContext
@EnvironmentObject var orientationInfo: OrientationInfo
@StateObject private var globalData = GlobalData() @StateObject private var globalData = GlobalData()
@EnvironmentObject var jsi: justSignedIn @EnvironmentObject var jsi: justSignedIn
@ -200,6 +201,14 @@ struct ContentView: View {
} }
func startup() { func startup() {
let size = UIScreen.main.bounds.size
if size.width < size.height {
orientationInfo.orientation = .portrait;
} else {
orientationInfo.orientation = .landscape;
}
if(_viewDidLoad.wrappedValue) { if(_viewDidLoad.wrappedValue) {
return return
} }

View File

@ -84,6 +84,11 @@ struct EpisodeItemView: View {
} }
func loadData() { func loadData() {
if(UIDevice.current.orientation.isLandscape) {
orientationInfo.orientation = .landscape;
} else {
orientationInfo.orientation = .portrait;
}
if(_vc.wrappedValue != nil) { if(_vc.wrappedValue != nil) {
_vc.wrappedValue?._prefersHomeIndicatorAutoHidden = false; _vc.wrappedValue?._prefersHomeIndicatorAutoHidden = false;
_vc.wrappedValue?._orientations = .allButUpsideDown; _vc.wrappedValue?._orientations = .allButUpsideDown;

View File

@ -122,10 +122,12 @@ struct SeriesItemView: View {
.fontWeight(.semibold) .fontWeight(.semibold)
.foregroundColor(.primary) .foregroundColor(.primary)
.lineLimit(1) .lineLimit(1)
Text(String(item.ProductionYear)) if(item.ProductionYear != 0) {
.foregroundColor(.secondary) Text(String(item.ProductionYear))
.font(.caption) .foregroundColor(.secondary)
.fontWeight(.medium) .font(.caption)
.fontWeight(.medium)
}
}.frame(width: 100) }.frame(width: 100)
} }
} }