Selaa lähdekoodia

chore: fix reset phantom record bug

appflowy 2 vuotta sitten
vanhempi
commit
1ba24c00ba

+ 2 - 3
frontend/app_flowy/packages/flowy_board/example/lib/multi_board_list_example.dart

@@ -14,11 +14,10 @@ class _MultiBoardListExampleState extends State<MultiBoardListExample> {
       debugPrint('Move column from $fromIndex to $toIndex');
     },
     onMoveColumnItem: (columnId, fromIndex, toIndex) {
-      debugPrint('Column:$columnId move item from $fromIndex to $toIndex');
+      debugPrint('Move $columnId:$fromIndex to $columnId:$toIndex');
     },
     onMoveColumnItemToColumn: (fromColumnId, fromIndex, toColumnId, toIndex) {
-      debugPrint(
-          'Column:$fromColumnId move item at $fromIndex to column:$toColumnId $toIndex');
+      debugPrint('Move $fromColumnId:$fromIndex to $toColumnId:$toIndex');
     },
   );
 

+ 1 - 1
frontend/app_flowy/packages/flowy_board/example/lib/single_board_list_example.dart

@@ -56,5 +56,5 @@ class TextItem extends ColumnItem {
   TextItem(this.s);
 
   @override
-  String get id => throw UnimplementedError();
+  String get id => s;
 }

+ 1 - 1
frontend/app_flowy/packages/flowy_board/lib/src/widgets/board_data.dart

@@ -120,7 +120,7 @@ class BoardDataController extends ChangeNotifier
       columnController.removeAt(index);
 
       Log.debug(
-          '[$BoardPhantomController] Column$columnId remove phantom, current count: ${columnController.items.length}');
+          '[$BoardDataController] Column$columnId remove phantom, current count: ${columnController.items.length}');
     }
     return isExist;
   }

+ 3 - 3
frontend/app_flowy/packages/flowy_board/lib/src/widgets/flex/drag_target.dart

@@ -174,7 +174,7 @@ class _ReorderDragTargetState<T extends DragTargetData>
       transform: Matrix4.rotationZ(0),
       alignment: FractionalOffset.topLeft,
       child: Material(
-        elevation: 2.0,
+        elevation: 3.0,
         color: Colors.transparent,
         borderRadius: BorderRadius.zero,
         clipBehavior: Clip.hardEdge,
@@ -212,10 +212,10 @@ class DragTargetAnimation {
         value: 0, vsync: vsync, duration: reorderAnimationDuration);
 
     insertController = AnimationController(
-        value: 0.0, vsync: vsync, duration: reorderAnimationDuration);
+        value: 0.0, vsync: vsync, duration: const Duration(milliseconds: 100));
 
     deleteController = AnimationController(
-        value: 0.0, vsync: vsync, duration: reorderAnimationDuration);
+        value: 0.0, vsync: vsync, duration: const Duration(milliseconds: 10));
   }
 
   void startDargging() {

+ 7 - 4
frontend/app_flowy/packages/flowy_board/lib/src/widgets/flex/reorder_flex.dart

@@ -328,10 +328,13 @@ class ReorderFlexState extends State<ReorderFlex>
             "[DragTarget]: Column${widget.dataSource.identifier} end dragging");
 
         setState(() {
-          _onReordered(
-            dragState.dragStartIndex,
-            dragState.currentIndex,
-          );
+          if (dragTargetData.reorderFlexId == widget.reorderFlexId) {
+            _onReordered(
+              dragState.dragStartIndex,
+              dragState.currentIndex,
+            );
+          }
+
           dragState.endDragging();
           widget.onDragEnded?.call();
         });

+ 9 - 13
frontend/app_flowy/packages/flowy_board/lib/src/widgets/phantom/phantom_controller.dart

@@ -64,26 +64,22 @@ class BoardPhantomController extends OverlapDragTargetDelegate
   /// Remove the phanton in the column when the column is end dragging.
   void columnEndDragging(String columnId) {
     columnsState.setColumnIsDragging(columnId, true);
-    if (phantomRecord != null) {
-      if (phantomRecord!.fromColumnId == columnId) {
-        columnsState.notifyDidRemovePhantom(phantomRecord!.toColumnId);
-      }
-    }
-    _swapColumnData();
-  }
+    if (phantomRecord == null) return;
 
-  void _swapColumnData() {
-    if (phantomRecord == null) {
-      return;
+    final fromColumnId = phantomRecord!.fromColumnId;
+    final toColumnId = phantomRecord!.toColumnId;
+    if (fromColumnId == columnId) {
+      columnsState.notifyDidRemovePhantom(toColumnId);
     }
 
-    if (columnsState.isDragging(phantomRecord!.fromColumnId) == false) {
+    if (columnsState.isDragging(fromColumnId) == false) {
       return;
     }
+
     delegate.swapColumnItem(
-      phantomRecord!.fromColumnId,
+      fromColumnId,
       phantomRecord!.fromColumnIndex,
-      phantomRecord!.toColumnId,
+      toColumnId,
       phantomRecord!.toColumnIndex,
     );