Need to create a grid of images with SwiftUI, that dynamically change rows according to screen width.
When I use List
, I can only get one column..
I tried Hstacks to make 2 columns, but then it doesn't work dynamically for screen width.
Ex: iPhone portrait should have 1 column Ex: iPhone landscape should have 2 column
import SwiftUI
struct ProductGrid : View {
var body: some View {
List(0 ..< 5) { item in
VStack() {
Image("product")
HStack {
ProfileImageSmall()
VStack {
Text("Product")
Text("Username")
}
}
}
}
}
}
How can I make a grid that column count adapts to screen width?