From b7a1bd1d558eb954968668b8d69358d4d9faaa23 Mon Sep 17 00:00:00 2001 From: Shav Kinderlehrer Date: Wed, 27 Dec 2023 13:07:20 -0500 Subject: [PATCH] Refactoring + make itemInfo more visible --- Jel/Views/Dashboard/DashboardView.swift | 26 ++++++++++----------- Jel/Views/Library/Item/ItemHeaderView.swift | 3 --- Jel/Views/Library/Item/ItemInfoView.swift | 4 ++++ Jel/Views/Library/Item/ItemMediaView.swift | 4 +++- Jel/Views/Library/Item/ItemView.swift | 2 +- Jel/Views/Library/LibraryDetailView.swift | 3 ++- Jel/Views/Library/LibraryIconView.swift | 8 +++---- 7 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Jel/Views/Dashboard/DashboardView.swift b/Jel/Views/Dashboard/DashboardView.swift index a29d2f5..b3c223b 100644 --- a/Jel/Views/Dashboard/DashboardView.swift +++ b/Jel/Views/Dashboard/DashboardView.swift @@ -12,23 +12,23 @@ struct DashboardView: View { @State var showingSettingsSheet: Bool = false var body: some View { - NavigationStack { - VStack { + VStack { + NavigationStack { DashboardLibraryView() + .navigationTitle("Home") } - .navigationTitle("Home") - .toolbar { - ToolbarItem(placement: .topBarTrailing) { - Button { - showingSettingsSheet.toggle() - } label: { - Label("Settings", systemImage: "gear") - } + } + .toolbar { + ToolbarItem(placement: .topBarTrailing) { + Button { + showingSettingsSheet.toggle() + } label: { + Label("Settings", systemImage: "gear") } } - .sheet(isPresented: $showingSettingsSheet) { - SettingsView(showingSettingsView: $showingSettingsSheet) - } + } + .sheet(isPresented: $showingSettingsSheet) { + SettingsView(showingSettingsView: $showingSettingsSheet) } } } diff --git a/Jel/Views/Library/Item/ItemHeaderView.swift b/Jel/Views/Library/Item/ItemHeaderView.swift index 2c11719..3930beb 100644 --- a/Jel/Views/Library/Item/ItemHeaderView.swift +++ b/Jel/Views/Library/Item/ItemHeaderView.swift @@ -22,12 +22,10 @@ struct ItemHeaderView: View { ZStack(alignment: .bottom) { StickyHeaderView(minHeight: 300) { LibraryIconView(library: item, imageType: "Backdrop", contentMode: .fill) - .hideCaption() .setCornerRadius(0) .mask(overlayGradient) .background { LibraryIconView(library: item, imageType: "Backdrop", contentMode: .fill) - .hideCaption() .setCornerRadius(0) .blur(radius: 50) } @@ -35,7 +33,6 @@ struct ItemHeaderView: View { HStack { LibraryIconView(library: item, imageType: "Logo", width: 200, height: 100, placeHolder: AnyView(Text(item.name ?? "Unknown").font(.title).bold().truncationMode(.middle))) - .hideCaption() .setCornerRadius(0) .shadow(radius: 10) .frame(alignment: .leading) diff --git a/Jel/Views/Library/Item/ItemInfoView.swift b/Jel/Views/Library/Item/ItemInfoView.swift index 103acf9..f682898 100644 --- a/Jel/Views/Library/Item/ItemInfoView.swift +++ b/Jel/Views/Library/Item/ItemInfoView.swift @@ -15,10 +15,14 @@ struct ItemInfoView: View { VStack(alignment: .leading) { HStack { Text((item.productionYear != nil) ? String(item.productionYear!) : "---") + .shadow(color: .black, radius: 1) Text("•") + .shadow(color: .black, radius: 1) Text(item.genres?.first ?? "---") + .shadow(color: .black, radius: 1) } Text(item.getRuntime() ?? "-:--") + .shadow(color: .black, radius: 1) } .font(.caption) } diff --git a/Jel/Views/Library/Item/ItemMediaView.swift b/Jel/Views/Library/Item/ItemMediaView.swift index 38c242d..a3f653a 100644 --- a/Jel/Views/Library/Item/ItemMediaView.swift +++ b/Jel/Views/Library/Item/ItemMediaView.swift @@ -46,7 +46,9 @@ struct ItemMediaView: View { .frame(maxWidth: .infinity, alignment: .leading) .padding(.bottom) - Text(item.overview ?? "---") + ForEach(item.overview?.components(separatedBy: "
") ?? [], id: \.self) {overview in + Text(overview) + } } .padding() } diff --git a/Jel/Views/Library/Item/ItemView.swift b/Jel/Views/Library/Item/ItemView.swift index d3446af..e3289ba 100644 --- a/Jel/Views/Library/Item/ItemView.swift +++ b/Jel/Views/Library/Item/ItemView.swift @@ -15,7 +15,7 @@ struct ItemView: View { case .movie: ItemMovieView(item: item) default: - Text("Unkown media") + ItemMediaView(item: item) } } } diff --git a/Jel/Views/Library/LibraryDetailView.swift b/Jel/Views/Library/LibraryDetailView.swift index 5b58a4e..1dc0c9c 100644 --- a/Jel/Views/Library/LibraryDetailView.swift +++ b/Jel/Views/Library/LibraryDetailView.swift @@ -39,7 +39,8 @@ struct LibraryDetailView: View { NavigationLink { ItemView(item: item) } label: { - LibraryIconView(library: item, imageType: "Primary", width: 170) + LibraryIconView(library: item, imageType: "Primary", width: 150) + .showCaption() .setAspectRatio(item.primaryImageAspectRatio ?? 0.6) .padding() diff --git a/Jel/Views/Library/LibraryIconView.swift b/Jel/Views/Library/LibraryIconView.swift index 9bd3182..800d488 100644 --- a/Jel/Views/Library/LibraryIconView.swift +++ b/Jel/Views/Library/LibraryIconView.swift @@ -24,10 +24,10 @@ struct LibraryIconView: View { @State var placeHolder: AnyView? - var shouldShowCaption: Bool = true + var shouldShowCaption: Bool = false var imageCornerRadius: CGFloat = 5 var body: some View { - VStack { + VStack(alignment: .leading) { LazyImage(url: imageUrl) {state in if let image = state.image { image @@ -60,9 +60,9 @@ struct LibraryIconView: View { } } } - func hideCaption(_ isHidden: Bool = true) -> Self { + func showCaption(_ showCaption: Bool = true) -> Self { var copy = self - copy.shouldShowCaption = !isHidden + copy.shouldShowCaption = showCaption return copy }