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
fix: view action not working (#5325)
Mathias Mogensen12ff548b09da
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/more_view_actions/more_view_actions.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/more_view_actions/more_view_actions.dartindex 529807c4f4..3d0416f589 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/more_view_actions/more_view_actions.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/more_view_actions/more_view_actions.dart@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';import 'package:appflowy/generated/flowy_svgs.g.dart';import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart';+import 'package:appflowy/workspace/application/view/view_bloc.dart';import 'package:appflowy/workspace/application/view_info/view_info_bloc.dart';import 'package:appflowy/workspace/presentation/widgets/more_view_actions/widgets/common_view_action.dart';import 'package:appflowy/workspace/presentation/widgets/more_view_actions/widgets/font_size_action.dart';@@ -33,23 +34,8 @@ class MoreViewActions extends StatefulWidget {}class _MoreViewActionsState extends State<MoreViewActions> {- late final List<Widget> viewActions;final popoverMutex = PopoverMutex();- @override- void initState() {- super.initState();- viewActions = ViewActionType.values- .map(- (type) => ViewAction(- type: type,- view: widget.view,- mutex: popoverMutex,- ),- )- .toList();- }-@overridevoid dispose() {popoverMutex.dispose();@@ -74,7 +60,13 @@ class _MoreViewActionsState extends State<MoreViewActions> {const FontSizeAction(),const Divider(height: 4),],- ...viewActions,+ ...ViewActionType.values.map(+ (type) => ViewAction(+ type: type,+ view: widget.view,+ mutex: popoverMutex,+ ),+ ),if (state.documentCounters != null ||state.createdAt != null) ...[const Divider(height: 4),@@ -87,13 +79,17 @@ class _MoreViewActionsState extends State<MoreViewActions> {],];- return ListView.separated(- shrinkWrap: true,- padding: EdgeInsets.zero,- itemCount: actions.length,- separatorBuilder: (_, __) => const VSpace(4),- physics: StyledScrollPhysics(),- itemBuilder: (_, index) => actions[index],+ return BlocProvider(+ create: (_) =>+ ViewBloc(view: widget.view)..add(const ViewEvent.initial()),+ child: ListView.separated(+ shrinkWrap: true,+ padding: EdgeInsets.zero,+ itemCount: actions.length,+ separatorBuilder: (_, __) => const VSpace(4),+ physics: StyledScrollPhysics(),+ itemBuilder: (_, index) => actions[index],+ ),);},child: FlowyTooltip(diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/more_view_actions/widgets/common_view_action.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/more_view_actions/widgets/common_view_action.dartindex 0ce56272b1..c54f6169a2 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/more_view_actions/widgets/common_view_action.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/more_view_actions/widgets/common_view_action.dart@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';import 'package:appflowy/generated/flowy_svgs.g.dart';import 'package:appflowy/generated/locale_keys.g.dart';-import 'package:appflowy/startup/startup.dart';import 'package:appflowy/workspace/application/view/view_bloc.dart';import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';import 'package:appflowy_popover/appflowy_popover.dart';@@ -10,6 +9,7 @@ import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra/theme_extension.dart';import 'package:flowy_infra_ui/style_widget/button.dart';import 'package:flowy_infra_ui/style_widget/text.dart';+import 'package:flutter_bloc/flutter_bloc.dart';enum ViewActionType {delete,@@ -47,7 +47,7 @@ class ViewAction extends StatelessWidget {Widget build(BuildContext context) {return FlowyButton(onTap: () {- getIt<ViewBloc>(param1: view).add(type.actionEvent);+ context.read<ViewBloc>().add(type.actionEvent);mutex?.close();},text: FlowyText.regular(