chore: auto width GridFieldCellActionSheet (#1673)

This commit is contained in:
Nathan.fooo 2023-01-08 12:59:54 +08:00 committed by GitHub
parent 37f269b08b
commit 7572321813
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 45 deletions

View File

@ -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) {

View File

@ -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(

View File

@ -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,
// ),
// ),
),
);
}