Skip to content

Commit

Permalink
feat(lyrics): tabs for both synced and static lyrics #182
Browse files Browse the repository at this point in the history
refactor: remove code-style warnings
  • Loading branch information
KRTirtho committed Oct 24, 2022
1 parent 0b79a11 commit 6b6907a
Show file tree
Hide file tree
Showing 27 changed files with 308 additions and 619 deletions.
7 changes: 0 additions & 7 deletions lib/components/Album/AlbumView.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:fl_query/fl_query.dart';
import 'package:fl_query_hooks/fl_query_hooks.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand All @@ -12,7 +11,6 @@ import 'package:spotube/hooks/useBreakpoints.dart';
import 'package:spotube/utils/service_utils.dart';
import 'package:spotube/utils/type_conversion_utils.dart';
import 'package:spotube/models/CurrentPlaylist.dart';
import 'package:spotube/provider/Auth.dart';
import 'package:spotube/provider/Playback.dart';
import 'package:spotube/provider/SpotifyDI.dart';
import 'package:spotube/provider/SpotifyRequests.dart';
Expand Down Expand Up @@ -56,16 +54,11 @@ class AlbumView extends HookConsumerWidget {
Playback playback = ref.watch(playbackProvider);

final SpotifyApi spotify = ref.watch(spotifyProvider);
final Auth auth = ref.watch(authProvider);

final tracksSnapshot = useQuery(
job: albumTracksQueryJob(album.id!),
externalData: spotify,
);
final albumSavedSnapshot = useQuery(
job: albumIsSavedForCurrentUserQueryJob(album.id!),
externalData: spotify,
);

final albumArt = useMemoized(
() => TypeConversionUtils.image_X_UrlString(
Expand Down
197 changes: 0 additions & 197 deletions lib/components/Home/Home.dart

This file was deleted.

3 changes: 1 addition & 2 deletions lib/components/Library/UserLocalTracks.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
Expand Down Expand Up @@ -193,7 +192,7 @@ class UserLocalTracks extends HookConsumerWidget {
SortTracksDropdown(
value: sortBy.value,
onChanged: (value) {
if (value != null) sortBy.value = value;
sortBy.value = value;
},
),
const SizedBox(width: 10),
Expand Down
1 change: 0 additions & 1 deletion lib/components/Login/TokenLogin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotube/components/Login/TokenLoginForms.dart';
import 'package:spotube/components/Shared/PageWindowTitleBar.dart';
import 'package:spotube/hooks/useBreakpoints.dart';
import 'package:spotube/utils/service_utils.dart';

class TokenLogin extends HookConsumerWidget {
const TokenLogin({Key? key}) : super(key: key);
Expand Down
114 changes: 114 additions & 0 deletions lib/components/Lyrics/GeniusLyrics.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import 'package:fl_query_hooks/fl_query_hooks.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:palette_generator/palette_generator.dart';
import 'package:spotify/spotify.dart';
import 'package:spotube/components/LoaderShimmers/ShimmerLyrics.dart';
import 'package:spotube/hooks/useBreakpoints.dart';
import 'package:spotube/provider/Playback.dart';
import 'package:spotube/provider/SpotifyRequests.dart';
import 'package:spotube/provider/UserPreferences.dart';
import 'package:spotube/utils/type_conversion_utils.dart';
import 'package:tuple/tuple.dart';

class GeniusLyrics extends HookConsumerWidget {
final PaletteColor palette;
const GeniusLyrics({
required this.palette,
Key? key,
}) : super(key: key);

@override
Widget build(BuildContext context, ref) {
Playback playback = ref.watch(playbackProvider);
final geniusLyricsQuery = useQuery(
job: geniusLyricsQueryJob,
externalData: Tuple2(
playback.track,
ref.watch(userPreferencesProvider).geniusAccessToken,
),
);
final breakpoint = useBreakpoints();
final textTheme = Theme.of(context).textTheme;

useEffect(() {
if (playback.track != null) {
geniusLyricsQuery.setExternalData(Tuple2(
playback.track,
ref.read(userPreferencesProvider).geniusAccessToken,
));
geniusLyricsQuery.refetch();
}
return null;
}, [playback.track]);

return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Center(
child: Text(
playback.track?.name ?? "",
style: breakpoint >= Breakpoints.md
? textTheme.headline3
: textTheme.headline4?.copyWith(
fontSize: 25,
color: palette.titleTextColor,
),
),
),
Center(
child: Text(
TypeConversionUtils.artists_X_String<Artist>(
playback.track?.artists ?? []),
style: (breakpoint >= Breakpoints.md
? textTheme.headline5
: textTheme.headline6)
?.copyWith(color: palette.bodyTextColor),
),
),
Expanded(
child: SingleChildScrollView(
child: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Builder(
builder: (context) {
if (geniusLyricsQuery.isLoading) {
return const ShimmerLyrics();
} else if (geniusLyricsQuery.hasError) {
return Text(
"Sorry, no Lyrics were found for `${playback.track?.name}` :'(\n${geniusLyricsQuery.error.toString()}",
style: textTheme.bodyText1?.copyWith(
color: palette.bodyTextColor,
),
);
}

final lyrics = geniusLyricsQuery.data;

return Text(
lyrics == null && playback.track == null
? "No Track being played currently"
: lyrics ?? "",
style: textTheme.headline6?.copyWith(
color: palette.bodyTextColor,
),
);
},
),
),
),
),
),
const Align(
alignment: Alignment.bottomRight,
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text("Powered by genius.com"),
),
)
],
);
}
}
Loading

0 comments on commit 6b6907a

Please sign in to comment.