ente/lib/ui/viewer/file/file_widget.dart
2023-08-31 06:29:46 +05:30

50 lines
1.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:photos/models/file/file.dart';
import 'package:photos/models/file/file_type.dart';
import "package:photos/ui/viewer/file/video_widget_new.dart";
import 'package:photos/ui/viewer/file/zoomable_live_image.dart';
class FileWidget extends StatelessWidget {
final EnteFile file;
final String? tagPrefix;
final Function(bool)? shouldDisableScroll;
final Function(bool)? playbackCallback;
final BoxDecoration? backgroundDecoration;
final bool? autoPlay;
const FileWidget(
this.file, {
this.autoPlay,
this.shouldDisableScroll,
this.playbackCallback,
this.tagPrefix,
this.backgroundDecoration,
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
if (file.fileType == FileType.livePhoto ||
file.fileType == FileType.image) {
return ZoomableLiveImage(
file,
shouldDisableScroll: shouldDisableScroll,
tagPrefix: tagPrefix,
backgroundDecoration: backgroundDecoration,
);
} else if (file.fileType == FileType.video) {
// return VideoWidget(
// file,
// autoPlay: autoPlay ?? false, // Autoplay if it was opened directly
// tagPrefix: tagPrefix,
// playbackCallback: playbackCallback,
// );
return VideoWidgetNew(file);
} else {
Logger('FileWidget').severe('unsupported file type ${file.fileType}');
return const Icon(Icons.error);
}
}
}