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,11 +12,12 @@ struct DashboardView: View {
@State var showingSettingsSheet: Bool = false
var body: some View {
NavigationStack {
VStack {
NavigationStack {
DashboardLibraryView()
}
.navigationTitle("Home")
}
}
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button {
@ -31,7 +32,6 @@ struct DashboardView: View {
}
}
}
}
//#Preview {
// DashboardView()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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