file_widget.dart 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import 'package:flutter/material.dart';
  2. import 'package:logging/logging.dart';
  3. import 'package:photos/models/file/file.dart';
  4. import 'package:photos/models/file/file_type.dart';
  5. import "package:photos/ui/viewer/file/video_widget_new.dart";
  6. import 'package:photos/ui/viewer/file/zoomable_live_image.dart';
  7. class FileWidget extends StatelessWidget {
  8. final EnteFile file;
  9. final String? tagPrefix;
  10. final Function(bool)? shouldDisableScroll;
  11. final Function(bool)? playbackCallback;
  12. final BoxDecoration? backgroundDecoration;
  13. final bool? autoPlay;
  14. const FileWidget(
  15. this.file, {
  16. this.autoPlay,
  17. this.shouldDisableScroll,
  18. this.playbackCallback,
  19. this.tagPrefix,
  20. this.backgroundDecoration,
  21. Key? key,
  22. }) : super(key: key);
  23. @override
  24. Widget build(BuildContext context) {
  25. if (file.fileType == FileType.livePhoto ||
  26. file.fileType == FileType.image) {
  27. return ZoomableLiveImage(
  28. file,
  29. shouldDisableScroll: shouldDisableScroll,
  30. tagPrefix: tagPrefix,
  31. backgroundDecoration: backgroundDecoration,
  32. );
  33. } else if (file.fileType == FileType.video) {
  34. // return VideoWidget(
  35. // file,
  36. // autoPlay: autoPlay ?? false, // Autoplay if it was opened directly
  37. // tagPrefix: tagPrefix,
  38. // playbackCallback: playbackCallback,
  39. // );
  40. return VideoWidgetNew(file);
  41. } else {
  42. Logger('FileWidget').severe('unsupported file type ${file.fileType}');
  43. return const Icon(Icons.error);
  44. }
  45. }
  46. }