fix orientation bug again
This commit is contained in:
parent
b31ff96ddf
commit
1db069bd59
|
@ -193,15 +193,7 @@ struct ContentView: View {
|
||||||
@State private var libraryPrefillID: String = "";
|
@State private var libraryPrefillID: String = "";
|
||||||
@State private var showSettingsPopover: Bool = false;
|
@State private var showSettingsPopover: Bool = false;
|
||||||
@State private var viewDidLoad: 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() {
|
func startup() {
|
||||||
let size = UIScreen.main.bounds.size
|
let size = UIScreen.main.bounds.size
|
||||||
if size.width < size.height {
|
if size.width < size.height {
|
||||||
|
@ -358,7 +350,7 @@ struct ContentView: View {
|
||||||
if(!needsToSelectServer && !isSignInErrored) {
|
if(!needsToSelectServer && !isSignInErrored) {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
ScrollView() {
|
ScrollView() {
|
||||||
Spacer().frame(height: isPortrait ? 0 : 15)
|
Spacer().frame(height: orientationInfo.orientation == .portrait ? 0 : 15)
|
||||||
ContinueWatchingView()
|
ContinueWatchingView()
|
||||||
NextUpView().padding(EdgeInsets(top: 4, leading: 0, bottom: 0, trailing: 0))
|
NextUpView().padding(EdgeInsets(top: 4, leading: 0, bottom: 0, trailing: 0))
|
||||||
ForEach(librariesShowRecentlyAdded, id: \.self) { library_id in
|
ForEach(librariesShowRecentlyAdded, id: \.self) { library_id in
|
||||||
|
|
|
@ -18,14 +18,8 @@ struct EpisodeItemView: View {
|
||||||
var item: ResumeItem;
|
var item: ResumeItem;
|
||||||
@EnvironmentObject var orientationInfo: OrientationInfo
|
@EnvironmentObject var orientationInfo: OrientationInfo
|
||||||
var fullItem: DetailItem;
|
var fullItem: DetailItem;
|
||||||
@State private var playing: Bool = false {
|
@State private var playing: Bool = false;
|
||||||
didSet {
|
|
||||||
if(_playing.wrappedValue == false) {
|
|
||||||
unlockOrientations()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@State private var vc: PreferenceUIHostingController? = nil;
|
|
||||||
@State private var progressString: String = "";
|
@State private var progressString: String = "";
|
||||||
@State private var viewDidLoad: Bool = false;
|
@State private var viewDidLoad: Bool = false;
|
||||||
|
|
||||||
|
@ -83,24 +77,7 @@ struct EpisodeItemView: View {
|
||||||
fullItem = DetailItem();
|
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() {
|
func loadData() {
|
||||||
unlockOrientations();
|
|
||||||
if(_viewDidLoad.wrappedValue == true) {
|
if(_viewDidLoad.wrappedValue == true) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -215,7 +192,10 @@ struct EpisodeItemView: View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if(playing) {
|
if(playing) {
|
||||||
VideoPlayerView(item: fullItem, playing: $playing).onAppear(perform: lockOrientations)
|
VideoPlayerView(item: fullItem, playing: $playing)
|
||||||
|
.supportedOrientations(.landscape)
|
||||||
|
.overrideViewPreference(.dark)
|
||||||
|
.prefersHomeIndicatorAutoHidden(true)
|
||||||
} else {
|
} else {
|
||||||
LoadingView(isShowing: $isLoading) {
|
LoadingView(isShowing: $isLoading) {
|
||||||
VStack(alignment:.leading) {
|
VStack(alignment:.leading) {
|
||||||
|
@ -589,14 +569,13 @@ struct EpisodeItemView: View {
|
||||||
}
|
}
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.navigationTitle("\(fullItem.Name) - S\(String(fullItem.ParentIndexNumber ?? 0)):E\(String(fullItem.IndexNumber ?? 0)) - \(fullItem.SeriesName ?? "")")
|
.navigationTitle("\(fullItem.Name) - S\(String(fullItem.ParentIndexNumber ?? 0)):E\(String(fullItem.IndexNumber ?? 0)) - \(fullItem.SeriesName ?? "")")
|
||||||
.withHostingWindow() { window in
|
.introspectTabBarController { (UITabBarController) in
|
||||||
let rootVC = window?.rootViewController;
|
|
||||||
let UIHostingcontroller: PreferenceUIHostingController = rootVC as! PreferenceUIHostingController;
|
|
||||||
vc = UIHostingcontroller;
|
|
||||||
}.introspectTabBarController { (UITabBarController) in
|
|
||||||
UITabBarController.tabBar.isHidden = true
|
UITabBarController.tabBar.isHidden = true
|
||||||
}
|
}
|
||||||
}.onAppear(perform: loadData).supportedOrientations(.allButUpsideDown)
|
}.onAppear(perform: loadData)
|
||||||
|
.supportedOrientations(.allButUpsideDown)
|
||||||
|
.overrideViewPreference(.unspecified)
|
||||||
|
.prefersHomeIndicatorAutoHidden(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,14 +66,8 @@ struct MovieItemView: View {
|
||||||
@State private var isLoading: Bool = true;
|
@State private var isLoading: Bool = true;
|
||||||
var item: ResumeItem;
|
var item: ResumeItem;
|
||||||
var fullItem: DetailItem;
|
var fullItem: DetailItem;
|
||||||
@State private var playing: Bool = false {
|
@State private var playing: Bool = false;
|
||||||
didSet {
|
|
||||||
if(_playing.wrappedValue == false) {
|
|
||||||
unlockOrientations()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@State private var vc: PreferenceUIHostingController? = nil;
|
|
||||||
@State private var progressString: String = "";
|
@State private var progressString: String = "";
|
||||||
@State private var viewDidLoad: Bool = false;
|
@State private var viewDidLoad: Bool = false;
|
||||||
|
|
||||||
|
@ -129,25 +123,8 @@ struct MovieItemView: View {
|
||||||
self.item = item;
|
self.item = item;
|
||||||
fullItem = DetailItem();
|
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() {
|
func loadData() {
|
||||||
unlockOrientations()
|
|
||||||
if(_viewDidLoad.wrappedValue == true) {
|
if(_viewDidLoad.wrappedValue == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -261,7 +238,11 @@ struct MovieItemView: View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if(playing) {
|
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 {
|
} else {
|
||||||
LoadingView(isShowing: $isLoading) {
|
LoadingView(isShowing: $isLoading) {
|
||||||
VStack(alignment:.leading) {
|
VStack(alignment:.leading) {
|
||||||
|
@ -625,7 +606,7 @@ struct MovieItemView: View {
|
||||||
}
|
}
|
||||||
Spacer().frame(height: 195);
|
Spacer().frame(height: 195);
|
||||||
}.frame(maxHeight: .infinity)
|
}.frame(maxHeight: .infinity)
|
||||||
}.padding(.trailing, 55)
|
}
|
||||||
}.padding(.top, 12).padding(.leading, UIDevice.current.userInterfaceIdiom == .pad ? 16 : 55).edgesIgnoringSafeArea(.leading)
|
}.padding(.top, 12).padding(.leading, UIDevice.current.userInterfaceIdiom == .pad ? 16 : 55).edgesIgnoringSafeArea(.leading)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -634,14 +615,13 @@ struct MovieItemView: View {
|
||||||
}
|
}
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.navigationTitle(fullItem.Name)
|
.navigationTitle(fullItem.Name)
|
||||||
.withHostingWindow() { window in
|
.introspectTabBarController { (UITabBarController) in
|
||||||
let rootVC = window?.rootViewController;
|
|
||||||
let UIHostingcontroller: PreferenceUIHostingController = rootVC as! PreferenceUIHostingController;
|
|
||||||
vc = UIHostingcontroller;
|
|
||||||
}.introspectTabBarController { (UITabBarController) in
|
|
||||||
UITabBarController.tabBar.isHidden = false
|
UITabBarController.tabBar.isHidden = false
|
||||||
}
|
}
|
||||||
}.onAppear(perform: loadData).supportedOrientations(.allButUpsideDown)
|
}.onAppear(perform: loadData)
|
||||||
|
.supportedOrientations(.allButUpsideDown)
|
||||||
|
.overrideViewPreference(.unspecified)
|
||||||
|
.prefersHomeIndicatorAutoHidden(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -490,10 +490,7 @@ struct VideoPlayerView: View {
|
||||||
.onAppear(perform: startStream)
|
.onAppear(perform: startStream)
|
||||||
.navigationBarHidden(true)
|
.navigationBarHidden(true)
|
||||||
.navigationBarBackButtonHidden(true)
|
.navigationBarBackButtonHidden(true)
|
||||||
.prefersHomeIndicatorAutoHidden(true)
|
|
||||||
.edgesIgnoringSafeArea(.all)
|
.edgesIgnoringSafeArea(.all)
|
||||||
.supportedOrientations(.landscapeRight)
|
|
||||||
.preferredColorScheme(.dark)
|
|
||||||
.introspectTabBarController { (UITabBarController) in
|
.introspectTabBarController { (UITabBarController) in
|
||||||
UITabBarController.tabBar.isHidden = true
|
UITabBarController.tabBar.isHidden = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue