mirror of
https://github.com/immich-app/immich.git
synced 2024-12-17 12:22:31 +02:00
d76baee50d
* Refactor to use ImmichThumbnail and local thumbnail image provider format * dart format linter errors linter * Adds blurhash format * Fixes image blur * uses hook instead of stateful widget to be more consistent * Uses blurhash hook state * Uses blurhash ref instead of state * Fixes fade in duration for fade in placeholder * Fixes an issue where thumbnails fail to load if too many thumbnail requests are made simultaenously --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
49 lines
1.3 KiB
Dart
49 lines
1.3 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:immich_mobile/modules/home/ui/asset_grid/thumbnail_placeholder.dart';
|
|
import 'package:immich_mobile/shared/ui/fade_in_placeholder_image.dart';
|
|
import 'package:octo_image/octo_image.dart';
|
|
|
|
/// Simple set to show [OctoPlaceholder.circularProgressIndicator] as
|
|
/// placeholder and [OctoError.icon] as error.
|
|
OctoSet blurHashOrPlaceholder(
|
|
Uint8List? blurhash, {
|
|
BoxFit? fit,
|
|
Text? errorMessage,
|
|
}) {
|
|
return OctoSet(
|
|
placeholderBuilder: blurHashPlaceholderBuilder(blurhash, fit: fit),
|
|
errorBuilder: blurHashErrorBuilder(blurhash, fit: fit),
|
|
);
|
|
}
|
|
|
|
OctoPlaceholderBuilder blurHashPlaceholderBuilder(
|
|
Uint8List? blurhash, {
|
|
BoxFit? fit,
|
|
}) {
|
|
return (context) => blurhash == null
|
|
? const ThumbnailPlaceholder()
|
|
: FadeInPlaceholderImage(
|
|
placeholder: const ThumbnailPlaceholder(),
|
|
image: MemoryImage(blurhash),
|
|
fit: fit ?? BoxFit.cover,
|
|
);
|
|
}
|
|
|
|
OctoErrorBuilder blurHashErrorBuilder(
|
|
Uint8List? blurhash, {
|
|
BoxFit? fit,
|
|
Text? message,
|
|
IconData? icon,
|
|
Color? iconColor,
|
|
double? iconSize,
|
|
}) {
|
|
return OctoError.placeholderWithErrorIcon(
|
|
blurHashPlaceholderBuilder(blurhash, fit: fit),
|
|
message: message,
|
|
icon: icon,
|
|
iconColor: iconColor,
|
|
iconSize: iconSize,
|
|
);
|
|
}
|