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
Merge branch 'main' into feat/wrap-appflowy-style-popover
appflowy5294d7700ee5
diff --cc frontend/app_flowy/lib/plugins/board/presentation/toolbar/board_setting.dartindex 6bf06c39b9,6bf06c39b9..caf80909a2--- a/frontend/app_flowy/lib/plugins/board/presentation/toolbar/board_setting.dart+++ b/frontend/app_flowy/lib/plugins/board/presentation/toolbar/board_setting.dart@@@ -2,7 -2,7 +2,9 @@@ import 'package:app_flowy/generated/locimport 'package:app_flowy/plugins/board/application/toolbar/board_setting_bloc.dart';import 'package:app_flowy/plugins/grid/application/field/field_controller.dart';import 'package:app_flowy/plugins/grid/presentation/layout/sizes.dart';++import 'package:app_flowy/plugins/grid/presentation/widgets/toolbar/grid_group.dart';import 'package:app_flowy/plugins/grid/presentation/widgets/toolbar/grid_property.dart';++import 'package:appflowy_popover/popover.dart';import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra/image.dart';import 'package:flowy_infra/theme.dart';@@@ -141,10 -141,10 +143,12 @@@ extension _GridSettingExtension on Boar}class BoardSettingListPopover extends StatefulWidget {++ final PopoverController popoverController;final BoardSettingContext settingContext;const BoardSettingListPopover({Key? key,++ required this.popoverController,required this.settingContext,}) : super(key: key);@@@ -153,36 -153,36 +157,33 @@@}class _BoardSettingListPopoverState extends State<BoardSettingListPopover> {-- bool _showGridPropertyList = false;++ BoardSettingAction? _action;@overrideWidget build(BuildContext context) {-- if (_showGridPropertyList) {-- return OverlayContainer(-- constraints: BoxConstraints.loose(const Size(260, 400)),-- child: GridPropertyList(-- gridId: widget.settingContext.viewId,-- fieldController: widget.settingContext.fieldController,-- ),-- );++ if (_action != null) {++ switch (_action!) {++ case BoardSettingAction.groups:++ return GridGroupList(++ viewId: widget.settingContext.viewId,++ fieldController: widget.settingContext.fieldController,++ onDismissed: () {++ widget.popoverController.close();++ },++ );++ case BoardSettingAction.properties:++ return GridPropertyList(++ gridId: widget.settingContext.viewId,++ fieldController: widget.settingContext.fieldController,++ );++ }}-- return OverlayContainer(-- constraints: BoxConstraints.loose(const Size(140, 400)),-- child: BoardSettingList(-- settingContext: widget.settingContext,-- onAction: (action, settingContext) {-- switch (action) {-- case BoardSettingAction.groups:-- break;-- case BoardSettingAction.properties:-- setState(() {-- _showGridPropertyList = true;-- });-- break;-- }-- },-- ),++ return BoardSettingList(++ settingContext: widget.settingContext,++ onAction: (action, settingContext) {++ setState(() => _action = action);++ },);}}diff --cc frontend/app_flowy/lib/plugins/board/presentation/toolbar/board_toolbar.dartindex f8cc0d30ca,f8cc0d30ca..27a59c69a6--- a/frontend/app_flowy/lib/plugins/board/presentation/toolbar/board_toolbar.dart+++ b/frontend/app_flowy/lib/plugins/board/presentation/toolbar/board_toolbar.dart@@@ -2,6 -2,6 +2,7 @@@ import 'package:app_flowy/plugins/grid/import 'package:appflowy_popover/popover.dart';import 'package:flowy_infra/image.dart';import 'package:flowy_infra/theme.dart';++import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flowy_infra_ui/style_widget/icon_button.dart';import 'package:flutter/widgets.dart';import 'package:provider/provider.dart';@@@ -40,15 -40,15 +41,30 @@@ class BoardToolbar extends StatelessWid}}--class _SettingButton extends StatelessWidget {++class _SettingButton extends StatefulWidget {final BoardSettingContext settingContext;const _SettingButton({required this.settingContext, Key? key}): super(key: key);++ @override++ State<_SettingButton> createState() => _SettingButtonState();++}++++class _SettingButtonState extends State<_SettingButton> {++ late PopoverController popoverController;++++ @override++ void initState() {++ popoverController = PopoverController();++ super.initState();++ }++@overrideWidget build(BuildContext context) {final theme = context.read<AppTheme>();-- return Popover(++ return AppFlowyStylePopover(++ controller: popoverController,++ constraints: BoxConstraints.loose(const Size(260, 400)),triggerActions: PopoverTriggerActionFlags.click,child: FlowyIconButton(hoverColor: theme.hover,@@@ -61,7 -61,7 +77,8 @@@),popupBuilder: (BuildContext popoverContext) {return BoardSettingListPopover(-- settingContext: settingContext,++ settingContext: widget.settingContext,++ popoverController: popoverController,);},);diff --cc frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_editor.dartindex 8a8c445ec4,6a3c2d8d5c..cc836809b8--- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_editor.dart+++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_editor.dart@@@ -114,3 -131,57 +131,55 @@@ class _FieldNameCell extends StatelessW);}}++ class _DeleteFieldButton extends StatelessWidget {+ final PopoverMutex popoverMutex;+ final VoidCallback? onDeleted;++ const _DeleteFieldButton({+ required this.popoverMutex,+ required this.onDeleted,+ Key? key,+ }) : super(key: key);++ @override+ Widget build(BuildContext context) {+ final theme = context.watch<AppTheme>();+ return BlocBuilder<FieldEditorBloc, FieldEditorState>(+ buildWhen: (previous, current) => previous != current,+ builder: (context, state) {+ final enable = !state.canDelete && !state.isGroupField;+ Widget button = FlowyButton(+ text: FlowyText.medium(+ LocaleKeys.grid_field_delete.tr(),+ fontSize: 12,+ color: enable ? null : theme.shader4,+ ),+ );+ if (enable) button = _wrapPopover(button);+ return button;+ },+ );+ }++ Widget _wrapPopover(Widget widget) {- return Popover(++ return AppFlowyStylePopover(+ triggerActions: PopoverTriggerActionFlags.click,++ constraints: BoxConstraints.loose(const Size(400, 240)),+ mutex: popoverMutex,+ direction: PopoverDirection.center,+ popupBuilder: (popupContext) {- return OverlayContainer(- constraints: BoxConstraints.loose(const Size(400, 240)),- child: PopoverAlertView(- title: LocaleKeys.grid_field_deleteFieldPromptMessage.tr(),- cancel: () => popoverMutex.state?.close(),- confirm: () {- onDeleted?.call();- popoverMutex.state?.close();- },- popoverMutex: popoverMutex,- ),++ return PopoverAlertView(++ title: LocaleKeys.grid_field_deleteFieldPromptMessage.tr(),++ cancel: () => popoverMutex.state?.close(),++ confirm: () {++ onDeleted?.call();++ popoverMutex.state?.close();++ },++ popoverMutex: popoverMutex,+ );+ },+ child: widget,+ );+ }+ }diff --cc frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_option_editor.dartindex 14eaebe798,b8da4f3b71..f541335844--- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_option_editor.dart+++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_option_editor.dart@@@ -64,10 -64,8 +64,9 @@@ class FieldTypeOptionEditor extends Stafinal theme = context.watch<AppTheme>();return SizedBox(height: GridSize.typeOptionItemHeight,- child: Popover(+ child: AppFlowyStylePopover(+ constraints: BoxConstraints.loose(const Size(460, 440)),- triggerActions:- PopoverTriggerActionFlags.hover | PopoverTriggerActionFlags.click,+ triggerActions: PopoverTriggerActionFlags.click,mutex: popoverMutex,offset: const Offset(20, 0),popupBuilder: (context) {diff --cc frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/grid_header.dartindex 45fb7543ce,154919d019..f9656e8dcc--- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/grid_header.dart+++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/grid_header.dart@@@ -187,13 -186,19 +187,16 @@@ class CreateFieldButton extends Statele),hoverColor: theme.shader6,onTap: () {},- leftIcon: svgWidget("home/add"),+ leftIcon: svgWidget(+ "home/add",+ color: theme.iconColor,+ ),),popupBuilder: (BuildContext popover) {- return OverlayContainer(- constraints: BoxConstraints.loose(const Size(240, 200)),- child: FieldEditor(- gridId: gridId,- fieldName: "",- typeOptionLoader: NewFieldTypeOptionLoader(gridId: gridId),- ),+ return FieldEditor(+ gridId: gridId,+ fieldName: "",+ typeOptionLoader: NewFieldTypeOptionLoader(gridId: gridId),);},);diff --cc frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_group.dartindex b400cda0fe,b400cda0fe..8709cd3ea3--- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_group.dart+++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_group.dart@@@ -3,7 -3,7 +3,6 @@@ import 'package:app_flowy/plugins/grid/import 'package:app_flowy/plugins/grid/presentation/widgets/header/field_type_extension.dart';import 'package:flowy_infra/image.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:flowy_infra_ui/style_widget/text.dart';import 'package:flowy_infra_ui/widget/spacing.dart';@@@ -15,9 -15,9 +14,11 @@@ import 'package:flutter_bloc/flutter_blclass GridGroupList extends StatelessWidget {final String viewId;final GridFieldController fieldController;++ final VoidCallback onDismissed;const GridGroupList({required this.viewId,required this.fieldController,++ required this.onDismissed,Key? key,}) : super(key: key);@@@ -33,6 -33,6 +34,7 @@@final cells = state.fieldContexts.map((fieldContext) {Widget cell = _GridGroupCell(fieldContext: fieldContext,++ onSelected: () => onDismissed(),key: ValueKey(fieldContext.id),);@@@ -56,29 -56,29 +58,16 @@@),);}---- void show(BuildContext context) {-- FlowyOverlay.of(context).insertWithAnchor(-- widget: OverlayContainer(-- constraints: BoxConstraints.loose(const Size(260, 400)),-- child: this,-- ),-- identifier: identifier(),-- anchorContext: context,-- anchorDirection: AnchorDirection.bottomRight,-- style: FlowyOverlayStyle(blur: false),-- );-- }---- static String identifier() {-- return (GridGroupList).toString();-- }}class _GridGroupCell extends StatelessWidget {++ final VoidCallback onSelected;final GridFieldContext fieldContext;-- const _GridGroupCell({required this.fieldContext, Key? key})-- : super(key: key);++ const _GridGroupCell({++ required this.fieldContext,++ required this.onSelected,++ Key? key,++ }) : super(key: key);@overrideWidget build(BuildContext context) {@@@ -97,8 -97,8 +86,10 @@@child: FlowyButton(text: FlowyText.medium(fieldContext.name, fontSize: 12),hoverColor: theme.hover,-- leftIcon: svgWidget(fieldContext.fieldType.iconName(),-- color: theme.iconColor),++ leftIcon: svgWidget(++ fieldContext.fieldType.iconName(),++ color: theme.iconColor,++ ),rightIcon: rightIcon,onTap: () {context.read<GridGroupBloc>().add(@@@ -107,7 -107,7 +98,8 @@@fieldContext.fieldType,),);-- FlowyOverlay.of(context).remove(GridGroupList.identifier());++ onSelected();++ // FlowyOverlay.of(context).remove(GridGroupList.identifier());},),);diff --cc frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_toolbar.dartindex 88b64a8f25,f5893c892f..7675eda943--- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_toolbar.dart+++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_toolbar.dart@@@ -53,7 -53,7 +53,8 @@@ class _SettingButton extends StatelessW@overrideWidget build(BuildContext context) {final theme = context.watch<AppTheme>();-- return Popover(++ return AppFlowyStylePopover(++ constraints: BoxConstraints.loose(const Size(260, 400)),triggerActions: PopoverTriggerActionFlags.click,offset: const Offset(0, 10),child: FlowyIconButton(@@@ -85,25 -87,25 +88,19 @@@ class _GridSettingListPopoverState exte@overrideWidget build(BuildContext context) {if (_action == GridSettingAction.properties) {-- return OverlayContainer(-- constraints: BoxConstraints.loose(const Size(260, 400)),-- child: GridPropertyList(-- gridId: widget.settingContext.gridId,-- fieldController: widget.settingContext.fieldController,-- ),++ return GridPropertyList(++ gridId: widget.settingContext.gridId,++ fieldController: widget.settingContext.fieldController,);}-- return OverlayContainer(-- constraints: BoxConstraints.loose(const Size(140, 400)),-- child: GridSettingList(-- settingContext: widget.settingContext,-- onAction: (action, settingContext) {-- setState(() {-- _action = action;-- });-- },-- ),++ return GridSettingList(++ settingContext: widget.settingContext,++ onAction: (action, settingContext) {++ setState(() {++ _action = action;++ });++ },);}}diff --cc frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/appflowy_stype_popover.dartindex dbd45e2b1d,0000000000..663a8c0646mode 100644,000000..100644--- a/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/appflowy_stype_popover.dart+++ b/frontend/app_flowy/packages/flowy_infra_ui/lib/src/flowy_overlay/appflowy_stype_popover.dart@@@ -1,46 -1,0 +1,48 @@@+import 'package:flowy_infra_ui/flowy_infra_ui_web.dart';+import 'package:appflowy_popover/popover.dart';+import 'package:flutter/material.dart';++class AppFlowyStylePopover extends StatelessWidget {+ final Widget child;+ final PopoverController? controller;+ final Widget Function(BuildContext context) popupBuilder;+ final PopoverDirection direction;+ final int triggerActions;+ final BoxConstraints? constraints;+ final void Function()? onClose;+ final PopoverMutex? mutex;+ final Offset? offset;++ const AppFlowyStylePopover({+ Key? key,+ required this.child,+ required this.popupBuilder,+ this.direction = PopoverDirection.rightWithTopAligned,+ this.onClose,+ this.constraints,+ this.mutex,+ this.triggerActions = 0,+ this.offset,+ this.controller,+ }) : super(key: key);++ @override+ Widget build(BuildContext context) {+ return Popover(+ controller: controller,+ onClose: onClose,+ direction: direction,+ mutex: mutex,+ triggerActions: triggerActions,+ popupBuilder: (context) {++ final child = popupBuilder(context);++ debugPrint('$child popover');+ return OverlayContainer(+ constraints: constraints,+ child: popupBuilder(context),+ );+ },+ child: child,+ );+ }+}