Skip to content

Commit 7572321

Browse files
authored
chore: auto width GridFieldCellActionSheet (#1673)
1 parent 37f269b commit 7572321

File tree

3 files changed

+34
-45
lines changed

3 files changed

+34
-45
lines changed

frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ class _GridFieldCellState extends State<GridFieldCell> {
4444
builder: (context, state) {
4545
final button = AppFlowyPopover(
4646
triggerActions: PopoverTriggerFlags.none,
47-
constraints: BoxConstraints.loose(const Size(240, 440)),
48-
margin: EdgeInsets.zero,
47+
constraints: BoxConstraints.loose(const Size(400, 240)),
4948
direction: PopoverDirection.bottomWithLeftAligned,
5049
controller: popoverController,
5150
popupBuilder: (BuildContext context) {

frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dart

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,23 @@ class _GridFieldCellActionSheetState extends State<GridFieldCellActionSheet> {
4343
return BlocProvider(
4444
create: (context) =>
4545
getIt<FieldActionSheetBloc>(param1: widget.cellContext),
46-
child: SingleChildScrollView(
47-
padding: const EdgeInsets.all(12.0),
48-
child: Column(
49-
children: [
50-
_EditFieldButton(
51-
cellContext: widget.cellContext,
52-
onTap: () {
53-
setState(() {
54-
_showFieldEditor = true;
55-
});
56-
},
57-
),
58-
VSpace(GridSize.typeOptionSeparatorHeight),
59-
_FieldOperationList(widget.cellContext, () {}),
60-
],
46+
child: IntrinsicWidth(
47+
child: IntrinsicHeight(
48+
child: Column(
49+
crossAxisAlignment: CrossAxisAlignment.start,
50+
children: [
51+
_EditFieldButton(
52+
cellContext: widget.cellContext,
53+
onTap: () {
54+
setState(() {
55+
_showFieldEditor = true;
56+
});
57+
},
58+
),
59+
VSpace(GridSize.typeOptionSeparatorHeight),
60+
_FieldOperationList(widget.cellContext),
61+
],
62+
),
6163
),
6264
),
6365
);
@@ -90,22 +92,17 @@ class _EditFieldButton extends StatelessWidget {
9092

9193
class _FieldOperationList extends StatelessWidget {
9294
final GridFieldCellContext fieldInfo;
93-
final VoidCallback onDismissed;
94-
const _FieldOperationList(this.fieldInfo, this.onDismissed, {Key? key})
95-
: super(key: key);
95+
final double cellWidth = 100;
96+
97+
const _FieldOperationList(this.fieldInfo, {Key? key}) : super(key: key);
9698

9799
@override
98100
Widget build(BuildContext context) {
99-
return GridView(
100-
// https://api.flutter.dev/flutter/widgets/AnimatedList/shrinkWrap.html
101-
shrinkWrap: true,
102-
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
103-
crossAxisCount: 2,
104-
childAspectRatio: 4.0,
105-
mainAxisSpacing: GridSize.typeOptionSeparatorHeight,
106-
crossAxisSpacing: GridSize.typeOptionSeparatorHeight,
101+
return SizedBox(
102+
width: cellWidth * 2,
103+
child: Wrap(
104+
children: buildCells(),
107105
),
108-
children: buildCells(),
109106
);
110107
}
111108

@@ -121,11 +118,14 @@ class _FieldOperationList extends StatelessWidget {
121118
break;
122119
}
123120

124-
return FieldActionCell(
125-
fieldInfo: fieldInfo,
126-
action: action,
127-
onTap: onDismissed,
128-
enable: enable,
121+
return SizedBox(
122+
height: GridSize.typeOptionItemHeight,
123+
width: cellWidth,
124+
child: FieldActionCell(
125+
fieldInfo: fieldInfo,
126+
action: action,
127+
enable: enable,
128+
),
129129
);
130130
},
131131
).toList();
@@ -134,14 +134,12 @@ class _FieldOperationList extends StatelessWidget {
134134

135135
class FieldActionCell extends StatelessWidget {
136136
final GridFieldCellContext fieldInfo;
137-
final VoidCallback onTap;
138137
final FieldAction action;
139138
final bool enable;
140139

141140
const FieldActionCell({
142141
required this.fieldInfo,
143142
required this.action,
144-
required this.onTap,
145143
required this.enable,
146144
Key? key,
147145
}) : super(key: key);
@@ -156,7 +154,6 @@ class FieldActionCell extends StatelessWidget {
156154
onTap: () {
157155
if (enable) {
158156
action.run(context, fieldInfo);
159-
onTap();
160157
}
161158
},
162159
leftIcon: svgWidget(

frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/appflowy_popover.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class AppFlowyPopover extends StatelessWidget {
4545
windowPadding: windowPadding,
4646
popupBuilder: (context) {
4747
final child = popupBuilder(context);
48+
debugPrint("show popover: $child");
4849
return _PopoverContainer(
4950
constraints: constraints,
5051
margin: margin,
@@ -81,14 +82,6 @@ class _PopoverContainer extends StatelessWidget {
8182
decoration: decoration,
8283
constraints: constraints,
8384
child: child,
84-
85-
// SingleChildScrollView(
86-
// scrollDirection: Axis.horizontal,
87-
// child: ConstrainedBox(
88-
// constraints: constraints,
89-
// child: child,
90-
// ),
91-
// ),
9285
),
9386
);
9487
}

0 commit comments

Comments
 (0)