fix: tap event conflict when dragging grid header cell

This commit is contained in:
appflowy 2022-09-21 11:24:37 +08:00
parent bdf4e60b48
commit 0ff08ff8d2
10 changed files with 29 additions and 22 deletions

View File

@ -45,7 +45,7 @@ test "" = "$(grep '^Signed-off-by: ' "$1" |
if [ $? -ne 0 ]
then
printError "Please fix your commit message to match AppFlowy coding standards"
printError "https://appflowy.gitbook.io/docs/essential-documentation/contribute-to-appflowy/software-contributions/submitting-code/style-guides"
printError "https://appflowy.gitbook.io/docs/essential-documentation/contribute-to-appflowy/software-contributions/submitting-code/code-submission-guidelines#commit-message-guidelines"
exit 1
fi

View File

@ -65,7 +65,6 @@ class _SettingButtonState extends State<_SettingButton> {
return AppFlowyPopover(
controller: popoverController,
constraints: BoxConstraints.loose(const Size(260, 400)),
triggerActions: PopoverTriggerFlags.click,
child: FlowyIconButton(
hoverColor: theme.hover,
width: 22,

View File

@ -220,7 +220,6 @@ class _EditURLAccessoryState extends State<_EditURLAccessory>
constraints: BoxConstraints.loose(const Size(300, 160)),
controller: _popoverController,
direction: PopoverDirection.bottomWithLeftAligned,
triggerActions: PopoverTriggerFlags.click,
offset: const Offset(0, 20),
child: svgWidget("editor/edit", color: theme.iconColor),
popupBuilder: (BuildContext popoverContext) {

View File

@ -15,34 +15,47 @@ import 'field_type_extension.dart';
import 'field_cell_action_sheet.dart';
class GridFieldCell extends StatelessWidget {
class GridFieldCell extends StatefulWidget {
final GridFieldCellContext cellContext;
const GridFieldCell({
Key? key,
required this.cellContext,
}) : super(key: key);
@override
State<GridFieldCell> createState() => _GridFieldCellState();
}
class _GridFieldCellState extends State<GridFieldCell> {
late PopoverController popoverController;
@override
void initState() {
popoverController = PopoverController();
super.initState();
}
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) {
return FieldCellBloc(cellContext: cellContext);
return FieldCellBloc(cellContext: widget.cellContext);
},
child: BlocBuilder<FieldCellBloc, FieldCellState>(
builder: (context, state) {
final button = AppFlowyPopover(
triggerActions: PopoverTriggerFlags.none,
constraints: BoxConstraints.loose(const Size(240, 840)),
direction: PopoverDirection.bottomWithLeftAligned,
triggerActions: PopoverTriggerFlags.click,
offset: const Offset(0, 10),
controller: popoverController,
popupBuilder: (BuildContext context) {
return GridFieldCellActionSheet(
cellContext: cellContext,
cellContext: widget.cellContext,
);
},
child: FieldCellButton(
field: cellContext.field,
onTap: () {},
field: widget.cellContext.field,
onTap: () => popoverController.show(),
),
);

View File

@ -102,10 +102,8 @@ class _GridHeaderState extends State<_GridHeader> {
.where((field) => field.visibility)
.map((field) =>
GridFieldCellContext(gridId: widget.gridId, field: field.field))
.map((ctx) => GridFieldCell(
key: _getKeyById(ctx.field.id),
cellContext: ctx,
))
.map((ctx) =>
GridFieldCell(key: _getKeyById(ctx.field.id), cellContext: ctx))
.toList();
return Container(
@ -115,6 +113,7 @@ class _GridHeaderState extends State<_GridHeader> {
crossAxisAlignment: CrossAxisAlignment.stretch,
scrollController: ScrollController(),
header: const _CellLeading(),
needsLongPressDraggable: false,
footer: _CellTrailing(gridId: widget.gridId),
onReorder: (int oldIndex, int newIndex) {
_onReorder(cells, oldIndex, context, newIndex);
@ -177,7 +176,6 @@ class CreateFieldButton extends StatelessWidget {
final theme = context.watch<AppTheme>();
return AppFlowyPopover(
triggerActions: PopoverTriggerFlags.click,
direction: PopoverDirection.bottomWithRightAligned,
asBarrier: true,
constraints: BoxConstraints.loose(const Size(240, 600)),

View File

@ -192,7 +192,6 @@ class _CreateFieldButtonState extends State<_CreateFieldButton> {
return AppFlowyPopover(
constraints: BoxConstraints.loose(const Size(240, 200)),
controller: popoverController,
triggerActions: PopoverTriggerFlags.click,
direction: PopoverDirection.topWithLeftAligned,
onClose: widget.onClosed,
child: Container(

View File

@ -118,7 +118,6 @@ class _GridPropertyCell extends StatelessWidget {
Widget _editFieldButton(AppTheme theme, BuildContext context) {
return AppFlowyPopover(
mutex: popoverMutex,
triggerActions: PopoverTriggerFlags.click,
offset: const Offset(20, 0),
constraints: BoxConstraints.loose(const Size(240, 400)),
child: FlowyButton(

View File

@ -55,7 +55,6 @@ class _SettingButton extends StatelessWidget {
final theme = context.watch<AppTheme>();
return AppFlowyPopover(
constraints: BoxConstraints.loose(const Size(260, 400)),
triggerActions: PopoverTriggerFlags.click,
offset: const Offset(0, 10),
child: FlowyIconButton(
width: 22,

View File

@ -17,8 +17,9 @@ class PopoverController {
}
class PopoverTriggerFlags {
static int click = 0x01;
static int hover = 0x02;
static const int none = 0x00;
static const int click = 0x01;
static const int hover = 0x02;
}
enum PopoverDirection {

View File

@ -20,9 +20,9 @@ class AppFlowyPopover extends StatelessWidget {
required this.popupBuilder,
this.direction = PopoverDirection.rightWithTopAligned,
this.onClose,
this.constraints,
this.constraints = const BoxConstraints(maxWidth: 240, maxHeight: 600),
this.mutex,
this.triggerActions = 0,
this.triggerActions = PopoverTriggerFlags.click,
this.offset,
this.controller,
this.asBarrier = false,