menu.dart 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import 'package:appflowy/startup/plugin/plugin.dart';
  2. import 'package:appflowy/startup/startup.dart';
  3. import 'package:appflowy/workspace/application/tabs/tabs_bloc.dart';
  4. import 'package:appflowy/workspace/presentation/home/menu/menu.dart';
  5. import 'package:easy_localization/easy_localization.dart';
  6. import 'package:flowy_infra/theme_extension.dart';
  7. import 'package:flowy_infra/image.dart';
  8. import 'package:flowy_infra/size.dart';
  9. import 'package:flowy_infra_ui/style_widget/extension.dart';
  10. import 'package:flowy_infra_ui/style_widget/hover.dart';
  11. import 'package:flowy_infra_ui/style_widget/text.dart';
  12. import 'package:flowy_infra_ui/widget/spacing.dart';
  13. import 'package:flutter/material.dart';
  14. import 'package:appflowy/generated/locale_keys.g.dart';
  15. class MenuTrash extends StatelessWidget {
  16. const MenuTrash({Key? key}) : super(key: key);
  17. @override
  18. Widget build(BuildContext context) {
  19. return ValueListenableBuilder(
  20. valueListenable: getIt<MenuSharedState>().notifier,
  21. builder: (context, value, child) {
  22. return FlowyHover(
  23. style: HoverStyle(
  24. hoverColor: AFThemeExtension.of(context).greySelect,
  25. ),
  26. isSelected: () => getIt<MenuSharedState>().latestOpenView == null,
  27. child: SizedBox(
  28. height: 26,
  29. child: InkWell(
  30. onTap: () {
  31. getIt<MenuSharedState>().latestOpenView = null;
  32. getIt<TabsBloc>().add(
  33. TabsEvent.openPlugin(
  34. plugin: makePlugin(pluginType: PluginType.trash),
  35. ),
  36. );
  37. },
  38. child: _render(context),
  39. ),
  40. ).padding(horizontal: Insets.l),
  41. ).padding(horizontal: 8);
  42. },
  43. );
  44. }
  45. Widget _render(BuildContext context) {
  46. return Row(
  47. children: [
  48. const FlowySvg(
  49. size: Size(16, 16),
  50. name: 'home/trash',
  51. ),
  52. const HSpace(6),
  53. FlowyText.medium(LocaleKeys.trash_text.tr()),
  54. ],
  55. );
  56. }
  57. }