mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix: heart button showing when not logged in, wrong login redirect
This commit is contained in:
parent
9465d92fa0
commit
4dc26af23d
@ -9,6 +9,7 @@ import 'package:spotube/components/player/player_queue.dart';
|
|||||||
import 'package:spotube/components/player/sibling_tracks_sheet.dart';
|
import 'package:spotube/components/player/sibling_tracks_sheet.dart';
|
||||||
import 'package:spotube/components/shared/heart_button.dart';
|
import 'package:spotube/components/shared/heart_button.dart';
|
||||||
import 'package:spotube/models/logger.dart';
|
import 'package:spotube/models/logger.dart';
|
||||||
|
import 'package:spotube/provider/auth_provider.dart';
|
||||||
import 'package:spotube/provider/downloader_provider.dart';
|
import 'package:spotube/provider/downloader_provider.dart';
|
||||||
import 'package:spotube/provider/playback_provider.dart';
|
import 'package:spotube/provider/playback_provider.dart';
|
||||||
import 'package:spotube/utils/type_conversion_utils.dart';
|
import 'package:spotube/utils/type_conversion_utils.dart';
|
||||||
@ -33,6 +34,7 @@ class PlayerActions extends HookConsumerWidget {
|
|||||||
final isInQueue =
|
final isInQueue =
|
||||||
downloader.inQueue.any((element) => element.id == playback.track?.id);
|
downloader.inQueue.any((element) => element.id == playback.track?.id);
|
||||||
final localTracks = ref.watch(localTracksProvider).value;
|
final localTracks = ref.watch(localTracksProvider).value;
|
||||||
|
final auth = ref.watch(authProvider);
|
||||||
|
|
||||||
final isDownloaded = useMemoized(() {
|
final isDownloaded = useMemoized(() {
|
||||||
return localTracks?.any(
|
return localTracks?.any(
|
||||||
@ -122,7 +124,7 @@ class PlayerActions extends HookConsumerWidget {
|
|||||||
? () => downloader.addToQueue(playback.track!)
|
? () => downloader.addToQueue(playback.track!)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
if (playback.track != null && !isLocalTrack)
|
if (playback.track != null && !isLocalTrack && auth.isLoggedIn)
|
||||||
TrackHeartButton(track: playback.track!),
|
TrackHeartButton(track: playback.track!),
|
||||||
...(extraActions ?? [])
|
...(extraActions ?? [])
|
||||||
],
|
],
|
||||||
|
@ -7,6 +7,7 @@ import 'package:spotube/components/shared/shimmers/shimmer_track_tile.dart';
|
|||||||
import 'package:spotube/components/shared/page_window_title_bar.dart';
|
import 'package:spotube/components/shared/page_window_title_bar.dart';
|
||||||
import 'package:spotube/components/shared/image/universal_image.dart';
|
import 'package:spotube/components/shared/image/universal_image.dart';
|
||||||
import 'package:spotube/components/shared/track_table/tracks_table_view.dart';
|
import 'package:spotube/components/shared/track_table/tracks_table_view.dart';
|
||||||
|
import 'package:spotube/provider/auth_provider.dart';
|
||||||
import 'package:spotube/utils/type_conversion_utils.dart';
|
import 'package:spotube/utils/type_conversion_utils.dart';
|
||||||
import 'package:spotube/hooks/use_custom_status_bar_color.dart';
|
import 'package:spotube/hooks/use_custom_status_bar_color.dart';
|
||||||
import 'package:spotube/hooks/use_palette_color.dart';
|
import 'package:spotube/hooks/use_palette_color.dart';
|
||||||
@ -55,6 +56,7 @@ class TrackCollectionView<T> extends HookConsumerWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, ref) {
|
Widget build(BuildContext context, ref) {
|
||||||
|
final auth = ref.watch(authProvider);
|
||||||
final color = usePaletteGenerator(
|
final color = usePaletteGenerator(
|
||||||
context,
|
context,
|
||||||
titleImage,
|
titleImage,
|
||||||
@ -69,7 +71,7 @@ class TrackCollectionView<T> extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
onPressed: onShare,
|
onPressed: onShare,
|
||||||
),
|
),
|
||||||
if (heartBtn != null) heartBtn!,
|
if (heartBtn != null && auth.isLoggedIn) heartBtn!,
|
||||||
PlatformIconButton(
|
PlatformIconButton(
|
||||||
tooltip: "Shuffle",
|
tooltip: "Shuffle",
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
|
@ -16,6 +16,7 @@ import 'package:spotube/hooks/use_breakpoint_value.dart';
|
|||||||
import 'package:spotube/hooks/use_breakpoints.dart';
|
import 'package:spotube/hooks/use_breakpoints.dart';
|
||||||
import 'package:spotube/models/current_playlist.dart';
|
import 'package:spotube/models/current_playlist.dart';
|
||||||
import 'package:spotube/models/logger.dart';
|
import 'package:spotube/models/logger.dart';
|
||||||
|
import 'package:spotube/provider/auth_provider.dart';
|
||||||
import 'package:spotube/provider/playback_provider.dart';
|
import 'package:spotube/provider/playback_provider.dart';
|
||||||
import 'package:spotube/provider/spotify_provider.dart';
|
import 'package:spotube/provider/spotify_provider.dart';
|
||||||
import 'package:spotube/services/queries/queries.dart';
|
import 'package:spotube/services/queries/queries.dart';
|
||||||
@ -53,6 +54,8 @@ class ArtistPage extends HookConsumerWidget {
|
|||||||
|
|
||||||
final Playback playback = ref.watch(playbackProvider);
|
final Playback playback = ref.watch(playbackProvider);
|
||||||
|
|
||||||
|
final auth = ref.watch(authProvider);
|
||||||
|
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
child: PlatformScaffold(
|
child: PlatformScaffold(
|
||||||
appBar: PageWindowTitleBar(
|
appBar: PageWindowTitleBar(
|
||||||
@ -128,64 +131,66 @@ class ArtistPage extends HookConsumerWidget {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
HookBuilder(
|
if (auth.isLoggedIn)
|
||||||
builder: (context) {
|
HookBuilder(
|
||||||
final isFollowingQuery = useQuery(
|
builder: (context) {
|
||||||
job: Queries.artist.doIFollow(artistId),
|
final isFollowingQuery = useQuery(
|
||||||
externalData: spotify,
|
job: Queries.artist.doIFollow(artistId),
|
||||||
);
|
externalData: spotify,
|
||||||
|
|
||||||
if (isFollowingQuery.isLoading ||
|
|
||||||
!isFollowingQuery.hasData) {
|
|
||||||
return const SizedBox(
|
|
||||||
height: 20,
|
|
||||||
width: 20,
|
|
||||||
child:
|
|
||||||
PlatformCircularProgressIndicator(),
|
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
return PlatformFilledButton(
|
if (isFollowingQuery.isLoading ||
|
||||||
onPressed: () async {
|
!isFollowingQuery.hasData) {
|
||||||
try {
|
return const SizedBox(
|
||||||
isFollowingQuery.data!
|
height: 20,
|
||||||
? await spotify.me.unfollow(
|
width: 20,
|
||||||
FollowingType.artist,
|
child:
|
||||||
[artistId],
|
PlatformCircularProgressIndicator(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return PlatformFilledButton(
|
||||||
|
onPressed: () async {
|
||||||
|
try {
|
||||||
|
isFollowingQuery.data!
|
||||||
|
? await spotify.me.unfollow(
|
||||||
|
FollowingType.artist,
|
||||||
|
[artistId],
|
||||||
|
)
|
||||||
|
: await spotify.me.follow(
|
||||||
|
FollowingType.artist,
|
||||||
|
[artistId],
|
||||||
|
);
|
||||||
|
await isFollowingQuery.refetch();
|
||||||
|
QueryBowl.of(context)
|
||||||
|
.getInfiniteQuery(
|
||||||
|
Queries.artist.followedByMe
|
||||||
|
.queryKey,
|
||||||
)
|
)
|
||||||
: await spotify.me.follow(
|
?.refetch();
|
||||||
FollowingType.artist,
|
} catch (e, stack) {
|
||||||
[artistId],
|
logger.e(
|
||||||
);
|
"FollowButton.onPressed",
|
||||||
await isFollowingQuery.refetch();
|
e,
|
||||||
QueryBowl.of(context)
|
stack,
|
||||||
.getInfiniteQuery(
|
);
|
||||||
Queries.artist.followedByMe
|
} finally {
|
||||||
.queryKey,
|
QueryBowl.of(context)
|
||||||
)
|
.refetchQueries([
|
||||||
?.refetch();
|
Queries.artist
|
||||||
} catch (e, stack) {
|
.doIFollow(artistId)
|
||||||
logger.e(
|
.queryKey,
|
||||||
"FollowButton.onPressed",
|
]);
|
||||||
e,
|
}
|
||||||
stack,
|
},
|
||||||
);
|
child: PlatformText(
|
||||||
} finally {
|
isFollowingQuery.data!
|
||||||
QueryBowl.of(context).refetchQueries([
|
? "Following"
|
||||||
Queries.artist
|
: "Follow",
|
||||||
.doIFollow(artistId)
|
),
|
||||||
.queryKey,
|
);
|
||||||
]);
|
},
|
||||||
}
|
),
|
||||||
},
|
|
||||||
child: PlatformText(
|
|
||||||
isFollowingQuery.data!
|
|
||||||
? "Following"
|
|
||||||
: "Follow",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
PlatformIconButton(
|
PlatformIconButton(
|
||||||
icon: const Icon(Icons.share_rounded),
|
icon: const Icon(Icons.share_rounded),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
@ -12,7 +12,6 @@ class DesktopLoginPage extends HookConsumerWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, ref) {
|
Widget build(BuildContext context, ref) {
|
||||||
final breakpoint = useBreakpoints();
|
final breakpoint = useBreakpoints();
|
||||||
final textTheme = Theme.of(context).textTheme;
|
|
||||||
|
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
child: PlatformScaffold(
|
child: PlatformScaffold(
|
||||||
@ -36,13 +35,11 @@ class DesktopLoginPage extends HookConsumerWidget {
|
|||||||
width: MediaQuery.of(context).size.width *
|
width: MediaQuery.of(context).size.width *
|
||||||
(breakpoint <= Breakpoints.md ? .5 : .3),
|
(breakpoint <= Breakpoints.md ? .5 : .3),
|
||||||
),
|
),
|
||||||
PlatformText("Add your spotify credentials to get started",
|
PlatformText.subheading(
|
||||||
style: breakpoint <= Breakpoints.md
|
"Add your spotify credentials to get started",
|
||||||
? textTheme.headline5
|
),
|
||||||
: textTheme.headline4),
|
PlatformText.label(
|
||||||
PlatformText(
|
|
||||||
"Don't worry, any of your credentials won't be collected or shared with anyone",
|
"Don't worry, any of your credentials won't be collected or shared with anyone",
|
||||||
style: Theme.of(context).textTheme.caption,
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
TokenLoginForm(
|
TokenLoginForm(
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:introduction_screen/introduction_screen.dart';
|
import 'package:introduction_screen/introduction_screen.dart';
|
||||||
import 'package:platform_ui/platform_ui.dart';
|
import 'package:platform_ui/platform_ui.dart';
|
||||||
import 'package:spotube/components/desktop_login/login_form.dart';
|
import 'package:spotube/components/desktop_login/login_form.dart';
|
||||||
@ -16,6 +17,10 @@ class LoginTutorial extends ConsumerWidget {
|
|||||||
final auth = ref.watch(authProvider);
|
final auth = ref.watch(authProvider);
|
||||||
final key = GlobalKey<State<IntroductionScreen>>();
|
final key = GlobalKey<State<IntroductionScreen>>();
|
||||||
|
|
||||||
|
final pageDecoration = PageDecoration(
|
||||||
|
bodyTextStyle: PlatformTheme.of(context).textTheme!.body!,
|
||||||
|
titleTextStyle: PlatformTheme.of(context).textTheme!.subheading!,
|
||||||
|
);
|
||||||
return PlatformScaffold(
|
return PlatformScaffold(
|
||||||
appBar: PageWindowTitleBar(
|
appBar: PageWindowTitleBar(
|
||||||
hideWhenWindows: false,
|
hideWhenWindows: false,
|
||||||
@ -28,6 +33,8 @@ class LoginTutorial extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
body: IntroductionScreen(
|
body: IntroductionScreen(
|
||||||
key: key,
|
key: key,
|
||||||
|
globalBackgroundColor:
|
||||||
|
PlatformTheme.of(context).scaffoldBackgroundColor,
|
||||||
overrideBack: PlatformFilledButton(
|
overrideBack: PlatformFilledButton(
|
||||||
isSecondary: true,
|
isSecondary: true,
|
||||||
child: const Center(child: PlatformText("Previous")),
|
child: const Center(child: PlatformText("Previous")),
|
||||||
@ -52,6 +59,7 @@ class LoginTutorial extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
pages: [
|
pages: [
|
||||||
PageViewModel(
|
PageViewModel(
|
||||||
|
decoration: pageDecoration,
|
||||||
title: "Step 1",
|
title: "Step 1",
|
||||||
image: Image.asset("assets/tutorial/step-1.png"),
|
image: Image.asset("assets/tutorial/step-1.png"),
|
||||||
bodyWidget: Wrap(
|
bodyWidget: Wrap(
|
||||||
@ -70,6 +78,7 @@ class LoginTutorial extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
PageViewModel(
|
PageViewModel(
|
||||||
|
decoration: pageDecoration,
|
||||||
title: "Step 2",
|
title: "Step 2",
|
||||||
image: Image.asset("assets/tutorial/step-2.png"),
|
image: Image.asset("assets/tutorial/step-2.png"),
|
||||||
bodyWidget: const PlatformText(
|
bodyWidget: const PlatformText(
|
||||||
@ -78,6 +87,7 @@ class LoginTutorial extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
PageViewModel(
|
PageViewModel(
|
||||||
|
decoration: pageDecoration,
|
||||||
title: "Step 3",
|
title: "Step 3",
|
||||||
image: Image.asset(
|
image: Image.asset(
|
||||||
"assets/tutorial/step-3.png",
|
"assets/tutorial/step-3.png",
|
||||||
@ -89,7 +99,7 @@ class LoginTutorial extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
if (auth.isLoggedIn)
|
if (auth.isLoggedIn)
|
||||||
PageViewModel(
|
PageViewModel(
|
||||||
decoration: const PageDecoration(
|
decoration: pageDecoration.copyWith(
|
||||||
bodyAlignment: Alignment.center,
|
bodyAlignment: Alignment.center,
|
||||||
),
|
),
|
||||||
title: "Success🥳",
|
title: "Success🥳",
|
||||||
@ -99,14 +109,19 @@ class LoginTutorial extends ConsumerWidget {
|
|||||||
)
|
)
|
||||||
else
|
else
|
||||||
PageViewModel(
|
PageViewModel(
|
||||||
|
decoration: pageDecoration,
|
||||||
title: "Step 5",
|
title: "Step 5",
|
||||||
bodyWidget: Column(
|
bodyWidget: Column(
|
||||||
children: const [
|
children: [
|
||||||
PlatformText(
|
PlatformText.label(
|
||||||
"Paste the copied \"sp_dc\" and \"sp_key\" values in the respective fields",
|
"Paste the copied \"sp_dc\" and \"sp_key\" values in the respective fields",
|
||||||
),
|
),
|
||||||
SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
TokenLoginForm(),
|
TokenLoginForm(
|
||||||
|
onDone: () {
|
||||||
|
GoRouter.of(context).go("/");
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user