I'm currently building a ToDo List App in SwiftUI. One feature that I'd really like to implement is the ability to sort your List manually, so I've integrated the functionality using a .onMove
modifier on my ForEach
loop populating my List
, but I still had to toggle EditMode manually, so I set the EditMode of the list to be .active
as follows:
import SwiftUI
struct ContentView: View {
@State private var items = ["1", "2", "3"]
@State var editMode: EditMode = .active
var body: some View {
List {
ForEach(items, id: \.self) { item in
Text("Item \(item)")
}
.onMove(perform: { _, _ in })
}
.environment(\.editMode, $editMode)
}
}
But I'm not happy with this Implementation, as I still have to use the grip from EditMode, and it also breaks SwipeActions as well as Button functionality.
So how can I move List Items without using EditMode?