|
|
|
|
|
|
public class Draggable<T> : StatefulWidget { |
|
|
|
public Draggable( |
|
|
|
T data, |
|
|
|
Widget child, |
|
|
|
Widget feedback, |
|
|
|
Widget child = null, |
|
|
|
Widget feedback = null, |
|
|
|
Axis? axis = null, |
|
|
|
Widget childWhenDragging = null, |
|
|
|
Offset feedbackOffset = null, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class LongPressDraggable<T> : Draggable<T> { |
|
|
|
readonly bool hapticFeedbackOnStart; |
|
|
|
|
|
|
|
Widget child, |
|
|
|
Widget feedback, |
|
|
|
Key key = null, |
|
|
|
Widget child = null, |
|
|
|
Widget feedback = null, |
|
|
|
Key key = null, |
|
|
|
Widget childWhenDragging = null, |
|
|
|
Offset feedbackOffset = null, |
|
|
|
DragAnchor dragAnchor = DragAnchor.child, |
|
|
|
|
|
|
DragEndCallback onDragEnd = null, |
|
|
|
VoidCallback onDragCompleted = null, |
|
|
|
bool hapticFeedbackOnStart = true |
|
|
|
VoidCallback onDragCompleted = null |
|
|
|
) : base( |
|
|
|
key: key, |
|
|
|
child: child, |
|
|
|
|
|
|
onDragEnd: onDragEnd, |
|
|
|
onDragCompleted: onDragCompleted |
|
|
|
) { |
|
|
|
this.hapticFeedbackOnStart = hapticFeedbackOnStart; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public override GestureRecognizer createRecognizer(GestureMultiDragStartCallback onStart) { |
|
|
|
|
|
|
if (result != null && this.hapticFeedbackOnStart) { |
|
|
|
//HapticFeedback.selectionClick();
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
public class DraggableDetails { |
|
|
|
public DraggableDetails( |
|
|
|
Velocity velocity, |
|
|
|
Offset offset, |
|
|
|
bool wasAccepted = false |
|
|
|
bool wasAccepted = false, |
|
|
|
Velocity velocity = null, |
|
|
|
Offset offset = null |
|
|
|
) { |
|
|
|
D.assert(velocity != null); |
|
|
|
D.assert(offset != null); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public bool wasAccepted; |
|
|
|
public readonly bool wasAccepted; |
|
|
|
public Velocity velocity; |
|
|
|
public readonly Velocity velocity; |
|
|
|
public Offset offset; |
|
|
|
public readonly Offset offset; |
|
|
|
DragTargetBuilder<T> builder, |
|
|
|
DragTargetBuilder<T> builder = null, |
|
|
|
D.assert(builder != null); |
|
|
|
this.builder = builder; |
|
|
|
this.onWillAccept = onWillAccept; |
|
|
|
this.onAccept = onAccept; |
|
|
|
|
|
|
public DragTargetBuilder<T> builder; |
|
|
|
public readonly DragTargetBuilder<T> builder; |
|
|
|
public DragTargetWillAccept<T> onWillAccept; |
|
|
|
public readonly DragTargetWillAccept<T> onWillAccept; |
|
|
|
public DragTargetAccept<T> onAccept; |
|
|
|
public readonly DragTargetAccept<T> onAccept; |
|
|
|
public DragTargetLeave<T> onLeave; |
|
|
|
public readonly DragTargetLeave<T> onLeave; |
|
|
|
|
|
|
|
public override State createState() { |
|
|
|
return new _DragTargetState<T>(); |
|
|
|
|
|
|
|
|
|
|
readonly List<_DragTargetState<T>> _enteredTargets = new List<_DragTargetState<T>>(); |
|
|
|
|
|
|
|
OverlayEntry _entry; |
|
|
|
|
|
|
|
Offset _lastOffset; |
|
|
|
|
|
|
|
|
|
|
|
Offset _lastOffset; |
|
|
|
|
|
|
|
OverlayEntry _entry; |
|
|
|
|
|
|
|
public void update(DragUpdateDetails details) { |
|
|
|
this._position += this._restrictAxis(details.delta); |
|
|
|