@patrick_metcalfe yes
struct ModernStoryCardView: View {
var loadedImage: Image?
let bookCover: BookCover
var body: some View {
ZStack {
VStack {
ZStack(alignment: .topTrailing) {
ImageOrPlaceholder()
// RoundedRectangle(cornerRadius: 8)
HStack {
Image(systemName: "star.fill")
.foregroundStyle(.yellow)
.imageScale(.small)
Text(bookCover.rating.description)
.foregroundStyle(.yellow)
.textScale(.secondary)
}
.padding(.vertical, 5)
.padding(.horizontal, 5)
.background(.ultraThinMaterial.opacity(0.3))
.clipShape(RoundedRectangle(cornerRadius: 4))
.padding(10)
}
Text(bookCover.title)
.font(.headline)
Text(bookCover.authorName)
.font(.subheadline)
.foregroundStyle(.primary)
}
}
.containerRelativeFrame(.horizontal, count: 1, spacing: 10)
.frame(height: 300)
}
@ViewBuilder private func ImageOrPlaceholder() -> some View {
if let loadedImage {
loadedImage
.resizable()
.aspectRatio(9/16, contentMode: .fill)
.cornerRadius(8)
} else {
Image(systemName: "photo")
.resizable()
.aspectRatio(9/16, contentMode: .fill)
.foregroundStyle(.gray)
}
}
}
struct TextRoundedRectangleView: View {
let text: String
let color: Color
var body: some View {
Text(text)
.foregroundStyle(.primary)
.padding(.horizontal, 10)
.background(color.opacity(0.6))
.containerShape(RoundedRectangle(cornerRadius: 8))
.lineLimit(1)
}
}