import SwiftUI
struct StandardGradientGrid: View {
let spacing: CGFloat = 8
let width: CGFloat = 80 // column width
// 8 columns
var columns: [GridItem] {
// โญ๏ธ last GridItem's spacing is ignored.
Array(
repeating: GridItem(
.fixed(width), // โญ๏ธ fixed width
spacing: spacing+6 // spacing to next column
),
count: 8
)
}
var body: some View {
// โญ๏ธ lazy v grid
LazyVGrid(columns: columns, spacing: spacing) { // spacing between rows
ForEach(Color.standardColors, id: \.self) { color in
Swatch(name: color.name, size: 80) { color.gradient }
}
}.padding()
}
}
// previews
struct StandardGradientGrid_Previews: PreviewProvider {
static var previews: some View {
StandardGradientGrid()
}
}