board_toolbar.dart 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import 'package:app_flowy/plugins/grid/application/field/field_controller.dart';
  2. import 'package:appflowy_popover/appflowy_popover.dart';
  3. import 'package:flowy_infra/image.dart';
  4. import 'package:flowy_infra_ui/flowy_infra_ui.dart';
  5. import 'package:flowy_infra_ui/style_widget/icon_button.dart';
  6. import 'package:flutter/material.dart';
  7. import 'board_setting.dart';
  8. class BoardToolbarContext {
  9. final String viewId;
  10. final GridFieldController fieldController;
  11. BoardToolbarContext({
  12. required this.viewId,
  13. required this.fieldController,
  14. });
  15. }
  16. class BoardToolbar extends StatelessWidget {
  17. final BoardToolbarContext toolbarContext;
  18. const BoardToolbar({
  19. required this.toolbarContext,
  20. Key? key,
  21. }) : super(key: key);
  22. @override
  23. Widget build(BuildContext context) {
  24. return SizedBox(
  25. height: 40,
  26. child: Row(
  27. children: [
  28. _SettingButton(
  29. settingContext: BoardSettingContext.from(toolbarContext),
  30. ),
  31. ],
  32. ),
  33. );
  34. }
  35. }
  36. class _SettingButton extends StatefulWidget {
  37. final BoardSettingContext settingContext;
  38. const _SettingButton({required this.settingContext, Key? key})
  39. : super(key: key);
  40. @override
  41. State<_SettingButton> createState() => _SettingButtonState();
  42. }
  43. class _SettingButtonState extends State<_SettingButton> {
  44. late PopoverController popoverController;
  45. @override
  46. void initState() {
  47. popoverController = PopoverController();
  48. super.initState();
  49. }
  50. @override
  51. Widget build(BuildContext context) {
  52. return AppFlowyPopover(
  53. controller: popoverController,
  54. constraints: BoxConstraints.loose(const Size(260, 400)),
  55. child: FlowyIconButton(
  56. width: 22,
  57. icon: Padding(
  58. padding: const EdgeInsets.symmetric(vertical: 3.0, horizontal: 3.0),
  59. child: svgWidget(
  60. "grid/setting/setting",
  61. color: Theme.of(context).colorScheme.onSurface,
  62. ),
  63. ),
  64. ),
  65. popupBuilder: (BuildContext popoverContext) {
  66. return BoardSettingListPopover(
  67. settingContext: widget.settingContext,
  68. popoverController: popoverController,
  69. );
  70. },
  71. );
  72. }
  73. }