Skip to content

Commit

Permalink
fix: PlayerOverlay not hiding when not playing and unneeded bottom sp…
Browse files Browse the repository at this point in the history
…ace in TrackTableView
  • Loading branch information
KRTirtho committed Oct 11, 2022
1 parent 0ca97b4 commit 0ebac05
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 51 deletions.
106 changes: 59 additions & 47 deletions lib/components/Player/PlayerOverlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(
Expand 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<PlayPauseIntent>(
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<PlayPauseIntent>(
context,
PlayPauseIntent(ref),
),
);
},
),
IconButton(
icon: const Icon(Icons.skip_next_rounded),
onPressed: () => onNext(),
color: paletteColor.bodyTextColor,
),
],
),
],
),
),
),
),
Expand Down
1 change: 0 additions & 1 deletion lib/components/Shared/TrackCollectionView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ class TrackCollectionView extends HookConsumerWidget {
onTrackPlayButtonPressed: onPlay,
playlistId: id,
userPlaylist: isOwned,
bottomSpace: bottomSpace,
);
},
error: (error, _) =>
Expand Down
3 changes: 0 additions & 3 deletions lib/components/Shared/TracksTableView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class TracksTableView extends HookConsumerWidget {
final List<Track> tracks;
final bool userPlaylist;
final String? playlistId;
final bool bottomSpace;
final bool isSliver;

final Widget? heading;
Expand All @@ -26,7 +25,6 @@ class TracksTableView extends HookConsumerWidget {
this.userPlaylist = false,
this.playlistId,
this.heading,
this.bottomSpace = false,
this.isSliver = true,
}) : super(key: key);

Expand Down Expand Up @@ -191,7 +189,6 @@ class TracksTableView extends HookConsumerWidget {
),
);
}).toList(),
if (bottomSpace) const SizedBox(height: 70),
];

if (isSliver) {
Expand Down

0 comments on commit 0ebac05

Please sign in to comment.