[Mob][Photos] Show video duration only on Gallery (#2205)

## Description

- Show video duration overlay only on galleries
- In all other places, show a centred play button -- showing the overlay
on some places wasn't looking good, like memories, when opening a video
etc. So have replaced the overlay with a play button, just like before.
- Pass optional parameter to get Thumbnail without any icons stacked
over it.
This commit is contained in:
Laurens Priem
2024-06-18 18:43:28 +05:30
committed by GitHub
4 changed files with 29 additions and 5 deletions

View File

@@ -26,6 +26,9 @@ import 'package:photos/utils/thumbnail_util.dart';
class ThumbnailWidget extends StatefulWidget {
final EnteFile file;
final BoxFit fit;
/// Returns ThumbnailWidget without any overlay icons if true.
final bool rawThumbnail;
final bool shouldShowSyncStatus;
final bool shouldShowArchiveStatus;
final bool shouldShowPinIcon;
@@ -37,10 +40,15 @@ 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,
this.fit = BoxFit.cover,
this.rawThumbnail = false,
this.shouldShowSyncStatus = true,
this.shouldShowLivePhotoOverlay = false,
this.shouldShowArchiveStatus = false,
@@ -51,6 +59,7 @@ class ThumbnailWidget extends StatefulWidget {
this.serverLoadDeferDuration,
this.thumbnailSize = thumbnailSmallSize,
this.shouldShowFavoriteIcon = true,
this.shouldShowVideoDuration = false,
}) : super(key: key ?? Key(file.tag));
@override
@@ -131,6 +140,9 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {
// If yes, parent thumbnail widget can be stateless
Widget? content;
if (image != null) {
if (widget.rawThumbnail) {
return image;
}
final List<Widget> contentChildren = [image];
if (widget.shouldShowFavoriteIcon) {
if (FavoritesService.instance.isFavoriteCache(
@@ -142,8 +154,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

@@ -96,6 +96,7 @@ class CroppedFaceImageView extends StatelessWidget {
}
return ThumbnailWidget(
enteFile,
rawThumbnail: true,
);
}
},

View File

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