💄 Optimize cloud file rendering
This commit is contained in:
		| @@ -812,11 +812,16 @@ class _CloudFileListEntry extends HookConsumerWidget { | |||||||
|     final lockedByDS = dataSaving && !showDataSaving.value; |     final lockedByDS = dataSaving && !showDataSaving.value; | ||||||
|     final lockedByMature = file.sensitiveMarks.isNotEmpty && !showMature.value; |     final lockedByMature = file.sensitiveMarks.isNotEmpty && !showMature.value; | ||||||
|     final meta = file.fileMeta is Map ? file.fileMeta as Map : const {}; |     final meta = file.fileMeta is Map ? file.fileMeta as Map : const {}; | ||||||
|  |     final hasRatio = | ||||||
|  |         meta.containsKey('ratio') && | ||||||
|  |         (meta['ratio'] is num && (meta['ratio'] as num) != 0); | ||||||
|     final ratio = |     final ratio = | ||||||
|         (meta['ratio'] is num && (meta['ratio'] as num) != 0) |         (meta['ratio'] is num && (meta['ratio'] as num) != 0) | ||||||
|             ? (meta['ratio'] as num).toDouble() |             ? (meta['ratio'] as num).toDouble() | ||||||
|             : 1.0; |             : 1.0; | ||||||
|  |  | ||||||
|  |     final fit = hasRatio ? BoxFit.cover : BoxFit.contain; | ||||||
|  |  | ||||||
|     Widget bg = const SizedBox.shrink(); |     Widget bg = const SizedBox.shrink(); | ||||||
|     if (isImage) { |     if (isImage) { | ||||||
|       if (meta['blur'] is String) { |       if (meta['blur'] is String) { | ||||||
| @@ -825,6 +830,7 @@ class _CloudFileListEntry extends HookConsumerWidget { | |||||||
|         bg = ImageFiltered( |         bg = ImageFiltered( | ||||||
|           imageFilter: ImageFilter.blur(sigmaX: 10, sigmaY: 10), |           imageFilter: ImageFilter.blur(sigmaX: 10, sigmaY: 10), | ||||||
|           child: CloudFileWidget( |           child: CloudFileWidget( | ||||||
|  |             fit: fit, | ||||||
|             item: file, |             item: file, | ||||||
|             noBlurhash: true, |             noBlurhash: true, | ||||||
|             useInternalGate: false, |             useInternalGate: false, | ||||||
| @@ -843,13 +849,13 @@ class _CloudFileListEntry extends HookConsumerWidget { | |||||||
|                   item: file, |                   item: file, | ||||||
|                   heroTag: heroTag, |                   heroTag: heroTag, | ||||||
|                   noBlurhash: true, |                   noBlurhash: true, | ||||||
|                   fit: BoxFit.contain, |                   fit: fit, | ||||||
|                   useInternalGate: false, |                   useInternalGate: false, | ||||||
|                 ) |                 ) | ||||||
|                 : CloudFileWidget( |                 : CloudFileWidget( | ||||||
|                   item: file, |                   item: file, | ||||||
|                   heroTag: heroTag, |                   heroTag: heroTag, | ||||||
|                   fit: BoxFit.contain, |                   fit: fit, | ||||||
|                   useInternalGate: false, |                   useInternalGate: false, | ||||||
|                 )) |                 )) | ||||||
|             : AspectRatio(aspectRatio: ratio, child: const SizedBox.shrink()); |             : AspectRatio(aspectRatio: ratio, child: const SizedBox.shrink()); | ||||||
|   | |||||||
| @@ -31,10 +31,7 @@ class UniversalImage extends StatelessWidget { | |||||||
|           height != null ? (height! * devicePixelRatio).round() : null; |           height != null ? (height! * devicePixelRatio).round() : null; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return SizedBox( |     return Stack( | ||||||
|       width: width, |  | ||||||
|       height: height, |  | ||||||
|       child: Stack( |  | ||||||
|       fit: StackFit.expand, |       fit: StackFit.expand, | ||||||
|       children: [ |       children: [ | ||||||
|         if (blurHash != null) BlurHash(hash: blurHash!), |         if (blurHash != null) BlurHash(hash: blurHash!), | ||||||
| @@ -59,7 +56,6 @@ class UniversalImage extends StatelessWidget { | |||||||
|           }, |           }, | ||||||
|         ), |         ), | ||||||
|       ], |       ], | ||||||
|       ), |  | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user