[mob][photos] Show video duration only on GalleryFileWidget and show a centered play icon otherwise

This commit is contained in:
ashilkn
2024-06-18 17:06:55 +05:30
parent ff0fa9a69f
commit d282ef2eae
3 changed files with 20 additions and 5 deletions

View File

@@ -26,6 +26,7 @@ import 'package:photos/utils/thumbnail_util.dart';
class ThumbnailWidget extends StatefulWidget {
final EnteFile file;
final BoxFit fit;
final bool shouldShowSyncStatus;
final bool shouldShowArchiveStatus;
final bool shouldShowPinIcon;
@@ -37,6 +38,10 @@ class ThumbnailWidget extends StatefulWidget {
final bool shouldShowOwnerAvatar;
final bool shouldShowFavoriteIcon;
///On video thumbnails, shows the video duration if true. If false,
///shows a centered play icon.
final bool shouldShowVideoDuration;
ThumbnailWidget(
this.file, {
Key? key,
@@ -51,6 +56,7 @@ class ThumbnailWidget extends StatefulWidget {
this.serverLoadDeferDuration,
this.thumbnailSize = thumbnailSmallSize,
this.shouldShowFavoriteIcon = true,
this.shouldShowVideoDuration = false,
}) : super(key: key ?? Key(file.tag));
@override
@@ -142,8 +148,12 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {
}
if (widget.file.fileType == FileType.video) {
contentChildren
.add(VideoOverlayDuration(duration: widget.file.duration!));
if (widget.shouldShowVideoDuration) {
contentChildren
.add(VideoOverlayDuration(duration: widget.file.duration!));
} else {
contentChildren.add(const VideoOverlayIcon());
}
} else if (widget.shouldShowLivePhotoOverlay &&
widget.file.isLiveOrMotionPhoto) {
contentChildren.add(const LivePhotoOverlayIcon());

View File

@@ -55,6 +55,7 @@ class GalleryFileWidget extends StatelessWidget {
? thumbnailLargeSize
: thumbnailSmallSize,
shouldShowOwnerAvatar: !isFileSelected,
shouldShowVideoDuration: true,
);
return GestureDetector(
onTap: () {

View File

@@ -74,7 +74,9 @@ class PersonFaceWidget extends StatelessWidget {
log('Error getting cover face for person: ${snapshot.error}');
}
return thumbnailFallback
? ThumbnailWidget(file)
? ThumbnailWidget(
file,
)
: const EnteLoadingWidget();
}
},
@@ -96,7 +98,9 @@ class PersonFaceWidget extends StatelessWidget {
log('Error getting cover face for person: ${snapshot.error}');
}
return thumbnailFallback
? ThumbnailWidget(file)
? ThumbnailWidget(
file,
)
: const EnteLoadingWidget();
}
},
@@ -188,7 +192,7 @@ class PersonFaceWidget extends StatelessWidget {
stackTrace: s,
);
resetPool(fullFile: useFullFile);
if(fetchAttempt <= retryLimit) {
if (fetchAttempt <= retryLimit) {
return getFaceCrop(fetchAttempt: fetchAttempt + 1);
}
return null;