board.dart 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
  2. import 'package:app_flowy/workspace/presentation/widgets/left_bar_item.dart';
  3. import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
  4. import 'package:app_flowy/startup/plugin/plugin.dart';
  5. import 'package:flutter/material.dart';
  6. import 'presentation/board_page.dart';
  7. class BoardPluginBuilder implements PluginBuilder {
  8. @override
  9. Plugin build(dynamic data) {
  10. if (data is ViewPB) {
  11. return BoardPlugin(pluginType: pluginType, view: data);
  12. } else {
  13. throw FlowyPluginException.invalidData;
  14. }
  15. }
  16. @override
  17. String get menuName => "Board";
  18. @override
  19. PluginType get pluginType => PluginType.board;
  20. @override
  21. ViewDataTypePB get dataType => ViewDataTypePB.Database;
  22. @override
  23. ViewLayoutTypePB? get subDataType => ViewLayoutTypePB.Board;
  24. }
  25. class BoardPluginConfig implements PluginConfig {
  26. @override
  27. bool get creatable => false;
  28. }
  29. class BoardPlugin extends Plugin {
  30. final ViewPB _view;
  31. final PluginType _pluginType;
  32. BoardPlugin({
  33. required ViewPB view,
  34. required PluginType pluginType,
  35. }) : _pluginType = pluginType,
  36. _view = view;
  37. @override
  38. PluginDisplay get display => GridPluginDisplay(view: _view);
  39. @override
  40. PluginId get id => _view.id;
  41. @override
  42. PluginType get ty => _pluginType;
  43. }
  44. class GridPluginDisplay extends PluginDisplay {
  45. final ViewPB _view;
  46. GridPluginDisplay({required ViewPB view, Key? key}) : _view = view;
  47. @override
  48. Widget get leftBarItem => ViewLeftBarItem(view: _view);
  49. @override
  50. Widget buildWidget() => BoardPage(view: _view);
  51. @override
  52. List<NavigationItem> get navigationItems => [this];
  53. }