|
@@ -1,3 +1,4 @@
|
|
|
|
+import 'package:appflowy_board/appflowy_board.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
|
|
import '../../utils/log.dart';
|
|
import '../../utils/log.dart';
|
|
@@ -39,8 +40,12 @@ class BoardPhantomController extends OverlapDragTargetDelegate
|
|
with CrossReorderFlexDragTargetDelegate {
|
|
with CrossReorderFlexDragTargetDelegate {
|
|
PhantomRecord? phantomRecord;
|
|
PhantomRecord? phantomRecord;
|
|
final BoardPhantomControllerDelegate delegate;
|
|
final BoardPhantomControllerDelegate delegate;
|
|
- final columnsState = ColumnPhantomStateController();
|
|
|
|
- BoardPhantomController({required this.delegate});
|
|
|
|
|
|
+ final BoardColumnsState columnsState;
|
|
|
|
+ final phantomState = ColumnPhantomState();
|
|
|
|
+ BoardPhantomController({
|
|
|
|
+ required this.delegate,
|
|
|
|
+ required this.columnsState,
|
|
|
|
+ });
|
|
|
|
|
|
bool isFromColumn(String columnId) {
|
|
bool isFromColumn(String columnId) {
|
|
if (phantomRecord != null) {
|
|
if (phantomRecord != null) {
|
|
@@ -59,19 +64,19 @@ class BoardPhantomController extends OverlapDragTargetDelegate
|
|
}
|
|
}
|
|
|
|
|
|
void columnStartDragging(String columnId) {
|
|
void columnStartDragging(String columnId) {
|
|
- columnsState.setColumnIsDragging(columnId, true);
|
|
|
|
|
|
+ phantomState.setColumnIsDragging(columnId, true);
|
|
}
|
|
}
|
|
|
|
|
|
/// Remove the phantom in the column when the column is end dragging.
|
|
/// Remove the phantom in the column when the column is end dragging.
|
|
void columnEndDragging(String columnId) {
|
|
void columnEndDragging(String columnId) {
|
|
- columnsState.setColumnIsDragging(columnId, false);
|
|
|
|
|
|
+ phantomState.setColumnIsDragging(columnId, false);
|
|
|
|
|
|
if (phantomRecord == null) return;
|
|
if (phantomRecord == null) return;
|
|
|
|
|
|
final fromColumnId = phantomRecord!.fromColumnId;
|
|
final fromColumnId = phantomRecord!.fromColumnId;
|
|
final toColumnId = phantomRecord!.toColumnId;
|
|
final toColumnId = phantomRecord!.toColumnId;
|
|
if (fromColumnId == columnId) {
|
|
if (fromColumnId == columnId) {
|
|
- columnsState.notifyDidRemovePhantom(toColumnId);
|
|
|
|
|
|
+ phantomState.notifyDidRemovePhantom(toColumnId);
|
|
}
|
|
}
|
|
|
|
|
|
if (phantomRecord!.toColumnId == columnId) {
|
|
if (phantomRecord!.toColumnId == columnId) {
|
|
@@ -82,8 +87,8 @@ class BoardPhantomController extends OverlapDragTargetDelegate
|
|
phantomRecord!.toColumnIndex,
|
|
phantomRecord!.toColumnIndex,
|
|
);
|
|
);
|
|
|
|
|
|
- Log.debug(
|
|
|
|
- "[$BoardPhantomController] did move ${phantomRecord.toString()}");
|
|
|
|
|
|
+ // Log.debug(
|
|
|
|
+ // "[$BoardPhantomController] did move ${phantomRecord.toString()}");
|
|
phantomRecord = null;
|
|
phantomRecord = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -91,8 +96,8 @@ class BoardPhantomController extends OverlapDragTargetDelegate
|
|
/// Remove the phantom in the column if it contains phantom
|
|
/// Remove the phantom in the column if it contains phantom
|
|
void _removePhantom(String columnId) {
|
|
void _removePhantom(String columnId) {
|
|
if (delegate.removePhantom(columnId)) {
|
|
if (delegate.removePhantom(columnId)) {
|
|
- columnsState.notifyDidRemovePhantom(columnId);
|
|
|
|
- columnsState.removeColumnListener(columnId);
|
|
|
|
|
|
+ phantomState.notifyDidRemovePhantom(columnId);
|
|
|
|
+ phantomState.removeColumnListener(columnId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -105,7 +110,7 @@ class BoardPhantomController extends OverlapDragTargetDelegate
|
|
index: phantomIndex,
|
|
index: phantomIndex,
|
|
dragTargetData: dragTargetData,
|
|
dragTargetData: dragTargetData,
|
|
);
|
|
);
|
|
- columnsState.addColumnListener(toColumnId, phantomContext);
|
|
|
|
|
|
+ phantomState.addColumnListener(toColumnId, phantomContext);
|
|
|
|
|
|
delegate.insertPhantom(
|
|
delegate.insertPhantom(
|
|
toColumnId,
|
|
toColumnId,
|
|
@@ -113,7 +118,7 @@ class BoardPhantomController extends OverlapDragTargetDelegate
|
|
PhantomColumnItem(phantomContext),
|
|
PhantomColumnItem(phantomContext),
|
|
);
|
|
);
|
|
|
|
|
|
- columnsState.notifyDidInsertPhantom(toColumnId, phantomIndex);
|
|
|
|
|
|
+ phantomState.notifyDidInsertPhantom(toColumnId, phantomIndex);
|
|
}
|
|
}
|
|
|
|
|
|
/// Reset or initial the [PhantomRecord]
|
|
/// Reset or initial the [PhantomRecord]
|
|
@@ -150,7 +155,8 @@ class BoardPhantomController extends OverlapDragTargetDelegate
|
|
if (phantomRecord == null) {
|
|
if (phantomRecord == null) {
|
|
_resetPhantomRecord(reorderFlexId, dragTargetData, dragTargetIndex);
|
|
_resetPhantomRecord(reorderFlexId, dragTargetData, dragTargetIndex);
|
|
_insertPhantom(reorderFlexId, dragTargetData, dragTargetIndex);
|
|
_insertPhantom(reorderFlexId, dragTargetData, dragTargetIndex);
|
|
- return false;
|
|
|
|
|
|
+
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
final isNewDragTarget = phantomRecord!.toColumnId != reorderFlexId;
|
|
final isNewDragTarget = phantomRecord!.toColumnId != reorderFlexId;
|
|
@@ -204,7 +210,7 @@ class BoardPhantomController extends OverlapDragTargetDelegate
|
|
|
|
|
|
@override
|
|
@override
|
|
int getInsertedIndex(String dragTargetId) {
|
|
int getInsertedIndex(String dragTargetId) {
|
|
- if (columnsState.isDragging(dragTargetId)) {
|
|
|
|
|
|
+ if (phantomState.isDragging(dragTargetId)) {
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -243,8 +249,7 @@ class PhantomRecord {
|
|
if (fromColumnIndex == index) {
|
|
if (fromColumnIndex == index) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- Log.debug(
|
|
|
|
- '[$PhantomRecord] Update Column:[$fromColumnId] remove position to $index');
|
|
|
|
|
|
+
|
|
fromColumnIndex = index;
|
|
fromColumnIndex = index;
|
|
}
|
|
}
|
|
|
|
|