view_ext.dart 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import 'package:app_flowy/startup/plugin/plugin.dart';
  2. import 'package:flowy_infra/image.dart';
  3. import 'package:flowy_sdk/protobuf/flowy-folder/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 = svgWidget(thumbnail, color: iconColor);
  35. return widget;
  36. }
  37. PluginType get pluginType {
  38. switch (layout) {
  39. case ViewLayoutTypePB.Board:
  40. return PluginType.board;
  41. case ViewLayoutTypePB.Document:
  42. return PluginType.editor;
  43. case ViewLayoutTypePB.Grid:
  44. return PluginType.grid;
  45. }
  46. throw UnimplementedError;
  47. }
  48. Plugin plugin() {
  49. final plugin = makePlugin(pluginType: pluginType, data: this);
  50. return plugin;
  51. }
  52. }