From d282ef2eae08a1a4d819fd08516fca4dd5f3e453 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Tue, 18 Jun 2024 17:06:55 +0530 Subject: [PATCH] [mob][photos] Show video duration only on GalleryFileWidget and show a centered play icon otherwise --- mobile/lib/ui/viewer/file/thumbnail_widget.dart | 14 ++++++++++++-- .../gallery/component/gallery_file_widget.dart | 1 + .../viewer/search/result/person_face_widget.dart | 10 +++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/mobile/lib/ui/viewer/file/thumbnail_widget.dart b/mobile/lib/ui/viewer/file/thumbnail_widget.dart index 27a20e95ca..e86c0a36a8 100644 --- a/mobile/lib/ui/viewer/file/thumbnail_widget.dart +++ b/mobile/lib/ui/viewer/file/thumbnail_widget.dart @@ -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 { } 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()); diff --git a/mobile/lib/ui/viewer/gallery/component/gallery_file_widget.dart b/mobile/lib/ui/viewer/gallery/component/gallery_file_widget.dart index 5f1ce7cbfa..6bd6725376 100644 --- a/mobile/lib/ui/viewer/gallery/component/gallery_file_widget.dart +++ b/mobile/lib/ui/viewer/gallery/component/gallery_file_widget.dart @@ -55,6 +55,7 @@ class GalleryFileWidget extends StatelessWidget { ? thumbnailLargeSize : thumbnailSmallSize, shouldShowOwnerAvatar: !isFileSelected, + shouldShowVideoDuration: true, ); return GestureDetector( onTap: () { diff --git a/mobile/lib/ui/viewer/search/result/person_face_widget.dart b/mobile/lib/ui/viewer/search/result/person_face_widget.dart index 57fe5af654..e7fcf4b889 100644 --- a/mobile/lib/ui/viewer/search/result/person_face_widget.dart +++ b/mobile/lib/ui/viewer/search/result/person_face_widget.dart @@ -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;