Browse Source

chore: optimaze tap area of row detail cells

appflowy 3 years ago
parent
commit
0b83684c66

+ 0 - 44
frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/number_cell.dart

@@ -1,44 +0,0 @@
-import 'package:app_flowy/startup/startup.dart';
-import 'package:app_flowy/workspace/application/grid/prelude.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-
-class NumberCell extends StatefulWidget {
-  final GridCell cellData;
-
-  const NumberCell({
-    required this.cellData,
-    Key? key,
-  }) : super(key: key);
-
-  @override
-  State<NumberCell> createState() => _NumberCellState();
-}
-
-class _NumberCellState extends State<NumberCell> {
-  late NumberCellBloc _cellBloc;
-
-  @override
-  void initState() {
-    _cellBloc = getIt<NumberCellBloc>(param1: widget.cellData);
-    super.initState();
-  }
-
-  @override
-  Widget build(BuildContext context) {
-    return BlocProvider.value(
-      value: _cellBloc,
-      child: BlocBuilder<NumberCellBloc, NumberCellState>(
-        builder: (context, state) {
-          return Container();
-        },
-      ),
-    );
-  }
-
-  @override
-  Future<void> dispose() async {
-    _cellBloc.close();
-    super.dispose();
-  }
-}

+ 10 - 6
frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_detail.dart

@@ -152,6 +152,15 @@ class _RowDetailCell extends StatelessWidget {
     final style = _customCellStyle(theme, gridCell.field.fieldType);
     final style = _customCellStyle(theme, gridCell.field.fieldType);
     final cell = buildGridCellWidget(gridCell, cellCache, style: style);
     final cell = buildGridCellWidget(gridCell, cellCache, style: style);
 
 
+    final gesture = GestureDetector(
+      behavior: HitTestBehavior.translucent,
+      onTap: () => cell.requestBeginFocus.notify(),
+      child: AccessoryHover(
+        child: cell,
+        contentPadding: const EdgeInsets.symmetric(horizontal: 10, vertical: 12),
+      ),
+    );
+
     return ConstrainedBox(
     return ConstrainedBox(
       constraints: const BoxConstraints(minHeight: 40),
       constraints: const BoxConstraints(minHeight: 40),
       child: IntrinsicHeight(
       child: IntrinsicHeight(
@@ -164,12 +173,7 @@ class _RowDetailCell extends StatelessWidget {
               child: FieldCellButton(field: gridCell.field, onTap: () => _showFieldEditor(context)),
               child: FieldCellButton(field: gridCell.field, onTap: () => _showFieldEditor(context)),
             ),
             ),
             const HSpace(10),
             const HSpace(10),
-            Expanded(
-              child: AccessoryHover(
-                child: cell,
-                contentPadding: const EdgeInsets.symmetric(horizontal: 10, vertical: 12),
-              ),
-            ),
+            Expanded(child: gesture),
           ],
           ],
         ),
         ),
       ),
       ),