Skip to content

Commit

Permalink
Add blur background transition
Browse files Browse the repository at this point in the history
  • Loading branch information
jmshrv committed Jul 27, 2022
1 parent c3b47c5 commit 2a9fafc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/screens/player_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,21 @@ class _PlayerScreenBlurHash extends StatelessWidget {
return StreamBuilder<MediaItem?>(
stream: audioHandler.mediaItem,
builder: (context, snapshot) {
Widget? dynWidget;
if (snapshot.hasData) {
final item =
BaseItemDto.fromJson(snapshot.data!.extras!["itemJson"]);

final blurHash = item.imageBlurHashes?.primary?.values.first;

if (blurHash != null) {
return ColorFiltered(
dynWidget = ColorFiltered(
colorFilter: ColorFilter.mode(
Theme.of(context).brightness == Brightness.dark
? Colors.black.withOpacity(0.35)
: Colors.white.withOpacity(0.75),
BlendMode.srcOver),
key: ValueKey<String>(blurHash),
child: BlurHash(
hash: blurHash,
imageFit: BoxFit.cover,
Expand All @@ -160,7 +162,12 @@ class _PlayerScreenBlurHash extends StatelessWidget {
}
}

return const SizedBox.shrink();
dynWidget ??= const SizedBox.shrink();

return AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
child: dynWidget,
);
});
}
}

0 comments on commit 2a9fafc

Please sign in to comment.