mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: auto width GridFieldCellActionSheet (#1673)
This commit is contained in:
@ -44,8 +44,7 @@ class _GridFieldCellState extends State<GridFieldCell> {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final button = AppFlowyPopover(
|
final button = AppFlowyPopover(
|
||||||
triggerActions: PopoverTriggerFlags.none,
|
triggerActions: PopoverTriggerFlags.none,
|
||||||
constraints: BoxConstraints.loose(const Size(240, 440)),
|
constraints: BoxConstraints.loose(const Size(400, 240)),
|
||||||
margin: EdgeInsets.zero,
|
|
||||||
direction: PopoverDirection.bottomWithLeftAligned,
|
direction: PopoverDirection.bottomWithLeftAligned,
|
||||||
controller: popoverController,
|
controller: popoverController,
|
||||||
popupBuilder: (BuildContext context) {
|
popupBuilder: (BuildContext context) {
|
||||||
|
@ -43,9 +43,10 @@ class _GridFieldCellActionSheetState extends State<GridFieldCellActionSheet> {
|
|||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) =>
|
create: (context) =>
|
||||||
getIt<FieldActionSheetBloc>(param1: widget.cellContext),
|
getIt<FieldActionSheetBloc>(param1: widget.cellContext),
|
||||||
child: SingleChildScrollView(
|
child: IntrinsicWidth(
|
||||||
padding: const EdgeInsets.all(12.0),
|
child: IntrinsicHeight(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
_EditFieldButton(
|
_EditFieldButton(
|
||||||
cellContext: widget.cellContext,
|
cellContext: widget.cellContext,
|
||||||
@ -56,10 +57,11 @@ class _GridFieldCellActionSheetState extends State<GridFieldCellActionSheet> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
VSpace(GridSize.typeOptionSeparatorHeight),
|
VSpace(GridSize.typeOptionSeparatorHeight),
|
||||||
_FieldOperationList(widget.cellContext, () {}),
|
_FieldOperationList(widget.cellContext),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,22 +92,17 @@ class _EditFieldButton extends StatelessWidget {
|
|||||||
|
|
||||||
class _FieldOperationList extends StatelessWidget {
|
class _FieldOperationList extends StatelessWidget {
|
||||||
final GridFieldCellContext fieldInfo;
|
final GridFieldCellContext fieldInfo;
|
||||||
final VoidCallback onDismissed;
|
final double cellWidth = 100;
|
||||||
const _FieldOperationList(this.fieldInfo, this.onDismissed, {Key? key})
|
|
||||||
: super(key: key);
|
const _FieldOperationList(this.fieldInfo, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GridView(
|
return SizedBox(
|
||||||
// https://api.flutter.dev/flutter/widgets/AnimatedList/shrinkWrap.html
|
width: cellWidth * 2,
|
||||||
shrinkWrap: true,
|
child: Wrap(
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
||||||
crossAxisCount: 2,
|
|
||||||
childAspectRatio: 4.0,
|
|
||||||
mainAxisSpacing: GridSize.typeOptionSeparatorHeight,
|
|
||||||
crossAxisSpacing: GridSize.typeOptionSeparatorHeight,
|
|
||||||
),
|
|
||||||
children: buildCells(),
|
children: buildCells(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,11 +118,14 @@ class _FieldOperationList extends StatelessWidget {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FieldActionCell(
|
return SizedBox(
|
||||||
|
height: GridSize.typeOptionItemHeight,
|
||||||
|
width: cellWidth,
|
||||||
|
child: FieldActionCell(
|
||||||
fieldInfo: fieldInfo,
|
fieldInfo: fieldInfo,
|
||||||
action: action,
|
action: action,
|
||||||
onTap: onDismissed,
|
|
||||||
enable: enable,
|
enable: enable,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
).toList();
|
).toList();
|
||||||
@ -134,14 +134,12 @@ class _FieldOperationList extends StatelessWidget {
|
|||||||
|
|
||||||
class FieldActionCell extends StatelessWidget {
|
class FieldActionCell extends StatelessWidget {
|
||||||
final GridFieldCellContext fieldInfo;
|
final GridFieldCellContext fieldInfo;
|
||||||
final VoidCallback onTap;
|
|
||||||
final FieldAction action;
|
final FieldAction action;
|
||||||
final bool enable;
|
final bool enable;
|
||||||
|
|
||||||
const FieldActionCell({
|
const FieldActionCell({
|
||||||
required this.fieldInfo,
|
required this.fieldInfo,
|
||||||
required this.action,
|
required this.action,
|
||||||
required this.onTap,
|
|
||||||
required this.enable,
|
required this.enable,
|
||||||
Key? key,
|
Key? key,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
@ -156,7 +154,6 @@ class FieldActionCell extends StatelessWidget {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
action.run(context, fieldInfo);
|
action.run(context, fieldInfo);
|
||||||
onTap();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
leftIcon: svgWidget(
|
leftIcon: svgWidget(
|
||||||
|
@ -45,6 +45,7 @@ class AppFlowyPopover extends StatelessWidget {
|
|||||||
windowPadding: windowPadding,
|
windowPadding: windowPadding,
|
||||||
popupBuilder: (context) {
|
popupBuilder: (context) {
|
||||||
final child = popupBuilder(context);
|
final child = popupBuilder(context);
|
||||||
|
debugPrint("show popover: $child");
|
||||||
return _PopoverContainer(
|
return _PopoverContainer(
|
||||||
constraints: constraints,
|
constraints: constraints,
|
||||||
margin: margin,
|
margin: margin,
|
||||||
@ -81,14 +82,6 @@ class _PopoverContainer extends StatelessWidget {
|
|||||||
decoration: decoration,
|
decoration: decoration,
|
||||||
constraints: constraints,
|
constraints: constraints,
|
||||||
child: child,
|
child: child,
|
||||||
|
|
||||||
// SingleChildScrollView(
|
|
||||||
// scrollDirection: Axis.horizontal,
|
|
||||||
// child: ConstrainedBox(
|
|
||||||
// constraints: constraints,
|
|
||||||
// child: child,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user