Is it possible to "re-order"/"move" items in a ScrollView as one can in a List? I have playground below which compiles/run fine, however the onDelete / onMove does does visualise any delete button or hamburger lines for dragging/moving?
Is there a way to get my code working here so at least the "onMove" concept works?
Note - I note that both List and ScrollView (I think) support protocol DynamicViewContent, so was assuming it should work(?)
Image after running code:
https://i.stack.imgur.com/c5R8g.png
Code (Playgrounds)
import SwiftUI
import PlaygroundSupport
let modelData: [String] = ["Eggs", "Milk", "Bread"]
struct ListTestNoDelete: View {
private func move(from uiStartIndexSet: IndexSet, to uiDestIndex: Int) {
print("On Move")
}
private func delete(at offsets : IndexSet) {
print("On Delete")
}
var body: some View {
NavigationView {
VStack {
ScrollView {
ForEach(modelData, id: \.self) { str in
HStack {
Image(systemName: "square")
Text(str)
Spacer()
}.padding(.horizontal, 3)
}
.onMove(perform: self.move)
.onDelete(perform: self.delete)
}
.environment(\.editMode, .constant(.active))
.navigationBarTitle( Text("Test") )
}
}
}
}
let listTest = ListTestNoDelete()
PlaygroundPage.current.liveView = UIHostingController(rootView: listTest)