fix(mobile): blurry memory photos (#6734)

* fix(mobile): blurry memory photos

* better naming and performance
This commit is contained in:
Alex 2024-01-30 09:24:31 -06:00 committed by GitHub
parent dd9b08dafe
commit 9e1d358168
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 143 additions and 138 deletions

View file

@ -20,6 +20,7 @@ class ImmichImage extends StatelessWidget {
this.useGrayBoxPlaceholder = false,
this.useProgressIndicator = false,
this.type = api.ThumbnailFormat.WEBP,
this.preferredLocalAssetSize = 250,
super.key,
});
final Asset? asset;
@ -29,6 +30,7 @@ class ImmichImage extends StatelessWidget {
final double? height;
final BoxFit fit;
final api.ThumbnailFormat type;
final int preferredLocalAssetSize;
@override
Widget build(BuildContext context) {
@ -49,7 +51,7 @@ class ImmichImage extends StatelessWidget {
final Asset asset = this.asset!;
if (useLocal(asset)) {
return Image(
image: localThumbnailProvider(asset),
image: localImageProvider(asset, size: preferredLocalAssetSize),
width: width,
height: height,
fit: fit,
@ -145,11 +147,14 @@ class ImmichImage extends StatelessWidget {
);
}
static AssetEntityImageProvider localThumbnailProvider(Asset asset) =>
static AssetEntityImageProvider localImageProvider(
Asset asset, {
int size = 250,
}) =>
AssetEntityImageProvider(
asset.local!,
isOriginal: false,
thumbnailSize: const ThumbnailSize.square(250),
thumbnailSize: ThumbnailSize.square(size),
);
static CachedNetworkImageProvider remoteThumbnailProvider(
@ -181,10 +186,14 @@ class ImmichImage extends StatelessWidget {
Asset asset,
BuildContext context, {
type = api.ThumbnailFormat.WEBP,
size = 250,
}) {
if (useLocal(asset)) {
// Precache the local image
return precacheImage(localThumbnailProvider(asset), context);
return precacheImage(
localImageProvider(asset, size: size),
context,
);
} else {
final authToken = 'Bearer ${Store.get(StoreKey.accessToken)}';
// Precache the remote image since we are not using local images