From 89d036158b27ab22a3c9b4d87d7f40bec4da603c Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Sat, 8 Oct 2022 20:48:14 +0800 Subject: [PATCH] chore: update view state when close the popover (#1251) --- frontend/app_flowy/lib/plugins/doc/document.dart | 2 +- .../presentation/home/menu/app/header/header.dart | 2 +- .../presentation/home/menu/app/section/item.dart | 5 ++++- .../widgets/float_bubble/question_bubble.dart | 2 +- .../workspace/presentation/widgets/pop_up_action.dart | 9 ++++++--- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/frontend/app_flowy/lib/plugins/doc/document.dart b/frontend/app_flowy/lib/plugins/doc/document.dart index ee8d572158..5bb1377d90 100644 --- a/frontend/app_flowy/lib/plugins/doc/document.dart +++ b/frontend/app_flowy/lib/plugins/doc/document.dart @@ -175,7 +175,7 @@ class ShareActionList extends StatelessWidget { actions: ShareAction.values .map((action) => ShareActionWrapper(action)) .toList(), - withChild: (controller) { + buildChild: (controller) { return RoundedTextButton( title: LocaleKeys.shareAction_buttonText.tr(), fontSize: 12, diff --git a/frontend/app_flowy/lib/workspace/presentation/home/menu/app/header/header.dart b/frontend/app_flowy/lib/workspace/presentation/home/menu/app/header/header.dart index 689db8db71..afaecdbd45 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/menu/app/header/header.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/menu/app/header/header.dart @@ -157,7 +157,7 @@ class AppActionList extends StatelessWidget { actions: AppDisclosureAction.values .map((action) => DisclosureActionWrapper(action)) .toList(), - withChild: (controller) { + buildChild: (controller) { return GestureDetector( behavior: HitTestBehavior.opaque, onTap: () => ExpandableController.of(context, diff --git a/frontend/app_flowy/lib/workspace/presentation/home/menu/app/section/item.dart b/frontend/app_flowy/lib/workspace/presentation/home/menu/app/section/item.dart index 8587cfcdaf..049a6bb4a5 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/menu/app/section/item.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/menu/app/section/item.dart @@ -177,7 +177,7 @@ class ViewDisclosureButton extends StatelessWidget { actions: ViewDisclosureAction.values .map((action) => ViewDisclosureActionWrapper(action)) .toList(), - withChild: (controller) { + buildChild: (controller) { return FlowyIconButton( iconPadding: const EdgeInsets.all(5), width: 26, @@ -193,6 +193,9 @@ class ViewDisclosureButton extends StatelessWidget { onAction(action.inner); controller.close(); }, + onClosed: () { + onEdit(false); + }, ); } } diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart index 8cd18084b8..1f8f0b6837 100644 --- a/frontend/app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart +++ b/frontend/app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart @@ -45,7 +45,7 @@ class BubbleActionList extends StatelessWidget { return PopoverActionList( direction: PopoverDirection.topWithRightAligned, actions: actions, - withChild: (controller) { + buildChild: (controller) { return FlowyTextButton( '?', tooltip: LocaleKeys.questionBubble_help.tr(), diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/pop_up_action.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/pop_up_action.dart index 08d9ff4a40..9aa4df4455 100644 --- a/frontend/app_flowy/lib/workspace/presentation/widgets/pop_up_action.dart +++ b/frontend/app_flowy/lib/workspace/presentation/widgets/pop_up_action.dart @@ -13,12 +13,14 @@ class PopoverActionList extends StatefulWidget { final Function(T, PopoverController) onSelected; final BoxConstraints constraints; final PopoverDirection direction; - final Widget Function(PopoverController) withChild; + final Widget Function(PopoverController) buildChild; + final VoidCallback? onClosed; const PopoverActionList({ required this.actions, - required this.withChild, + required this.buildChild, required this.onSelected, + this.onClosed, this.direction = PopoverDirection.rightWithTopAligned, this.constraints = const BoxConstraints( minWidth: 120, @@ -44,13 +46,14 @@ class _PopoverActionListState @override Widget build(BuildContext context) { - final child = widget.withChild(popoverController); + final child = widget.buildChild(popoverController); return AppFlowyPopover( controller: popoverController, constraints: widget.constraints, direction: widget.direction, triggerActions: PopoverTriggerFlags.none, + onClose: widget.onClosed, popupBuilder: (BuildContext popoverContext) { final List children = widget.actions.map((action) { if (action is ActionCell) {