view_ext.dart 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import 'package:appflowy/startup/plugin/plugin.dart';
  2. import 'package:flowy_infra/image.dart';
  3. import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
  4. import 'package:flutter/material.dart';
  5. enum FlowyPlugin {
  6. editor,
  7. kanban,
  8. }
  9. extension FlowyPluginExtension on FlowyPlugin {
  10. String displayName() {
  11. switch (this) {
  12. case FlowyPlugin.editor:
  13. return "Doc";
  14. case FlowyPlugin.kanban:
  15. return "Kanban";
  16. default:
  17. return "";
  18. }
  19. }
  20. bool enable() {
  21. switch (this) {
  22. case FlowyPlugin.editor:
  23. return true;
  24. case FlowyPlugin.kanban:
  25. return false;
  26. default:
  27. return false;
  28. }
  29. }
  30. }
  31. extension ViewExtension on ViewPB {
  32. Widget renderThumbnail({Color? iconColor}) {
  33. String thumbnail = "file_icon";
  34. final Widget widget = FlowySvg(name: thumbnail);
  35. return widget;
  36. }
  37. PluginType get pluginType {
  38. switch (layout) {
  39. case ViewLayoutPB.Board:
  40. return PluginType.board;
  41. case ViewLayoutPB.Calendar:
  42. return PluginType.calendar;
  43. case ViewLayoutPB.Document:
  44. return PluginType.editor;
  45. case ViewLayoutPB.Grid:
  46. return PluginType.grid;
  47. }
  48. throw UnimplementedError;
  49. }
  50. Plugin plugin() {
  51. final plugin = makePlugin(pluginType: pluginType, data: this);
  52. return plugin;
  53. }
  54. }