Hello,
I am unable to move multiple rows in a list, it only allows for one at a time. However, I am able to select multiple rows.
Here is my code:
import SwiftUI
struct ContentView: View {
@State var items = ["Test 1", "Test 2", "Test 3", "Test 4", "Test 5", "Test 6"]
@State var selectedItems: Set<String> = .init()
var body: some View {
NavigationView {
List(selection: $selectedItems) {
ForEach(items, id: \.self) { item in
Text(item).tag(item)
}
.onMove(perform: { indices, newOffset in
withAnimation {
self.items.move(fromOffsets: indices, toOffset: newOffset)
}
})
}
#if os(iOS)
.navigationBarItems(trailing: EditButton())
#endif
}
.padding()
}
}
I need all the selected rows to move when dragged.
Any help would be greatly appreciated, I have tried, and can not find any way to do it.
Thanks, Dev_101