Refactoring + make itemInfo more visible

This commit is contained in:
Shav Kinderlehrer 2023-12-27 13:07:20 -05:00
parent 7aa602f19d
commit b7a1bd1d55
7 changed files with 27 additions and 23 deletions

View File

@ -12,23 +12,23 @@ struct DashboardView: View {
@State var showingSettingsSheet: Bool = false @State var showingSettingsSheet: Bool = false
var body: some View { var body: some View {
NavigationStack { VStack {
VStack { NavigationStack {
DashboardLibraryView() DashboardLibraryView()
.navigationTitle("Home")
} }
.navigationTitle("Home") }
.toolbar { .toolbar {
ToolbarItem(placement: .topBarTrailing) { ToolbarItem(placement: .topBarTrailing) {
Button { Button {
showingSettingsSheet.toggle() showingSettingsSheet.toggle()
} label: { } label: {
Label("Settings", systemImage: "gear") Label("Settings", systemImage: "gear")
}
} }
} }
.sheet(isPresented: $showingSettingsSheet) { }
SettingsView(showingSettingsView: $showingSettingsSheet) .sheet(isPresented: $showingSettingsSheet) {
} SettingsView(showingSettingsView: $showingSettingsSheet)
} }
} }
} }

View File

@ -22,12 +22,10 @@ struct ItemHeaderView: View {
ZStack(alignment: .bottom) { ZStack(alignment: .bottom) {
StickyHeaderView(minHeight: 300) { StickyHeaderView(minHeight: 300) {
LibraryIconView(library: item, imageType: "Backdrop", contentMode: .fill) LibraryIconView(library: item, imageType: "Backdrop", contentMode: .fill)
.hideCaption()
.setCornerRadius(0) .setCornerRadius(0)
.mask(overlayGradient) .mask(overlayGradient)
.background { .background {
LibraryIconView(library: item, imageType: "Backdrop", contentMode: .fill) LibraryIconView(library: item, imageType: "Backdrop", contentMode: .fill)
.hideCaption()
.setCornerRadius(0) .setCornerRadius(0)
.blur(radius: 50) .blur(radius: 50)
} }
@ -35,7 +33,6 @@ struct ItemHeaderView: View {
HStack { HStack {
LibraryIconView(library: item, imageType: "Logo", width: 200, height: 100, placeHolder: AnyView(Text(item.name ?? "Unknown").font(.title).bold().truncationMode(.middle))) LibraryIconView(library: item, imageType: "Logo", width: 200, height: 100, placeHolder: AnyView(Text(item.name ?? "Unknown").font(.title).bold().truncationMode(.middle)))
.hideCaption()
.setCornerRadius(0) .setCornerRadius(0)
.shadow(radius: 10) .shadow(radius: 10)
.frame(alignment: .leading) .frame(alignment: .leading)

View File

@ -15,10 +15,14 @@ struct ItemInfoView: View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
HStack { HStack {
Text((item.productionYear != nil) ? String(item.productionYear!) : "---") Text((item.productionYear != nil) ? String(item.productionYear!) : "---")
.shadow(color: .black, radius: 1)
Text("") Text("")
.shadow(color: .black, radius: 1)
Text(item.genres?.first ?? "---") Text(item.genres?.first ?? "---")
.shadow(color: .black, radius: 1)
} }
Text(item.getRuntime() ?? "-:--") Text(item.getRuntime() ?? "-:--")
.shadow(color: .black, radius: 1)
} }
.font(.caption) .font(.caption)
} }

View File

@ -46,7 +46,9 @@ struct ItemMediaView: View {
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
.padding(.bottom) .padding(.bottom)
Text(item.overview ?? "---") ForEach(item.overview?.components(separatedBy: "<br>") ?? [], id: \.self) {overview in
Text(overview)
}
} }
.padding() .padding()
} }

View File

@ -15,7 +15,7 @@ struct ItemView: View {
case .movie: case .movie:
ItemMovieView(item: item) ItemMovieView(item: item)
default: default:
Text("Unkown media") ItemMediaView(item: item)
} }
} }
} }

View File

@ -39,7 +39,8 @@ struct LibraryDetailView: View {
NavigationLink { NavigationLink {
ItemView(item: item) ItemView(item: item)
} label: { } label: {
LibraryIconView(library: item, imageType: "Primary", width: 170) LibraryIconView(library: item, imageType: "Primary", width: 150)
.showCaption()
.setAspectRatio(item.primaryImageAspectRatio ?? 0.6) .setAspectRatio(item.primaryImageAspectRatio ?? 0.6)
.padding() .padding()

View File

@ -24,10 +24,10 @@ struct LibraryIconView: View {
@State var placeHolder: AnyView? @State var placeHolder: AnyView?
var shouldShowCaption: Bool = true var shouldShowCaption: Bool = false
var imageCornerRadius: CGFloat = 5 var imageCornerRadius: CGFloat = 5
var body: some View { var body: some View {
VStack { VStack(alignment: .leading) {
LazyImage(url: imageUrl) {state in LazyImage(url: imageUrl) {state in
if let image = state.image { if let image = state.image {
image image
@ -60,9 +60,9 @@ struct LibraryIconView: View {
} }
} }
} }
func hideCaption(_ isHidden: Bool = true) -> Self { func showCaption(_ showCaption: Bool = true) -> Self {
var copy = self var copy = self
copy.shouldShowCaption = !isHidden copy.shouldShowCaption = showCaption
return copy return copy
} }