This repository showcases a generic drag list implemented in SwiftUI for iOS. The drag list allows users to reorder list items by dragging and dropping them into the desired position. This implementation leverages the powerful features of SwiftUI, enabling easy customization and integration into iOS apps.
- Intuitive Reordering: Users can intuitively reorder list items by dragging them with a drag gesture.
- Simple Customization: The list is designed to be highly customizable, allowing developers to specify the content of list items through a closure.
- SwiftUI Compatibility: It harnesses SwiftUI features for an efficient and modern implementation.
- DragList.swift: The main component implementing the generic drag list.
- DropViewDelegate.swift: A SwiftUI drop delegate that handles drop operations, proposing a move operation when a drop enters, performing the drop action by swapping items, and animating the rearrangement of items in the drop target.
To integrate the generic drag list into your SwiftUI iOS projects, follow these steps:
- Add the DragList.swift file to your project.
- Define the model for list items by extending DragListItem.
- Use DragList in your SwiftUI view, passing the list of items and a closure to determine the content of each item.
DragList(items: myItems) { item in
// Customize the content of the item here
}
We welcome contributions and enhancements! If you have ideas on how to make this drag list even more powerful or if you encounter any bugs, feel free to submit a pull request or open an issue.
We hope this generic drag list proves useful in your SwiftUI projects!