From 6c2d65587b0e6e167be1d0b086df103c7e72d4b2 Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Sun, 25 Jun 2023 10:00:44 +0600 Subject: [PATCH] fix(player): queue button not showing when not logged in --- lib/components/player/player_actions.dart | 53 +++++++------- lib/pages/home/personalized.dart | 15 ++-- lib/pages/player/player.dart | 88 ++++++++++++++++------- 3 files changed, 98 insertions(+), 58 deletions(-) diff --git a/lib/components/player/player_actions.dart b/lib/components/player/player_actions.dart index 9a01b5317..577d5a833 100644 --- a/lib/components/player/player_actions.dart +++ b/lib/components/player/player_actions.dart @@ -22,10 +22,12 @@ import 'package:spotube/utils/type_conversion_utils.dart'; class PlayerActions extends HookConsumerWidget { final MainAxisAlignment mainAxisAlignment; final bool floatingQueue; + final bool showQueue; final List? extraActions; PlayerActions({ this.mainAxisAlignment = MainAxisAlignment.center, this.floatingQueue = true, + this.showQueue = true, this.extraActions, Key? key, }) : super(key: key); @@ -72,31 +74,32 @@ class PlayerActions extends HookConsumerWidget { return Row( mainAxisAlignment: mainAxisAlignment, children: [ - IconButton( - icon: const Icon(SpotubeIcons.queue), - tooltip: context.l10n.queue, - onPressed: playlist.activeTrack != null - ? () { - showModalBottomSheet( - context: context, - isDismissible: true, - enableDrag: true, - isScrollControlled: true, - backgroundColor: Colors.black12, - barrierColor: Colors.black12, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - ), - constraints: BoxConstraints( - maxHeight: MediaQuery.of(context).size.height * .7, - ), - builder: (context) { - return PlayerQueue(floating: floatingQueue); - }, - ); - } - : null, - ), + if (showQueue) + IconButton( + icon: const Icon(SpotubeIcons.queue), + tooltip: context.l10n.queue, + onPressed: playlist.activeTrack != null + ? () { + showModalBottomSheet( + context: context, + isDismissible: true, + enableDrag: true, + isScrollControlled: true, + backgroundColor: Colors.black12, + barrierColor: Colors.black12, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + constraints: BoxConstraints( + maxHeight: MediaQuery.of(context).size.height * .7, + ), + builder: (context) { + return PlayerQueue(floating: floatingQueue); + }, + ); + } + : null, + ), if (!isLocalTrack) IconButton( icon: const Icon(SpotubeIcons.alternativeRoute), diff --git a/lib/pages/home/personalized.dart b/lib/pages/home/personalized.dart index 6c4ea851d..29f6ecb5f 100644 --- a/lib/pages/home/personalized.dart +++ b/lib/pages/home/personalized.dart @@ -10,6 +10,7 @@ import 'package:spotube/components/shared/shimmers/shimmer_playbutton_card.dart' import 'package:spotube/components/shared/waypoint.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/models/logger.dart'; +import 'package:spotube/provider/authentication_provider.dart'; import 'package:spotube/services/queries/queries.dart'; import 'package:spotube/utils/type_conversion_utils.dart'; @@ -94,6 +95,7 @@ class PersonalizedPage extends HookConsumerWidget { @override Widget build(BuildContext context, ref) { + final auth = ref.watch(AuthenticationNotifier.provider); final featuredPlaylistsQuery = useQueries.playlist.featured(ref); final playlists = useMemoized( () => featuredPlaylistsQuery.pages @@ -132,12 +134,13 @@ class PersonalizedPage extends HookConsumerWidget { hasNextPage: featuredPlaylistsQuery.hasNextPage, onFetchMore: featuredPlaylistsQuery.fetchNext, ), - PersonalizedItemCard( - albums: albums, - title: context.l10n.new_releases, - hasNextPage: newReleases.hasNextPage, - onFetchMore: newReleases.fetchNext, - ), + if (auth != null) + PersonalizedItemCard( + albums: albums, + title: context.l10n.new_releases, + hasNextPage: newReleases.hasNextPage, + onFetchMore: newReleases.fetchNext, + ), ...?madeForUser.data?["content"]?["items"]?.map((item) { final playlists = item["content"]?["items"] ?.where((itemL2) => itemL2["type"] == "playlist") diff --git a/lib/pages/player/player.dart b/lib/pages/player/player.dart index 8e7750f4b..9bd6bc8ba 100644 --- a/lib/pages/player/player.dart +++ b/lib/pages/player/player.dart @@ -9,6 +9,7 @@ import 'package:spotube/collections/assets.gen.dart'; import 'package:spotube/collections/spotube_icons.dart'; import 'package:spotube/components/player/player_actions.dart'; import 'package:spotube/components/player/player_controls.dart'; +import 'package:spotube/components/player/player_queue.dart'; import 'package:spotube/components/player/volume_slider.dart'; import 'package:spotube/components/shared/animated_gradient.dart'; import 'package:spotube/components/shared/dialogs/track_details_dialog.dart'; @@ -77,6 +78,24 @@ class PlayerView extends HookConsumerWidget { foregroundColor: titleTextColor, toolbarOpacity: 1, leading: const BackButton(), + actions: [ + IconButton( + icon: const Icon(SpotubeIcons.info, size: 18), + tooltip: context.l10n.details, + style: IconButton.styleFrom(foregroundColor: bodyTextColor), + onPressed: currentTrack == null + ? null + : () { + showDialog( + context: context, + builder: (context) { + return TrackDetailsDialog( + track: currentTrack, + ); + }); + }, + ) + ], ), extendBodyBehindAppBar: true, body: SizedBox( @@ -183,38 +202,53 @@ class PlayerView extends HookConsumerWidget { const SizedBox(height: 25), PlayerActions( mainAxisAlignment: MainAxisAlignment.spaceEvenly, - floatingQueue: false, + showQueue: false, ), const SizedBox(height: 10), - if (auth != null) - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - const SizedBox(width: 10), - Expanded( - child: OutlinedButton.icon( - icon: const Icon(SpotubeIcons.info), - label: Text(context.l10n.details), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + const SizedBox(width: 10), + Expanded( + child: OutlinedButton.icon( + icon: const Icon(SpotubeIcons.queue), + label: Text(context.l10n.queue), style: OutlinedButton.styleFrom( foregroundColor: bodyTextColor, side: BorderSide( color: bodyTextColor ?? Colors.white, ), ), - onPressed: currentTrack == null - ? null - : () { - showDialog( - context: context, - builder: (context) { - return TrackDetailsDialog( - track: currentTrack, - ); - }); - }, - ), - ), - const SizedBox(width: 10), + onPressed: currentTrack != null + ? () { + showModalBottomSheet( + context: context, + isDismissible: true, + enableDrag: true, + isScrollControlled: true, + backgroundColor: Colors.black12, + barrierColor: Colors.black12, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(10), + ), + constraints: BoxConstraints( + maxHeight: + MediaQuery.of(context) + .size + .height * + .7, + ), + builder: (context) { + return PlayerQueue( + floating: false); + }, + ); + } + : null), + ), + if (auth != null) const SizedBox(width: 10), + if (auth != null) Expanded( child: OutlinedButton.icon( label: Text(context.l10n.lyrics), @@ -251,9 +285,9 @@ class PlayerView extends HookConsumerWidget { }, ), ), - const SizedBox(width: 10), - ], - ), + const SizedBox(width: 10), + ], + ), const SizedBox(height: 25), SliderTheme( data: theme.sliderTheme.copyWith(