diff --git a/frontend/app_flowy/lib/plugins/board/application/group_controller.dart b/frontend/app_flowy/lib/plugins/board/application/group_controller.dart index 0ca71ff5f6..942fa872c4 100644 --- a/frontend/app_flowy/lib/plugins/board/application/group_controller.dart +++ b/frontend/app_flowy/lib/plugins/board/application/group_controller.dart @@ -1,7 +1,7 @@ import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-grid/protobuf.dart'; - +import 'package:protobuf/protobuf.dart'; import 'group_listener.dart'; typedef OnGroupError = void Function(FlowyError); @@ -42,7 +42,6 @@ class GroupController { for (final insertedRow in changeset.insertedRows) { final index = insertedRow.hasIndex() ? insertedRow.index : null; - if (insertedRow.hasIndex() && group.rows.length > insertedRow.index) { group.rows.insert(insertedRow.index, insertedRow.row); @@ -50,11 +49,7 @@ class GroupController { group.rows.add(insertedRow.row); } - delegate.insertRow( - group, - insertedRow.row, - index, - ); + delegate.insertRow(group, insertedRow.row, index); } for (final updatedRow in changeset.updatedRows) { @@ -74,6 +69,29 @@ class GroupController { }); } + // GroupChangesetPB _transformChangeset(GroupChangesetPB changeset) { + // final insertedRows = changeset.insertedRows + // .where( + // (delete) => !changeset.deletedRows.contains(delete.row.id), + // ) + // .toList(); + + // final deletedRows = changeset.deletedRows + // .where((deletedRowId) => + // changeset.insertedRows + // .indexWhere((insert) => insert.row.id == deletedRowId) == + // -1) + // .toList(); + + // return changeset.rebuild((rebuildChangeset) { + // rebuildChangeset.insertedRows.clear(); + // rebuildChangeset.insertedRows.addAll(insertedRows); + + // rebuildChangeset.deletedRows.clear(); + // rebuildChangeset.deletedRows.addAll(deletedRows); + // }); + // } + Future dispose() async { _listener.stop(); } diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board.dart index 007a9b82a8..bf8cfa5313 100644 --- a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board.dart +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board.dart @@ -184,7 +184,7 @@ class _AFBoardContentState extends State { ); final reorderFlex = ReorderFlex( - key: widget.key, + key: const PageStorageKey('AFBoardContent'), config: widget.reorderFlexConfig, scrollController: widget.scrollController, onDragStarted: widget.onDragStarted, @@ -242,27 +242,23 @@ class _AFBoardContentState extends State { value: widget.dataController.getColumnController(columnData.id), child: Consumer( builder: (context, value, child) { - final scrollController = - widget.columnState.scrollController(columnData.id); final boardColumn = AFBoardColumnWidget( - key: ValueKey(columnData.id), + key: const PageStorageKey('AFBoardColumnWidget'), margin: _marginFromIndex(columnIndex), itemMargin: widget.config.columnItemPadding, headerBuilder: _buildHeader, footBuilder: widget.footBuilder, cardBuilder: widget.cardBuilder, dataSource: dataSource, - scrollController: scrollController, + scrollController: ScrollController(), phantomController: widget.phantomController, onReorder: widget.dataController.moveColumnItem, cornerRadius: widget.config.cornerRadius, backgroundColor: widget.config.columnBackgroundColor, ); - widget.columnState.addColumn( - columnData.id, - boardColumn.globalKey, - ); + widget.columnState + .addColumn(columnData.id, boardColumn.globalKey); return ConstrainedBox( constraints: widget.columnConstraints, @@ -350,10 +346,4 @@ class BoardColumnState { final widget = flexGlobalKey.currentWidget as ReorderFlex; return widget; } - - ScrollController scrollController(String columnId) { - ScrollController scrollController = ScrollController(); - - return scrollController; - } } diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dart index c4a80bd80b..150e3f8d6f 100644 --- a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dart +++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dart @@ -65,7 +65,6 @@ class AFBoardColumnWidget extends StatefulWidget { final AFBoardColumnDataDataSource dataSource; final ScrollController? scrollController; final ReorderFlexConfig config; - final OnColumnDragStarted? onDragStarted; final OnColumnReorder onReorder; final OnColumnDragEnded? onDragEnded; @@ -88,7 +87,7 @@ class AFBoardColumnWidget extends StatefulWidget { final Color backgroundColor; - final GlobalKey globalKey = GlobalKey(); + final GlobalKey globalKey; AFBoardColumnWidget({ Key? key, @@ -98,14 +97,15 @@ class AFBoardColumnWidget extends StatefulWidget { required this.onReorder, required this.dataSource, required this.phantomController, - this.onDragStarted, this.scrollController, + this.onDragStarted, this.onDragEnded, this.margin = EdgeInsets.zero, this.itemMargin = EdgeInsets.zero, this.cornerRadius = 0.0, this.backgroundColor = Colors.transparent, - }) : config = const ReorderFlexConfig(), + }) : globalKey = GlobalKey(), + config = const ReorderFlexConfig(), super(key: key); @override @@ -115,7 +115,6 @@ class AFBoardColumnWidget extends StatefulWidget { class _AFBoardColumnWidgetState extends State { final GlobalKey _columnOverlayKey = GlobalKey(debugLabel: '$AFBoardColumnWidget overlay key'); - late BoardOverlayEntry _overlayEntry; @override