浏览代码

chore: auto width GridFieldCellActionSheet (#1673)

Nathan.fooo 2 年之前
父节点
当前提交
7572321813

+ 1 - 2
frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell.dart

@@ -44,8 +44,7 @@ class _GridFieldCellState extends State<GridFieldCell> {
         builder: (context, state) {
           final button = AppFlowyPopover(
             triggerActions: PopoverTriggerFlags.none,
-            constraints: BoxConstraints.loose(const Size(240, 440)),
-            margin: EdgeInsets.zero,
+            constraints: BoxConstraints.loose(const Size(400, 240)),
             direction: PopoverDirection.bottomWithLeftAligned,
             controller: popoverController,
             popupBuilder: (BuildContext context) {

+ 32 - 35
frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dart

@@ -43,21 +43,23 @@ class _GridFieldCellActionSheetState extends State<GridFieldCellActionSheet> {
     return BlocProvider(
       create: (context) =>
           getIt<FieldActionSheetBloc>(param1: widget.cellContext),
-      child: SingleChildScrollView(
-        padding: const EdgeInsets.all(12.0),
-        child: Column(
-          children: [
-            _EditFieldButton(
-              cellContext: widget.cellContext,
-              onTap: () {
-                setState(() {
-                  _showFieldEditor = true;
-                });
-              },
-            ),
-            VSpace(GridSize.typeOptionSeparatorHeight),
-            _FieldOperationList(widget.cellContext, () {}),
-          ],
+      child: IntrinsicWidth(
+        child: IntrinsicHeight(
+          child: Column(
+            crossAxisAlignment: CrossAxisAlignment.start,
+            children: [
+              _EditFieldButton(
+                cellContext: widget.cellContext,
+                onTap: () {
+                  setState(() {
+                    _showFieldEditor = true;
+                  });
+                },
+              ),
+              VSpace(GridSize.typeOptionSeparatorHeight),
+              _FieldOperationList(widget.cellContext),
+            ],
+          ),
         ),
       ),
     );
@@ -90,22 +92,17 @@ class _EditFieldButton extends StatelessWidget {
 
 class _FieldOperationList extends StatelessWidget {
   final GridFieldCellContext fieldInfo;
-  final VoidCallback onDismissed;
-  const _FieldOperationList(this.fieldInfo, this.onDismissed, {Key? key})
-      : super(key: key);
+  final double cellWidth = 100;
+
+  const _FieldOperationList(this.fieldInfo, {Key? key}) : super(key: key);
 
   @override
   Widget build(BuildContext context) {
-    return GridView(
-      // https://api.flutter.dev/flutter/widgets/AnimatedList/shrinkWrap.html
-      shrinkWrap: true,
-      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
-        crossAxisCount: 2,
-        childAspectRatio: 4.0,
-        mainAxisSpacing: GridSize.typeOptionSeparatorHeight,
-        crossAxisSpacing: GridSize.typeOptionSeparatorHeight,
+    return SizedBox(
+      width: cellWidth * 2,
+      child: Wrap(
+        children: buildCells(),
       ),
-      children: buildCells(),
     );
   }
 
@@ -121,11 +118,14 @@ class _FieldOperationList extends StatelessWidget {
             break;
         }
 
-        return FieldActionCell(
-          fieldInfo: fieldInfo,
-          action: action,
-          onTap: onDismissed,
-          enable: enable,
+        return SizedBox(
+          height: GridSize.typeOptionItemHeight,
+          width: cellWidth,
+          child: FieldActionCell(
+            fieldInfo: fieldInfo,
+            action: action,
+            enable: enable,
+          ),
         );
       },
     ).toList();
@@ -134,14 +134,12 @@ class _FieldOperationList extends StatelessWidget {
 
 class FieldActionCell extends StatelessWidget {
   final GridFieldCellContext fieldInfo;
-  final VoidCallback onTap;
   final FieldAction action;
   final bool enable;
 
   const FieldActionCell({
     required this.fieldInfo,
     required this.action,
-    required this.onTap,
     required this.enable,
     Key? key,
   }) : super(key: key);
@@ -156,7 +154,6 @@ class FieldActionCell extends StatelessWidget {
       onTap: () {
         if (enable) {
           action.run(context, fieldInfo);
-          onTap();
         }
       },
       leftIcon: svgWidget(

+ 1 - 8
frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/appflowy_popover.dart

@@ -45,6 +45,7 @@ class AppFlowyPopover extends StatelessWidget {
       windowPadding: windowPadding,
       popupBuilder: (context) {
         final child = popupBuilder(context);
+        debugPrint("show popover: $child");
         return _PopoverContainer(
           constraints: constraints,
           margin: margin,
@@ -81,14 +82,6 @@ class _PopoverContainer extends StatelessWidget {
         decoration: decoration,
         constraints: constraints,
         child: child,
-
-        // SingleChildScrollView(
-        //   scrollDirection: Axis.horizontal,
-        //   child: ConstrainedBox(
-        //     constraints: constraints,
-        //     child: child,
-        //   ),
-        // ),
       ),
     );
   }