Skip to content

Commit

Permalink
feat: show thumbnail while loading raw image
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon committed Jan 15, 2025
1 parent 0052a44 commit 468749c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/view/dialog/image_gallery_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import '../../i18n/strings.g.dart';
import '../../provider/cache_manager_provider.dart';
import '../../util/copy_text.dart';
import '../../util/future_with_dialog.dart';
import '../widget/image_widget.dart';
import 'message_dialog.dart';

Future<void> showImageGalleryDialog(
Expand Down Expand Up @@ -91,6 +92,34 @@ class ImageGalleryDialog extends HookConsumerWidget {
cacheManager: ref.watch(cacheManagerProvider),
),
),
loadingBuilder: (context, event) => Stack(
alignment: Alignment.center,
children: [
if (controller.page == index.value)
if (files.elementAtOrNull(index.value)?.thumbnailUrl
case final thumbnailUrl?)
Positioned.fill(
child: ImageWidget(
url: thumbnailUrl,
blurHash: thumbnailUrl,
fit: BoxFit.contain,
),
),
SizedBox.square(
dimension: 20.0,
child: CircularProgressIndicator(
value: switch (event) {
ImageChunkEvent(
:final cumulativeBytesLoaded,
:final expectedTotalBytes?
) =>
cumulativeBytesLoaded / expectedTotalBytes,
_ => null,
},
),
),
],
),
itemCount: files.length,
backgroundDecoration:
const BoxDecoration(color: Colors.transparent),
Expand Down

0 comments on commit 468749c

Please sign in to comment.