|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 拖动上下文context的封装
|
|
|
|
public class Draggable<T> : StatefulWidget { |
|
|
|
public Draggable( |
|
|
|
Key key = null, |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 针对长按的Draggable的子类
|
|
|
|
public class LongPressDraggable<T> : Draggable<T> { |
|
|
|
public LongPressDraggable( |
|
|
|
Key key = null, |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 动作的分发,_DragAvatar的创建
|
|
|
|
// depend: _DragAvatar, DraggableDetails
|
|
|
|
public class _DraggableState<T> : State<Draggable<T>> { |
|
|
|
public override void initState() { |
|
|
|
base.initState(); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 记录一些drag的细节信息:速度,偏移
|
|
|
|
public class DraggableDetails { |
|
|
|
public DraggableDetails( |
|
|
|
bool wasAccepted = false, |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 托管函数的封装
|
|
|
|
public class DragTarget<T> : StatefulWidget { |
|
|
|
public DragTarget( |
|
|
|
Key key = null, |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 管理被拖动的对象(_DragAvatar)
|
|
|
|
// 依赖于_DragAvatar, DragTarget
|
|
|
|
public class _DragTargetState<T> : State<DragTarget<T>> { |
|
|
|
readonly List<_DragAvatar<T>> _candidateAvatars = new List<_DragAvatar<T>>(); |
|
|
|
readonly List<_DragAvatar<T>> _rejectedAvatars = new List<_DragAvatar<T>>(); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public delegate void _OnDragEnd(Velocity velocity, Offset offset, bool wasAccepted); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 被拖动的对象的封装
|
|
|
|
// 依赖于_DragTargetState
|
|
|
|
public class _DragAvatar<T> : Drag { |
|
|
|
public _DragAvatar( |
|
|
|
OverlayState overlayState, |
|
|
|