mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: view action not working (#5325)
This commit is contained in:
parent
027ab2c1ef
commit
12ff548b09
@ -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();
|
||||
}
|
||||
|
||||
@override
|
||||
void 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(
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user