chore: save scroll pos

This commit is contained in:
appflowy 2022-08-27 21:22:26 +08:00
parent 82c0006868
commit 4ead583f6d
3 changed files with 34 additions and 27 deletions

View File

@ -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<void> dispose() async {
_listener.stop();
}

View File

@ -184,7 +184,7 @@ class _AFBoardContentState extends State<AFBoardContent> {
);
final reorderFlex = ReorderFlex(
key: widget.key,
key: const PageStorageKey<String>('AFBoardContent'),
config: widget.reorderFlexConfig,
scrollController: widget.scrollController,
onDragStarted: widget.onDragStarted,
@ -242,27 +242,23 @@ class _AFBoardContentState extends State<AFBoardContent> {
value: widget.dataController.getColumnController(columnData.id),
child: Consumer<AFBoardColumnDataController>(
builder: (context, value, child) {
final scrollController =
widget.columnState.scrollController(columnData.id);
final boardColumn = AFBoardColumnWidget(
key: ValueKey(columnData.id),
key: const PageStorageKey<String>('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;
}
}

View File

@ -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<AFBoardColumnWidget> {
final GlobalKey _columnOverlayKey =
GlobalKey(debugLabel: '$AFBoardColumnWidget overlay key');
late BoardOverlayEntry _overlayEntry;
@override