Skip to content

Commit

Permalink
perf: artwork fading effect improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Dec 24, 2023
1 parent aa43912 commit 071d810
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/ui/widgets/artwork.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,25 @@ class _ArtworkWidgetState extends State<ArtworkWidget> with LoadingItemsDelayMix
height: realWidthAndHeight,
frameBuilder: ((context, child, frame, wasSynchronouslyLoaded) {
if (wasSynchronouslyLoaded) return child;
return AnimatedSwitcher(
if (bytes != null && bytes.isNotEmpty) return child;
if (frame == null) return child;

return TweenAnimationBuilder(
tween: Tween<double>(begin: 1.0, end: 0.0),
duration: Duration(milliseconds: widget.fadeMilliSeconds),
child: frame != null ? child : const SizedBox(),
child: child,
builder: (context, value, child) {
return Stack(
children: [
child!,
Positioned.fill(
child: IgnorePointer(
child: ColoredBox(color: context.theme.cardColor.withOpacity(value)),
),
),
],
);
},
);
}),
errorBuilder: (context, error, stackTrace) {
Expand Down

0 comments on commit 071d810

Please sign in to comment.