Pretty newbe question I guess.
Target: A Grid that fills as much horizontal space as possible, that grows vertically.
My approach is using a LazyVGrid with a single GridItem(.adaptive(minimum: 40)).
However, for some reason all LazyVGrid children are given the width of 40, no more, that's why the following bug occurs.
Picture 1
Picture 2
Obviously, I want my the "1123" be represented as one line and be wider than the rest of the numbers, however for the reason I don't understand, in is divided into chunks and is shown as three lines.
Here's my code:
import SwiftUI
struct NumbersViewTest: View {
var numbersAndOperators: [String] {
["+", "-", "*", "/", "1123", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
}
var gridItems: [GridItem] {
[GridItem(.adaptive(minimum: 40, maximum: .infinity))]
}
var body: some View {
LazyVGrid(columns: gridItems) {
ForEach(numbersAndOperators, id: \.self) { text in
ZStack {
Rectangle().stroke()
Text(text)
.font(.largeTitle)
}
}
}
.padding()
}
}
struct NumbersViewTest_Previews: PreviewProvider {
static var previews: some View {
NumbersViewTest()
}
}