Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
[flutter]: question bubble popup
appflowy7246f597afc9
diff --git a/app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart b/app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dartindex fcbd3d342f..6e87f925d0 100644--- a/app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart+++ b/app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart@@ -1,7 +1,10 @@+import 'package:app_flowy/workspace/presentation/widgets/pop_up_action.dart';import 'package:flowy_infra/theme.dart';+import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flowy_infra_ui/style_widget/button.dart';import 'package:flutter/material.dart';import 'package:provider/provider.dart';+import 'package:dartz/dartz.dart' as dartz;class QuestionBubble extends StatelessWidget {const QuestionBubble({Key? key}) : super(key: key);@@ -19,8 +22,69 @@ class QuestionBubble extends StatelessWidget {fillColor: theme.selector,mainAxisAlignment: MainAxisAlignment.center,radius: BorderRadius.circular(10),- onPressed: () {},+ onPressed: () {+ final actionList = QuestionBubbleActions(onSelected: (action) {});+ actionList.show(+ context,+ context,+ anchorDirection: AnchorDirection.topWithCenterAligned,+ );+ },),);}}++class QuestionBubbleActions with ActionList<QuestionBubbleActionWrapper> implements FlowyOverlayDelegate {+ final Function(dartz.Option<QuestionBubbleAction>) onSelected;+ final _items = QuestionBubbleAction.values.map((action) => QuestionBubbleActionWrapper(action)).toList();++ QuestionBubbleActions({+ required this.onSelected,+ });++ @override+ List<QuestionBubbleActionWrapper> get items => _items;++ @override+ void Function(dartz.Option<QuestionBubbleActionWrapper> p1) get selectCallback => (result) {+ result.fold(+ () => onSelected(dartz.none()),+ (wrapper) => onSelected(+ dartz.some(wrapper.inner),+ ),+ );+ };++ @override+ FlowyOverlayDelegate? get delegate => this;++ @override+ void didRemove() {+ onSelected(dartz.none());+ }+}++enum QuestionBubbleAction {+ whatsNews,+}++class QuestionBubbleActionWrapper extends ActionItemData {+ final QuestionBubbleAction inner;++ QuestionBubbleActionWrapper(this.inner);+ @override+ Widget? get icon => null;++ @override+ String get name => inner.name;+}++extension QuestionBubbleExtension on QuestionBubbleAction {+ String get name {+ switch (this) {+ case QuestionBubbleAction.whatsNews:+ return "What's new";+ }+ }+}diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/header/right_click_action.dart b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/header/right_click_action.dartindex feb1ae89c2..9186bdc556 100644--- a/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/header/right_click_action.dart+++ b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/header/right_click_action.dart@@ -12,20 +12,16 @@ class AppDisclosureActions with ActionList<AppDisclosureActionWrapper> implementrequired this.onSelected,});- @override- String get identifier => "ViewDisclosureActions";-@overrideList<AppDisclosureActionWrapper> get items => _items;- @override- double get maxWidth => 162;-@overridevoid Function(dartz.Option<AppDisclosureActionWrapper> p1) get selectCallback => (result) {result.fold(() => onSelected(dartz.none()),- (wrapper) => onSelected(dartz.some(wrapper.inner)),+ (wrapper) => onSelected(+ dartz.some(wrapper.inner),+ ),);};diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/section/disclosure_action.dart b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/section/disclosure_action.dartindex db0ce49c3a..06f1ba3ad1 100644--- a/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/section/disclosure_action.dart+++ b/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/section/disclosure_action.dart@@ -34,9 +34,6 @@ class ViewDisclosureButton extends StatelessWidget);}- @override- String get identifier => "ViewDisclosureActions";-@overrideList<ViewDisclosureActionWrapper> get items => _items;diff --git a/app_flowy/lib/workspace/presentation/widgets/pop_up_action.dart b/app_flowy/lib/workspace/presentation/widgets/pop_up_action.dartindex 0c74c93594..ce22623d7e 100644--- a/app_flowy/lib/workspace/presentation/widgets/pop_up_action.dart+++ b/app_flowy/lib/workspace/presentation/widgets/pop_up_action.dart@@ -11,9 +11,9 @@ import 'package:dartz/dartz.dart' as dartz;abstract class ActionList<T extends ActionItemData> {List<T> get items;- String get identifier;+ String get identifier => toString();- double get maxWidth;+ double get maxWidth => 162;void Function(dartz.Option<T>) get selectCallback;@@ -47,7 +47,7 @@ abstract class ActionList<T extends ActionItemData> {}abstract class ActionItemData {- Widget get icon;+ Widget? get icon;String get name;}@@ -80,7 +80,7 @@ class ActionItem<T extends ActionItemData> extends StatelessWidget {height: ActionListSizes.itemHeight,child: Row(children: [- action.icon,+ if (action.icon != null) action.icon!,HSpace(ActionListSizes.itemHPadding),FlowyText.medium(action.name,