SwiftUI IOS: Editable list in a form?

577 Views Asked by At

I would like to make my list in a form editable and sortable with the editMode. I've already tried using .environment(.editMode, .constant(.active)) on the list or on the ForEach loop, but unfortunately that didn't work. I'm happy about help.

What I want:

https://youtube.com/shorts/vSE6g-NVuE4?feature=share

Current code:

                        Form {
                            ForEach(elements, id: \.id) { element in
                                Text(element.name)
                            }
                            .onMove(perform: { _, _ in
                                
                            })
                            .onDelete(perform: { _ in
                                
                            })
                            .listRowSeparator(.hidden, edges: .bottom)
                            .environment(\.editMode, .constant(.active))
                        }
0

There are 0 best solutions below