menu.dart 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import 'package:app_flowy/startup/plugin/plugin.dart';
  2. import 'package:app_flowy/startup/startup.dart';
  3. import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
  4. import 'package:app_flowy/workspace/presentation/home/menu/menu.dart';
  5. import 'package:easy_localization/easy_localization.dart';
  6. import 'package:flowy_infra/color_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:app_flowy/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<HomeStackManager>()
  33. .setPlugin(makePlugin(pluginType: PluginType.trash));
  34. },
  35. child: _render(context),
  36. ),
  37. ).padding(horizontal: Insets.l),
  38. ).padding(horizontal: 8);
  39. },
  40. );
  41. }
  42. Widget _render(BuildContext context) {
  43. return Row(
  44. children: [
  45. SizedBox(
  46. width: 16,
  47. height: 16,
  48. child: svgWidget(
  49. "home/trash",
  50. color: Theme.of(context).colorScheme.onSurface,
  51. ),
  52. ),
  53. const HSpace(6),
  54. FlowyText.medium(LocaleKeys.trash_text.tr()),
  55. ],
  56. );
  57. }
  58. }