I want to present a table using SwiftUI. I've gotten most of the way using LazyVGrid.
Problem 1 is the last row's frame paints below the LazyVGrid frame when the last cell is taller than the others.
Problem 2 is the last column shows multiline text. All cells on that row should be aligned using VerticalAlignment.firstTextbaseline. What happens is all of the cells end up vertically aligned.
private var columns: [GridItem] = [
GridItem(.fixed(25)),
GridItem(.fixed(25)),
GridItem(.fixed(30), alignment: .trailing),
GridItem(.flexible())
]
var body: some View {
LazyVGrid(columns: columns, alignment: .leading) {
ForEach(rows) { row in
Text(row.a)
Text("#\(row.b)")
Text("(\(row.c))")
Text(row.d)
.multilineTextAlignment(.leading)
.lineLimit(nil)
}
}
}
I explored using custom alignment guides istead of LazyVGrid, but I don't know how to apply more than one guide to achieve the effect of tab stops for each column.