From 0ebac05a4be8e8f744a6c672d3bb9807d6f02e10 Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Tue, 11 Oct 2022 14:57:26 +0600 Subject: [PATCH] fix: PlayerOverlay not hiding when not playing and unneeded bottom space in TrackTableView --- lib/components/Player/PlayerOverlay.dart | 106 ++++++++++-------- .../Shared/TrackCollectionView.dart | 1 - lib/components/Shared/TracksTableView.dart | 3 - 3 files changed, 59 insertions(+), 51 deletions(-) diff --git a/lib/components/Player/PlayerOverlay.dart b/lib/components/Player/PlayerOverlay.dart index 0af1b362d..f5104722b 100644 --- a/lib/components/Player/PlayerOverlay.dart +++ b/lib/components/Player/PlayerOverlay.dart @@ -21,6 +21,14 @@ class PlayerOverlay extends HookConsumerWidget { @override Widget build(BuildContext context, ref) { final paletteColor = usePaletteColor(albumArt, ref); + final canShow = ref.watch( + playbackProvider.select( + (s) => + s.track != null || + s.isPlaying || + s.status == PlaybackStatus.loading, + ), + ); final onNext = useNextTrack(ref); final onPrevious = usePreviousTrack(ref); @@ -38,9 +46,9 @@ class PlayerOverlay extends HookConsumerWidget { child: BackdropFilter( filter: ImageFilter.blur(sigmaX: 15, sigmaY: 15), child: AnimatedContainer( - duration: const Duration(milliseconds: 500), + duration: const Duration(milliseconds: 250), width: MediaQuery.of(context).size.width, - height: 50, + height: canShow ? 50 : 0, decoration: BoxDecoration( color: paletteColor.color.withOpacity(.7), border: Border.all( @@ -49,55 +57,59 @@ class PlayerOverlay extends HookConsumerWidget { ), borderRadius: BorderRadius.circular(5), ), - child: Material( - type: MaterialType.transparency, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( - onTap: () => GoRouter.of(context).push("/player"), - child: PlayerTrackDetails( - albumArt: albumArt, - color: paletteColor.bodyTextColor, + child: AnimatedOpacity( + duration: const Duration(milliseconds: 250), + opacity: canShow ? 1 : 0, + child: Material( + type: MaterialType.transparency, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () => GoRouter.of(context).push("/player"), + child: PlayerTrackDetails( + albumArt: albumArt, + color: paletteColor.bodyTextColor, + ), ), ), ), - ), - Row( - children: [ - IconButton( - icon: const Icon(Icons.skip_previous_rounded), - color: paletteColor.bodyTextColor, - onPressed: () { - onPrevious(); - }), - Consumer( - builder: (context, ref, _) { - return IconButton( - icon: Icon( - ref.read(playbackProvider).isPlaying - ? Icons.pause_rounded - : Icons.play_arrow_rounded, - ), + Row( + children: [ + IconButton( + icon: const Icon(Icons.skip_previous_rounded), color: paletteColor.bodyTextColor, - onPressed: Actions.handler( - context, - PlayPauseIntent(ref), - ), - ); - }, - ), - IconButton( - icon: const Icon(Icons.skip_next_rounded), - onPressed: () => onNext(), - color: paletteColor.bodyTextColor, - ), - ], - ), - ], + onPressed: () { + onPrevious(); + }), + Consumer( + builder: (context, ref, _) { + return IconButton( + icon: Icon( + ref.read(playbackProvider).isPlaying + ? Icons.pause_rounded + : Icons.play_arrow_rounded, + ), + color: paletteColor.bodyTextColor, + onPressed: Actions.handler( + context, + PlayPauseIntent(ref), + ), + ); + }, + ), + IconButton( + icon: const Icon(Icons.skip_next_rounded), + onPressed: () => onNext(), + color: paletteColor.bodyTextColor, + ), + ], + ), + ], + ), ), ), ), diff --git a/lib/components/Shared/TrackCollectionView.dart b/lib/components/Shared/TrackCollectionView.dart index fd3306279..c0e41d642 100644 --- a/lib/components/Shared/TrackCollectionView.dart +++ b/lib/components/Shared/TrackCollectionView.dart @@ -233,7 +233,6 @@ class TrackCollectionView extends HookConsumerWidget { onTrackPlayButtonPressed: onPlay, playlistId: id, userPlaylist: isOwned, - bottomSpace: bottomSpace, ); }, error: (error, _) => diff --git a/lib/components/Shared/TracksTableView.dart b/lib/components/Shared/TracksTableView.dart index d06cb17a6..fb4da8f4f 100644 --- a/lib/components/Shared/TracksTableView.dart +++ b/lib/components/Shared/TracksTableView.dart @@ -15,7 +15,6 @@ class TracksTableView extends HookConsumerWidget { final List tracks; final bool userPlaylist; final String? playlistId; - final bool bottomSpace; final bool isSliver; final Widget? heading; @@ -26,7 +25,6 @@ class TracksTableView extends HookConsumerWidget { this.userPlaylist = false, this.playlistId, this.heading, - this.bottomSpace = false, this.isSliver = true, }) : super(key: key); @@ -191,7 +189,6 @@ class TracksTableView extends HookConsumerWidget { ), ); }).toList(), - if (bottomSpace) const SizedBox(height: 70), ]; if (isSliver) {