view_ext.dart 910 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import 'package:flowy_infra/image.dart';
  2. import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
  3. import 'package:flutter/material.dart';
  4. enum FlowyPlugin {
  5. editor,
  6. kanban,
  7. }
  8. extension FlowyPluginExtension on FlowyPlugin {
  9. String displayName() {
  10. switch (this) {
  11. case FlowyPlugin.editor:
  12. return "Doc";
  13. case FlowyPlugin.kanban:
  14. return "Kanban";
  15. default:
  16. return "";
  17. }
  18. }
  19. bool enable() {
  20. switch (this) {
  21. case FlowyPlugin.editor:
  22. return true;
  23. case FlowyPlugin.kanban:
  24. return false;
  25. default:
  26. return false;
  27. }
  28. }
  29. }
  30. extension ViewExtension on View {
  31. Widget renderThumbnail({Color? iconColor}) {
  32. String thumbnail = this.thumbnail;
  33. if (thumbnail.isEmpty) {
  34. thumbnail = "file_icon";
  35. }
  36. final Widget widget = svg(thumbnail, color: iconColor);
  37. return widget;
  38. }
  39. }