reorderable()
Enables reordering of views from this content inside the scope of a reorderable container modifier.
Declaration
nonisolated func reorderable() -> some DynamicViewContent<Self.Data>
Mentioned in
Discussion
Declare this modifier on DynamicViewContent within a reorderable container to allow people to reorder the items in the content using a system drag gesture. A reorderable container is a list, stack, grid, or custom layout that you define with the reorderContainer(for:in:isEnabled:move:) modifier.
Use this modifier when you have a single collection in the container. If your container has multiple collections, use DynamicViewContent/reorderable(collectionid:) instead.
The following example shows a list of landmark views that a person can move to reorder inside the VStack:
struct ContentView: View {
@State private var landmarks: [Landmark] = []
var body: some View {
VStack {
ForEach(landmarks) { landmark in
LandmarkView(landmark)
}
.reorderable()
}
.reorderContainer(for: Landmark.self) { difference in
apply(difference: difference)
}
}
}See Also
Reordering items
Making a card game with drag, drop, and reordering in SwiftUIreorderable(collectionID:)ReorderableSingleCollectionIdentifierreorderContainer(for:isEnabled:move:)reorderContainer(for:in:isEnabled:move:)reorderContainer(for:itemID:isEnabled:move:)reorderContainer(for:itemID:in:isEnabled:move:)reorderDestination(for:in:)reorderDestination(for:itemID:in:)ReorderDifference