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 {
@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
}

View File

@ -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;

View File

@ -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)
}
}