I have varying amount of data that needs to be displayed as per image below, notice how when there is odd amount of data, grid adopts to stretch respected items to span across 2 columns
So far, my best stab at this was to have a LazyVGrid
like this
LazyVGrid(
columns: [GridItem(.adaptive(minimum: thirdOfScreen, maximum: .infinity))],
spacing: 8
) {
// ...
}
here thirdOfScreen
is essentially what it says, a third of the screen width. This was my attempt to force only 2 items per row (used third and not half to account for various paddings between and around items).
This worked to an extent, however if there are 1 or 3 items, they don’t stretch to full width of the row.