Here is my code simplified.
Is there any way I can add an .onMove or .onDelete modifier to the ForEach and have those actions work when editing, or something else similar (maybe implementing a List to make it work)?
If not, is there a workaround for the move action (since I already have a delete action workaround)?
Thanks in advance for any solutions.
Code Block Swift struct TileView: View { @Binding var editMode: EditMode var columns = [GridItem(.adaptive(minimum: UIScreen.main.bounds.width / 4))] var body: some View { LazyVGrid(columns: columns, spacing: 16) { ForEach(0 ..< 5, id: \.self) { num in ZStack(alignment: .topLeading) { GroupBox(label: Text("Label")) { Text("Content") } .contextMenu { Button { } label: { Label("Delete", systemImage: "trash") } } // this is the work around for the delete action if editMode == .active { Button { } label: { Label("Delete", systemImage: "minus.circle.fill") .imageScale(.large) .foregroundColor(Color(.systemRed)) .backgroundColor(Color(.systemFill) .clipShape(Circle()) .labelStyle(IconOnlyLabelStyle()) .offset(x: -10, y: -10) } } } .padding(.horizontal, 4) } } } .padding(.horizontal) } }
Is there any way I can add an .onMove or .onDelete modifier to the ForEach and have those actions work when editing, or something else similar (maybe implementing a List to make it work)?
If not, is there a workaround for the move action (since I already have a delete action workaround)?
Thanks in advance for any solutions.