refactor: fade in images on home screen

This commit is contained in:
Dr-Blank 2024-10-06 05:52:29 -04:00
parent 09eafb2c28
commit 5b896e8b09
No known key found for this signature in database
GPG key ID: 7452CC63F210A266

View file

@ -114,38 +114,41 @@ class BookOnShelf extends HookConsumerWidget {
heroTagSuffix, heroTagSuffix,
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
child: coverImage.when( child: AnimatedSwitcher(
data: (image) { duration: const Duration(milliseconds: 300),
// return const BookCoverSkeleton(); child: coverImage.when(
if (image.isEmpty) { data: (image) {
// return const BookCoverSkeleton();
if (image.isEmpty) {
return const Icon(Icons.error);
}
var imageWidget = Image.memory(
image,
fit: BoxFit.fill,
cacheWidth: (height *
1.2 *
MediaQuery.of(context)
.devicePixelRatio)
.round(),
);
return Container(
decoration: BoxDecoration(
color: Theme.of(context)
.colorScheme
.onPrimaryContainer,
),
child: imageWidget,
);
},
loading: () {
return const Center(
child: BookCoverSkeleton(),
);
},
error: (error, stack) {
return const Icon(Icons.error); return const Icon(Icons.error);
} },
var imageWidget = Image.memory( ),
image,
fit: BoxFit.fill,
cacheWidth: (height *
1.2 *
MediaQuery.of(context)
.devicePixelRatio)
.round(),
);
return Container(
decoration: BoxDecoration(
color: Theme.of(context)
.colorScheme
.onPrimaryContainer,
),
child: imageWidget,
);
},
loading: () {
return const Center(
child: BookCoverSkeleton(),
);
},
error: (error, stack) {
return const Icon(Icons.error);
},
), ),
), ),
), ),