SwiftReorder
SwiftReorder copied to clipboard
expose new delegation APIs and handle cell deletion
This change adds new delegation APIs that:
- expose the gesture moving the cell to allow for further customization of the snapshot at those time
- let the delegate decide whether the cell should be deleted on release
and it ads an example in the demo project.
Thanks for your time putting this together.
I'm wondering if this is enough of a general-purpose feature to merge into the master branch. It seems like a somewhat niche use case, and I'm guessing most end users would want to customize the interaction beyond what the library could usefully provide. It also starts exposing internal details like the gesture recognizer, which might cause issues if the implementation needed to change in the future.
I think we could add hooks for supporting this behavior in a more general way, as well as other custom behaviors users might want to add. Maybe starting with a delegate method like this:
func tableViewShouldFinishReorder(_ tableView: UITableView, from initialSourceIndexPath: IndexPath, to finalDestinationIndexPath: IndexPath, with snapshotView: UIView) -> Bool
which could be overridden by users to perform a custom behavior instead of reordering the cell. (i.e. cancel the reorder, remove the item from the array, reload the tableview.)