I have the following view:
var body: some View {
HStack(
alignment: .top
) {
// List {
ForEach(taskLists, id: \.self) { list in
VStack(alignment: .leading) {
TaskListView(list: list)
.padding(10)
}
}
.onMove { indices, newOffset in
print("mooooooooove")
}
}
//}
}
So, it is a horizontal stack of several VStacks. This works fine (e.g):
■ ■ ■
Now, I want to wrap ForEach
with the List
to enable the drag-n-drop. When I uncomment the lines in the above code, the view changes to the vertical stack of the inner VStacks, i.e. they are now one above the other:
■
■
■
How can I use List&ForEach and remain the horizontal stack AND to enable the onMove()
?
Please note that putting List
before HStack
gives the correct view, but the method onMove
is not being called.