I have the following code
struct ContentView: View {
var items = ["1", "2", "3", "4"]
var body: some View {
LazyVGrid(columns: [GridItem(), GridItem()]) {
ForEach(items, id: \.self) { item in
GeometryReader { geometry in
Text(item)
.frame(width: geometry.size.width, height: geometry.size.width)
.background(.red)
}
}
}.background(.green)
}
}
and I am getting the following screen
What I expected is 4 square grid items but as you can see the grid items are stacked on top of each other and LazyVGrid is not resizing which you can see the green colored
If I remove GeometryReader and set frame(width: height:) to some static number it's working but I would like to set it dynamically based on screen size