Closed simibac closed 4 years ago
Not sure if it's an issue of QGrid
or GeometryReader
in such scenario, but as a quick workaround, this one seems to work as expected: (using GeometryReader
outside of QGrid) :
struct TestView: View {
var body: some View {
GeometryReader{ g in
QGrid(self.data,
columns: 3,
columnsInLandscape: 4,
vSpacing: 0,
hSpacing: 0,
vPadding: 0,
hPadding: 0,
content: {data in
VStack{
Text(data.name)
}
.frame(width:g.size.width / 3, height: g.size.width / 3)
.background(Color.yellow)
.overlay(Rectangle().stroke(Color.blue, lineWidth: 2))
})
}
}
}
When using the GeometryReader inside of a cell, the grid is not rendered as expected. The cells are overlapping as shown in the image below.
Any suggestions how to make sure that every cell is squared, independent from the screen size?