view_ext.dart 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import 'package:app_flowy/plugin/plugin.dart';
  2. import 'package:flowy_infra/image.dart';
  3. import 'package:flowy_sdk/protobuf/flowy-folder-data-model/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 View {
  32. Widget renderThumbnail({Color? iconColor}) {
  33. String thumbnail = this.thumbnail;
  34. if (thumbnail.isEmpty) {
  35. thumbnail = "file_icon";
  36. }
  37. final Widget widget = svg(thumbnail, color: iconColor);
  38. return widget;
  39. }
  40. Plugin plugin() {
  41. final plugin = makePlugin(pluginType: pluginType, data: this);
  42. return plugin;
  43. }
  44. }