From 7c9b443bc72ea30fa3f7e2307b034c71aff7c2dd Mon Sep 17 00:00:00 2001 From: Aiden Vigue Date: Wed, 23 Jun 2021 14:50:30 -0400 Subject: [PATCH] Get rid of spacers on home screen Also, fancify the list view of libraries. --- JellyfinPlayer/ContinueWatchingView.swift | 15 ++-- JellyfinPlayer/HomeView.swift | 40 +++++------ JellyfinPlayer/LatestMediaView.swift | 20 +++--- JellyfinPlayer/LibraryListView.swift | 75 ++++++++++++++++---- JellyfinPlayer/NextUpView.swift | 12 ++-- JellyfinPlayer/VideoPlayer.swift | 14 ---- Shared/ViewModels/LibraryListViewModel.swift | 2 - 7 files changed, 99 insertions(+), 79 deletions(-) diff --git a/JellyfinPlayer/ContinueWatchingView.swift b/JellyfinPlayer/ContinueWatchingView.swift index 13ed6492..f9556d9a 100644 --- a/JellyfinPlayer/ContinueWatchingView.swift +++ b/JellyfinPlayer/ContinueWatchingView.swift @@ -36,14 +36,13 @@ struct ContinueWatchingView: View { var body: some View { ScrollView(.horizontal, showsIndicators: false) { LazyHStack { - Spacer().frame(width: 14) ForEach(items, id: \.id) { item in - NavigationLink(destination: ItemView(item: item)) { + NavigationLink(destination: LazyView { ItemView(item: item) }) { VStack(alignment: .leading) { - Spacer().frame(height: 10) ImageView(src: item.getBackdropImage(maxWidth: 320), bh: item.getBackdropImageBlurHash()) .frame(width: 320, height: 180) .cornerRadius(10) + .shadow(radius: 4) .overlay( Group { if item.type == "Episode" { @@ -70,14 +69,12 @@ struct ContinueWatchingView: View { .foregroundColor(.primary) .lineLimit(1) .frame(width: 320, alignment: .leading) - Spacer().frame(height: 5) - } + }.padding(.top, 10) + .padding(.bottom, 5) } - Spacer().frame(width: 16) - } - Spacer().frame(width: 2) + }.padding(.trailing, 16) }.frame(height: 215) - .padding(.bottom, 10) + .padding(EdgeInsets(top: 8, leading: 20, bottom: 10, trailing: 2)) } } } diff --git a/JellyfinPlayer/HomeView.swift b/JellyfinPlayer/HomeView.swift index ec9b6236..afeec96e 100644 --- a/JellyfinPlayer/HomeView.swift +++ b/JellyfinPlayer/HomeView.swift @@ -12,8 +12,6 @@ import SwiftUI struct HomeView: View { @StateObject var viewModel = HomeViewModel() - @Environment(\.horizontalSizeClass) var hSizeClass - @Environment(\.verticalSizeClass) var vSizeClass @State var showingSettings = false @ViewBuilder @@ -25,36 +23,32 @@ struct HomeView: View { LazyVStack(alignment: .leading) { if !viewModel.resumeItems.isEmpty { ContinueWatchingView(items: viewModel.resumeItems) - .padding(.top, hSizeClass == .compact && vSizeClass == .regular ? 0 : 16) } if !viewModel.nextUpItems.isEmpty { NextUpView(items: viewModel.nextUpItems) } if !viewModel.librariesShowRecentlyAddedIDs.isEmpty { ForEach(viewModel.librariesShowRecentlyAddedIDs, id: \.self) { libraryID in - VStack(alignment: .leading) { - let library = viewModel.libraries.first(where: { $0.id == libraryID }) - HStack { - Text("Latest \(library?.name ?? "")") - .font(.title2) - .fontWeight(.bold) - .padding(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 16)) - Spacer() - NavigationLink(destination: LazyView { - LibraryView(viewModel: .init(parentID: libraryID, filters: viewModel.recentFilterSet), title: library?.name ?? "") - }) { - HStack { - Text("See All").font(.subheadline).fontWeight(.bold) - Image(systemName: "chevron.right").font(Font.subheadline.bold()) - } + let library = viewModel.libraries.first(where: { $0.id == libraryID }) + HStack { + Text("Latest \(library?.name ?? "")") + .font(.title2) + .fontWeight(.bold) + Spacer() + NavigationLink(destination: LazyView { + LibraryView(viewModel: .init(parentID: libraryID, filters: viewModel.recentFilterSet), title: library?.name ?? "") + }) { + HStack { + Text("See All").font(.subheadline).fontWeight(.bold) + Image(systemName: "chevron.right").font(Font.subheadline.bold()) } - }.padding(EdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16)) - LatestMediaView(viewModel: .init(libraryID: libraryID)) - }.padding(EdgeInsets(top: 4, leading: 0, bottom: 0, trailing: 0)) + } + }.padding(.leading, 16) + .padding(.trailing, 16) + LatestMediaView(viewModel: .init(libraryID: libraryID)) } } } - .padding(.top, hSizeClass == .compact && vSizeClass == .regular ? 0 : 16) .padding(.bottom, UIDevice.current.userInterfaceIdiom == .phone ? 20 : 30) } } @@ -63,6 +57,7 @@ struct HomeView: View { var body: some View { innerBody .navigationTitle(MainTabView.Tab.home.localized) + /* .toolbar { ToolbarItemGroup(placement: .navigationBarTrailing) { Button { @@ -75,5 +70,6 @@ struct HomeView: View { .fullScreenCover(isPresented: $showingSettings) { SettingsView(viewModel: SettingsViewModel(), close: $showingSettings) } + */ } } diff --git a/JellyfinPlayer/LatestMediaView.swift b/JellyfinPlayer/LatestMediaView.swift index 0b351c7e..6fa24521 100644 --- a/JellyfinPlayer/LatestMediaView.swift +++ b/JellyfinPlayer/LatestMediaView.swift @@ -8,21 +8,19 @@ import SwiftUI struct LatestMediaView: View { - @ObservedObject var viewModel: LatestMediaViewModel + @StateObject var viewModel: LatestMediaViewModel var body: some View { ScrollView(.horizontal, showsIndicators: false) { LazyHStack { - Spacer().frame(width: 16) ForEach(viewModel.items, id: \.id) { item in if item.type == "Series" || item.type == "Movie" { - NavigationLink(destination: ItemView(item: item)) { + NavigationLink(destination: LazyView { ItemView(item: item) }) { VStack(alignment: .leading) { - Spacer().frame(height: 10) ImageView(src: item.getPrimaryImage(maxWidth: 100), bh: item.getPrimaryImageBlurHash()) .frame(width: 100, height: 150) .cornerRadius(10) - Spacer().frame(height: 5) + .shadow(radius: 4) Text(item.seriesName ?? item.name ?? "") .font(.caption) .fontWeight(.semibold) @@ -35,15 +33,15 @@ struct LatestMediaView: View { .fontWeight(.medium) } else { Text(item.type!) + .foregroundColor(.secondary) + .font(.caption) + .fontWeight(.medium) } }.frame(width: 100) - Spacer().frame(width: 15) } } - } - } - .frame(height: 190) - } - .padding(EdgeInsets(top: -2, leading: 0, bottom: 0, trailing: 0)).frame(height: 190) + }.padding(.trailing, 16) + }.padding(.leading, 20) + }.frame(height: 195) } } diff --git a/JellyfinPlayer/LibraryListView.swift b/JellyfinPlayer/LibraryListView.swift index a4afa775..e527841d 100644 --- a/JellyfinPlayer/LibraryListView.swift +++ b/JellyfinPlayer/LibraryListView.swift @@ -12,27 +12,74 @@ struct LibraryListView: View { @StateObject var viewModel = LibraryListViewModel() var body: some View { - List(viewModel.libraries, id: \.self) { library in - switch library.id { - case "favorites": + ScrollView { + LazyVStack() { NavigationLink(destination: LazyView { - LibraryView(viewModel: .init(filters: viewModel.withFavorites), title: library.name ?? "") + LibraryView(viewModel: .init(filters: viewModel.withFavorites), title: "Favorites") }) { - Text(library.name ?? "") + ZStack() { + HStack() { + Spacer() + Text("Your Favorites") + .foregroundColor(.black) + .font(.subheadline) + .fontWeight(.semibold) + Spacer() + } + } + .padding(16) + .background(Color.white) + .frame(minWidth: 100, maxWidth: .infinity) } - case "genres": + .cornerRadius(10) + .shadow(radius: 5) + .padding(.bottom, 5) + NavigationLink(destination: LazyView { - EmptyView() + Text("WIP") }) { - Text(library.name ?? "") + ZStack() { + HStack() { + Spacer() + Text("All Genres") + .foregroundColor(.black) + .font(.subheadline) + .fontWeight(.semibold) + Spacer() + } + } + .padding(16) + .background(Color.white) + .frame(minWidth: 100, maxWidth: .infinity) } - default: - NavigationLink(destination: LazyView { - LibraryView(viewModel: .init(parentID: library.id), title: library.name ?? "") - }) { - Text(library.name ?? "") + .cornerRadius(10) + .shadow(radius: 5) + .padding(.bottom, 15) + + ForEach(viewModel.libraries, id: \.id) { library in + NavigationLink(destination: LazyView { + LibraryView(viewModel: .init(parentID: library.id), title: library.name ?? "") + }) { + ZStack() { + ImageView(src: library.getPrimaryImage(maxWidth: 500)) + .opacity(0.4) + HStack() { + Spacer() + Text(library.name ?? "") + .foregroundColor(.white) + .font(.title2) + .fontWeight(.semibold) + Spacer() + }.padding(32) + }.background(Color.black) + .frame(minWidth: 100, maxWidth: .infinity) + } + .cornerRadius(10) + .shadow(radius: 5) + .padding(.bottom, 5) } - } + }.padding(.leading, 16) + .padding(.trailing, 16) } .navigationTitle("All Media") .toolbar { diff --git a/JellyfinPlayer/NextUpView.swift b/JellyfinPlayer/NextUpView.swift index affe57f4..411a1a37 100644 --- a/JellyfinPlayer/NextUpView.swift +++ b/JellyfinPlayer/NextUpView.swift @@ -18,17 +18,16 @@ struct NextUpView: View { Text("Next Up") .font(.title2) .fontWeight(.bold) - .padding(EdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16)) + .padding(.leading, 16) ScrollView(.horizontal, showsIndicators: false) { LazyHStack { - Spacer().frame(width: 16) ForEach(items, id: \.id) { item in - NavigationLink(destination: ItemView(item: item)) { + NavigationLink(destination: LazyView { ItemView(item: item) }) { VStack(alignment: .leading) { ImageView(src: item.getSeriesPrimaryImage(maxWidth: 100), bh: item.getSeriesPrimaryImageBlurHash()) .frame(width: 100, height: 150) .cornerRadius(10) - Spacer().frame(height: 5) + .shadow(radius: 4) Text(item.seriesName!) .font(.caption) .fontWeight(.semibold) @@ -40,13 +39,12 @@ struct NextUpView: View { .foregroundColor(.secondary) .lineLimit(1) }.frame(width: 100) - Spacer().frame(width: 16) } - } + }.padding(.trailing, 16) } + .padding(.leading, 20) } .frame(height: 200) } - .padding(EdgeInsets(top: 4, leading: 0, bottom: 0, trailing: 0)) } } diff --git a/JellyfinPlayer/VideoPlayer.swift b/JellyfinPlayer/VideoPlayer.swift index a8a64a06..f6b11316 100644 --- a/JellyfinPlayer/VideoPlayer.swift +++ b/JellyfinPlayer/VideoPlayer.swift @@ -276,14 +276,6 @@ class PlayerViewController: UIViewController, GCKDiscoveryManagerListener, GCKRe self.mainActionButton.setImage(UIImage(systemName: "pause"), for: .normal) } } - - override var supportedInterfaceOrientations: UIInterfaceOrientationMask { - return .landscape - } - - override var shouldAutorotate: Bool { - return false - } func setupNowPlayingCC() { let commandCenter = MPRemoteCommandCenter.shared() @@ -422,12 +414,6 @@ class PlayerViewController: UIViewController, GCKDiscoveryManagerListener, GCKRe overrideUserInterfaceStyle = .dark self.tabBarController?.tabBar.isHidden = true self.navigationController?.isNavigationBarHidden = true - self.setNeedsUpdateOfHomeIndicatorAutoHidden() - - if !UIDevice.current.orientation.isLandscape || UIDevice.current.orientation.isFlat { - let value = UIInterfaceOrientation.landscapeLeft.rawValue - UIDevice.current.setValue(value, forKey: "orientation") - } mediaPlayer.perform(Selector(("setTextRendererFontSize:")), with: 14) // mediaPlayer.wrappedValue.perform(Selector(("setTextRendererFont:")), with: "Copperplate") diff --git a/Shared/ViewModels/LibraryListViewModel.swift b/Shared/ViewModels/LibraryListViewModel.swift index 6fcffe23..a25ae3aa 100644 --- a/Shared/ViewModels/LibraryListViewModel.swift +++ b/Shared/ViewModels/LibraryListViewModel.swift @@ -20,8 +20,6 @@ final class LibraryListViewModel: ViewModel { override init() { super.init() - libraries.append(.init(name: "Favorites", id: "favorites")) - libraries.append(.init(name: "Genres", id: "genres")) requestLibraries() }