I've looked at lots of Grid examples. I've seen it documented that views within a GridRow are treated as if they were in an HStack. That's not happening for me. I have to explicitly put them into an HStack or they are treated as new rows.
Here's my code:
@State private var gridRows : Int = 4
@State private var gridCols : Int = 2
@State private var myItems : [Int] = Array(0...8)
var body: some View
{
Group
{
if myItems.count > 0
{
ScrollView([.vertical])
{
Grid(alignment: .leading)
{
ForEach(0..<gridRows, id: \.self)
{ rowNdx in
GridRow
{
HStack // <<---
{
ForEach(0..<gridCols, id: \.self)
{ colNdx in
Text("\(rowNdx) \(colNdx)")
}
}
}
}
}
}
}
}
}
With the HStack I get (as expected).
0 0 0 1
1 0 1 1
2 0 2 1
3 0 3 1
Without the HStack I get
0 0
0 1
1 0
1 1
...
What have I done wrong?