Get rid of spacers on home screen

Also, fancify the list view of libraries.
This commit is contained in:
Aiden Vigue 2021-06-23 14:50:30 -04:00
parent e09c6d1da4
commit 7c9b443bc7
No known key found for this signature in database
GPG Key ID: B9A09843AB079D5B
7 changed files with 99 additions and 79 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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