Merge pull request #1109 from AppFlowy-IO/fix/drag_grid_header_cell

fix: tap event conflict when dragging grid header cell
This commit is contained in:
Nathan.fooo
2022-09-21 16:15:32 +08:00
committed by GitHub
10 changed files with 29 additions and 23 deletions

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

@ -1,4 +1,3 @@
import 'package:appflowy_popover/appflowy_popover.dart';
import 'package:app_flowy/plugins/grid/application/setting/setting_bloc.dart';
import 'package:flowy_infra/image.dart';
import 'package:flowy_infra/theme.dart';
@ -55,7 +54,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,