board_toolbar.dart 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import 'package:app_flowy/plugins/grid/application/field/field_controller.dart';
  2. import 'package:appflowy_popover/appflowy_popover.dart';
  3. import 'package:easy_localization/easy_localization.dart';
  4. import 'package:flowy_infra/color_extension.dart';
  5. import 'package:flowy_infra_ui/flowy_infra_ui.dart';
  6. import 'package:flowy_infra_ui/style_widget/button.dart';
  7. import 'package:flutter/material.dart';
  8. import '../../../../generated/locale_keys.g.dart';
  9. import 'board_setting.dart';
  10. class BoardToolbarContext {
  11. final String viewId;
  12. final GridFieldController fieldController;
  13. BoardToolbarContext({
  14. required this.viewId,
  15. required this.fieldController,
  16. });
  17. }
  18. class BoardToolbar extends StatelessWidget {
  19. final BoardToolbarContext toolbarContext;
  20. const BoardToolbar({
  21. required this.toolbarContext,
  22. Key? key,
  23. }) : super(key: key);
  24. @override
  25. Widget build(BuildContext context) {
  26. return SizedBox(
  27. height: 40,
  28. child: Row(
  29. children: [
  30. const Spacer(),
  31. _SettingButton(
  32. settingContext: BoardSettingContext.from(toolbarContext),
  33. ),
  34. ],
  35. ),
  36. );
  37. }
  38. }
  39. class _SettingButton extends StatefulWidget {
  40. final BoardSettingContext settingContext;
  41. const _SettingButton({required this.settingContext, Key? key})
  42. : super(key: key);
  43. @override
  44. State<_SettingButton> createState() => _SettingButtonState();
  45. }
  46. class _SettingButtonState extends State<_SettingButton> {
  47. late PopoverController popoverController;
  48. @override
  49. void initState() {
  50. popoverController = PopoverController();
  51. super.initState();
  52. }
  53. @override
  54. Widget build(BuildContext context) {
  55. return AppFlowyPopover(
  56. controller: popoverController,
  57. direction: PopoverDirection.leftWithTopAligned,
  58. triggerActions: PopoverTriggerFlags.none,
  59. constraints: BoxConstraints.loose(const Size(260, 400)),
  60. child: FlowyTextButton(
  61. LocaleKeys.settings_title.tr(),
  62. fontSize: 14,
  63. fillColor: Colors.transparent,
  64. hoverColor: AFThemeExtension.of(context).lightGreyHover,
  65. padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 6),
  66. onPressed: () {
  67. popoverController.show();
  68. },
  69. ),
  70. popupBuilder: (BuildContext popoverContext) {
  71. return BoardSettingListPopover(
  72. settingContext: widget.settingContext,
  73. popoverController: popoverController,
  74. );
  75. },
  76. );
  77. }
  78. }