Reorderable icon indicating copy to clipboard operation
Reorderable copied to clipboard

Extract drag detection logic to interface

Open toasterofbread opened this issue 10 months ago • 0 comments

Currently, only two hardcoded types of dragging (press and long press) are supported by this library.

This PR adds an interface, DragGestureDetector, which is responsible for handling drag detection via PointerInputScope. The interface is taken as a parameter in drag handle functions such as draggableHandle, allowing the user to override the behaviour. This is useful for applications that wish to use non-standard drag detection, such as dragging with middle click or waiting for a long press using a specific length.

API changes (let me know if you'd rather these were reverted):

  • draggableHandle methods now have a dragGestureDetector parameter in the last position (with a default value)
  • The onDragStarted and onDragStopped parameters of ReorderableScope.draggableHandle are no longer suspending and do not have CoroutineScope as a receiver

The longPressDraggableHandle API is kept the same, but now just calls draggableHandle with DragGestureDetector.LongPress as the dragGestureDetector.

toasterofbread avatar Feb 04 '25 20:02 toasterofbread