Issue #508
We need to use frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
. Note that order is important, and padding
should be first, and background
after frame
to apply color to the entire frame
struct BooksScreen: View {
@ObservedObject var viewModel: BooksViewModel
var body: some View {
List {
ForEach(viewModel.books) { book in
RowView(vault: book)
}
}
.listStyle(GroupedListStyle())
}
}
private struct RowView: View {
let book: Book
var body: some View {
VStack(alignment: .leading) {
Text(book.name)
.foregroundColor(.white)
.font(.headline)
Text(book.text)
.foregroundColor(.white)
.font(.subheadline)
}
.padding()
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
.background(Color(hex: book.color))
.cornerRadius(8)
}
}