mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-11-09 13:09:21 +03: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/flowy_svgs.g.dart';
|
||||||
import 'package:appflowy/generated/locale_keys.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/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/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/common_view_action.dart';
|
||||||
import 'package:appflowy/workspace/presentation/widgets/more_view_actions/widgets/font_size_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> {
|
class _MoreViewActionsState extends State<MoreViewActions> {
|
||||||
late final List<Widget> viewActions;
|
|
||||||
final popoverMutex = PopoverMutex();
|
final popoverMutex = PopoverMutex();
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
viewActions = ViewActionType.values
|
|
||||||
.map(
|
|
||||||
(type) => ViewAction(
|
|
||||||
type: type,
|
|
||||||
view: widget.view,
|
|
||||||
mutex: popoverMutex,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
popoverMutex.dispose();
|
popoverMutex.dispose();
|
||||||
@ -74,7 +60,13 @@ class _MoreViewActionsState extends State<MoreViewActions> {
|
|||||||
const FontSizeAction(),
|
const FontSizeAction(),
|
||||||
const Divider(height: 4),
|
const Divider(height: 4),
|
||||||
],
|
],
|
||||||
...viewActions,
|
...ViewActionType.values.map(
|
||||||
|
(type) => ViewAction(
|
||||||
|
type: type,
|
||||||
|
view: widget.view,
|
||||||
|
mutex: popoverMutex,
|
||||||
|
),
|
||||||
|
),
|
||||||
if (state.documentCounters != null ||
|
if (state.documentCounters != null ||
|
||||||
state.createdAt != null) ...[
|
state.createdAt != null) ...[
|
||||||
const Divider(height: 4),
|
const Divider(height: 4),
|
||||||
@ -87,13 +79,17 @@ class _MoreViewActionsState extends State<MoreViewActions> {
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
return ListView.separated(
|
return BlocProvider(
|
||||||
|
create: (_) =>
|
||||||
|
ViewBloc(view: widget.view)..add(const ViewEvent.initial()),
|
||||||
|
child: ListView.separated(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
itemCount: actions.length,
|
itemCount: actions.length,
|
||||||
separatorBuilder: (_, __) => const VSpace(4),
|
separatorBuilder: (_, __) => const VSpace(4),
|
||||||
physics: StyledScrollPhysics(),
|
physics: StyledScrollPhysics(),
|
||||||
itemBuilder: (_, index) => actions[index],
|
itemBuilder: (_, index) => actions[index],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: FlowyTooltip(
|
child: FlowyTooltip(
|
||||||
|
@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import 'package:appflowy/generated/flowy_svgs.g.dart';
|
import 'package:appflowy/generated/flowy_svgs.g.dart';
|
||||||
import 'package:appflowy/generated/locale_keys.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/workspace/application/view/view_bloc.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:appflowy_popover/appflowy_popover.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/theme_extension.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/button.dart';
|
import 'package:flowy_infra_ui/style_widget/button.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
enum ViewActionType {
|
enum ViewActionType {
|
||||||
delete,
|
delete,
|
||||||
@ -47,7 +47,7 @@ class ViewAction extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FlowyButton(
|
return FlowyButton(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
getIt<ViewBloc>(param1: view).add(type.actionEvent);
|
context.read<ViewBloc>().add(type.actionEvent);
|
||||||
mutex?.close();
|
mutex?.close();
|
||||||
},
|
},
|
||||||
text: FlowyText.regular(
|
text: FlowyText.regular(
|
||||||
|
Loading…
Reference in New Issue
Block a user