Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: reorder rows on windows (#3279)

Mathias Mogensenef6f9a3175bf
diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/grid_page.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/grid_page.dart
index 0eefacda47..8546ca3d96 100755
--- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/grid_page.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/grid_page.dart
@@ -1,5 +1,3 @@
-import 'dart:io';
-
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/database_view/application/row/row_service.dart';
import 'package:appflowy/plugins/database_view/grid/presentation/widgets/toolbar/grid_setting_bar.dart';
@@ -257,59 +255,38 @@ class _GridRows extends StatelessWidget {
GridState state,
List<RowInfo> rowInfos,
) {
- if (Platform.isWindows) {
- // Workaround: On Windows, the focusing of the text cell is not working
- // properly when the list is reorderable. So using the ListView instead.
- return ListView.builder(
- controller: scrollController.verticalController,
- itemCount: rowInfos.length + 1, // the extra item is the footer
- itemBuilder: (context, index) {
- if (index < rowInfos.length) {
- final rowInfo = rowInfos[index];
- return _renderRow(
- context,
- rowInfo.rowId,
- isDraggable: false,
- index: index,
- );
- }
- return const GridRowBottomBar(key: Key('gridFooter'));
- },
- );
- } else {
- return ReorderableListView.builder(
- /// TODO(Xazin): Resolve inconsistent scrollbar behavior
- /// This is a workaround related to
- /// https://github.com/flutter/flutter/issues/25652
- cacheExtent: 5000,
- scrollController: scrollController.verticalController,
- buildDefaultDragHandles: false,
- proxyDecorator: (child, index, animation) => Material(
- color: Colors.white.withOpacity(.1),
- child: Opacity(opacity: .5, child: child),
- ),
- onReorder: (fromIndex, newIndex) {
- final toIndex = newIndex > fromIndex ? newIndex - 1 : newIndex;
- if (fromIndex == toIndex) {
- return;
- }
- context.read<GridBloc>().add(GridEvent.moveRow(fromIndex, toIndex));
- },
- itemCount: rowInfos.length + 1, // the extra item is the footer
- itemBuilder: (context, index) {
- if (index < rowInfos.length) {
- final rowInfo = rowInfos[index];
- return _renderRow(
- context,
- rowInfo.rowId,
- isDraggable: state.reorderable,
- index: index,
- );
- }
- return const GridRowBottomBar(key: Key('gridFooter'));
- },
- );
- }
+ return ReorderableListView.builder(
+ /// TODO(Xazin): Resolve inconsistent scrollbar behavior
+ /// This is a workaround related to
+ /// https://github.com/flutter/flutter/issues/25652
+ cacheExtent: 5000,
+ scrollController: scrollController.verticalController,
+ buildDefaultDragHandles: false,
+ proxyDecorator: (child, index, animation) => Material(
+ color: Colors.white.withOpacity(.1),
+ child: Opacity(opacity: .5, child: child),
+ ),
+ onReorder: (fromIndex, newIndex) {
+ final toIndex = newIndex > fromIndex ? newIndex - 1 : newIndex;
+ if (fromIndex == toIndex) {
+ return;
+ }
+ context.read<GridBloc>().add(GridEvent.moveRow(fromIndex, toIndex));
+ },
+ itemCount: rowInfos.length + 1, // the extra item is the footer
+ itemBuilder: (context, index) {
+ if (index < rowInfos.length) {
+ final rowInfo = rowInfos[index];
+ return _renderRow(
+ context,
+ rowInfo.rowId,
+ isDraggable: state.reorderable,
+ index: index,
+ );
+ }
+ return const GridRowBottomBar(key: Key('gridFooter'));
+ },
+ );
}
Widget _renderRow(
diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/row/row.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/row/row.dart
index 02f7f5e70c..8ce1174830 100755
--- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/row/row.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/row/row.dart
@@ -161,16 +161,12 @@ class _RowLeadingState extends State<_RowLeading> {
index: widget.index!,
child: RowMenuButton(
isDragEnabled: isDraggable,
- openMenu: () {
- popoverController.show();
- },
+ openMenu: popoverController.show,
),
),
] else ...[
RowMenuButton(
- openMenu: () {
- popoverController.show();
- },
+ openMenu: popoverController.show,
),
],
],