I’m trying to have a View inside a List occupying the full width of the screen.
The standalone view does. Once in a List, it takes ~60% of the available space.
I tried already to use .frame(minWidth: .infinity)
on the List or on the View, but it does not change anything. I also tried various styles for the List, without success.
<code>struct TodoRow: View {
@Binding var todo: Todo
var body: some View {
Toggle(isOn: $todo.isDone) {
Text(todo.content ?? "")
}
.border(.red)
.toggleStyle(.switch)
}
struct ContentView: View {
@State var td1 = Todo(content: "Hello Todo World 20240706T15:23:42.256Z", isDone: false)
var body: some View {
List {
TodoRow(todo: $td1)
TodoRow(todo: $td1)
}
.border(.green)
TodoRow(todo: $td1)
.border(.blue)
}
}
</code>
<code>struct TodoRow: View {
@Binding var todo: Todo
var body: some View {
Toggle(isOn: $todo.isDone) {
Text(todo.content ?? "")
}
.border(.red)
.toggleStyle(.switch)
}
struct ContentView: View {
@State var td1 = Todo(content: "Hello Todo World 20240706T15:23:42.256Z", isDone: false)
var body: some View {
List {
TodoRow(todo: $td1)
TodoRow(todo: $td1)
}
.border(.green)
TodoRow(todo: $td1)
.border(.blue)
}
}
</code>
struct TodoRow: View {
@Binding var todo: Todo
var body: some View {
Toggle(isOn: $todo.isDone) {
Text(todo.content ?? "")
}
.border(.red)
.toggleStyle(.switch)
}
struct ContentView: View {
@State var td1 = Todo(content: "Hello Todo World 20240706T15:23:42.256Z", isDone: false)
var body: some View {
List {
TodoRow(todo: $td1)
TodoRow(todo: $td1)
}
.border(.green)
TodoRow(todo: $td1)
.border(.blue)
}
}
1