Re-orderable items in a ScrollView?

I would have thought this was trivial to do in SwiftUI, but apparently not.

Imagine a list of Items, each with some text in, within a ScrollView or something which scrolls (VStack maybe). The list goes off the screen so the user can scroll to see the bottom.

I want to be able to re-order that list as well, by dragging Items. Let's assume a one sec delay before it lets you 'pick up' the Item, and then drag to re-order. The delay is so as not to conflict with scrolling. And the dragged item should look exactly like the non-dragged item (except maybe a shadow or outline or something)

Is this possible with SwiftUI?

You can use List with an onMove modifier:

struct MyView: View {
    @State var data = [1, 2, 3, 4, 5]
    var body: some View {
        List {
            ForEach(0..<data.count, id: \.self) { i in
                Text(String(data[i]))
            }
            .onMove { source, destination in
                data.move(fromOffsets: source, toOffset: destination)
            }
        }
    }
}


WindowsMEMZ @ Darock Studio
let myEmail = "memz" + "1" + "@" + "darock.top"

Re-orderable items in a ScrollView?
 
 
Q