grid.dart 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
  2. import 'package:flowy_infra_ui/style_widget/text.dart';
  3. import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
  4. import 'package:app_flowy/plugin/plugin.dart';
  5. import 'package:flutter/material.dart';
  6. import 'src/grid_page.dart';
  7. class GridPluginBuilder extends PluginBuilder {
  8. @override
  9. Plugin build(dynamic data) {
  10. if (data is View) {
  11. return GridPlugin(pluginType: pluginType, view: data);
  12. } else {
  13. throw FlowyPluginException.invalidData;
  14. }
  15. }
  16. @override
  17. String get menuName => "Table";
  18. @override
  19. PluginType get pluginType => DefaultPlugin.grid.type();
  20. }
  21. class GridPluginConfig implements PluginConfig {
  22. @override
  23. bool get creatable => true;
  24. }
  25. class GridPlugin extends Plugin {
  26. final View _view;
  27. final PluginType _pluginType;
  28. GridPlugin({
  29. required View view,
  30. required PluginType pluginType,
  31. }) : _pluginType = pluginType,
  32. _view = view;
  33. @override
  34. PluginDisplay get display => GridPluginDisplay(view: _view);
  35. @override
  36. PluginId get id => _view.id;
  37. @override
  38. PluginType get ty => _pluginType;
  39. }
  40. class GridPluginDisplay extends PluginDisplay {
  41. final View _view;
  42. GridPluginDisplay({required View view, Key? key}) : _view = view;
  43. @override
  44. Widget get leftBarItem => const FlowyText.medium("Grid demo", fontSize: 12);
  45. @override
  46. Widget buildWidget() => GridPage(view: _view);
  47. @override
  48. List<NavigationItem> get navigationItems => [this];
  49. }