|
@@ -59,12 +59,13 @@ class BoardPhantomController extends OverlapDragTargetDelegate
|
|
|
}
|
|
|
|
|
|
void columnStartDragging(String columnId) {
|
|
|
- columnsState.setColumnIsDragging(columnId, false);
|
|
|
+ columnsState.setColumnIsDragging(columnId, true);
|
|
|
}
|
|
|
|
|
|
/// Remove the phantom in the column when the column is end dragging.
|
|
|
void columnEndDragging(String columnId) {
|
|
|
- columnsState.setColumnIsDragging(columnId, true);
|
|
|
+ columnsState.setColumnIsDragging(columnId, false);
|
|
|
+
|
|
|
if (phantomRecord == null) return;
|
|
|
|
|
|
final fromColumnId = phantomRecord!.fromColumnId;
|
|
@@ -73,19 +74,18 @@ class BoardPhantomController extends OverlapDragTargetDelegate
|
|
|
columnsState.notifyDidRemovePhantom(toColumnId);
|
|
|
}
|
|
|
|
|
|
- if (columnsState.isDragging(fromColumnId) == false) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- delegate.swapColumnItem(
|
|
|
- fromColumnId,
|
|
|
- phantomRecord!.fromColumnIndex,
|
|
|
- toColumnId,
|
|
|
- phantomRecord!.toColumnIndex,
|
|
|
- );
|
|
|
+ if (phantomRecord!.toColumnId == columnId) {
|
|
|
+ delegate.swapColumnItem(
|
|
|
+ fromColumnId,
|
|
|
+ phantomRecord!.fromColumnIndex,
|
|
|
+ toColumnId,
|
|
|
+ phantomRecord!.toColumnIndex,
|
|
|
+ );
|
|
|
|
|
|
- Log.debug("[$BoardPhantomController] did move ${phantomRecord.toString()}");
|
|
|
- phantomRecord = null;
|
|
|
+ Log.debug(
|
|
|
+ "[$BoardPhantomController] did move ${phantomRecord.toString()}");
|
|
|
+ phantomRecord = null;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// Remove the phantom in the column if it contains phantom
|
|
@@ -113,7 +113,7 @@ class BoardPhantomController extends OverlapDragTargetDelegate
|
|
|
PhantomColumnItem(phantomContext),
|
|
|
);
|
|
|
|
|
|
- columnsState.notifyDidInsertPhantom(toColumnId);
|
|
|
+ columnsState.notifyDidInsertPhantom(toColumnId, phantomIndex);
|
|
|
}
|
|
|
|
|
|
/// Reset or initial the [PhantomRecord]
|
|
@@ -128,8 +128,9 @@ class BoardPhantomController extends OverlapDragTargetDelegate
|
|
|
FlexDragTargetData dragTargetData,
|
|
|
int dragTargetIndex,
|
|
|
) {
|
|
|
- // Log.debug('[$BoardPhantomController] move Column:[${dragTargetData.reorderFlexId}]:${dragTargetData.draggingIndex} '
|
|
|
- // 'to Column:[$columnId]:$index');
|
|
|
+ // Log.debug(
|
|
|
+ // '[$BoardPhantomController] move Column:[${dragTargetData.reorderFlexId}]:${dragTargetData.draggingIndex} '
|
|
|
+ // 'to Column:[$columnId]:$dragTargetIndex');
|
|
|
|
|
|
phantomRecord = PhantomRecord(
|
|
|
toColumnId: columnId,
|
|
@@ -202,8 +203,23 @@ class BoardPhantomController extends OverlapDragTargetDelegate
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
- bool canMoveTo(String dragTargetId) {
|
|
|
- return delegate.controller(dragTargetId)?.columnData.items.isEmpty ?? false;
|
|
|
+ int canMoveTo(String dragTargetId) {
|
|
|
+ // if (columnsState.isDragging(dragTargetId)) {
|
|
|
+ // return -1;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // final controller = delegate.controller(dragTargetId);
|
|
|
+ // if (controller != null) {
|
|
|
+ // return controller.columnData.items.length;
|
|
|
+ // } else {
|
|
|
+ // return 0;
|
|
|
+ // }
|
|
|
+
|
|
|
+ if (delegate.controller(dragTargetId)?.columnData.items.isEmpty ?? false) {
|
|
|
+ return 0;
|
|
|
+ } else {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -294,7 +310,7 @@ class PassthroughPhantomContext extends FakeDragTargetEventTrigger
|
|
|
AFColumnItem get itemData => dragTargetData.reorderFlexItem as AFColumnItem;
|
|
|
|
|
|
@override
|
|
|
- VoidCallback? onInserted;
|
|
|
+ void Function(int?)? onInserted;
|
|
|
|
|
|
@override
|
|
|
VoidCallback? onDragEnded;
|
|
@@ -308,6 +324,11 @@ class PassthroughPhantomContext extends FakeDragTargetEventTrigger
|
|
|
void fakeOnDragEnded(VoidCallback callback) {
|
|
|
onDragEnded = callback;
|
|
|
}
|
|
|
+
|
|
|
+ @override
|
|
|
+ void fakeOnDragStart(void Function(int? index) callback) {
|
|
|
+ onInserted = callback;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
class PassthroughPhantomWidget extends PhantomWidget {
|