mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-14 16:25:16 +00:00
fix: check for unsynced lyrics and error handling for timed lyrics query
This commit is contained in:
parent
574406dd5f
commit
1d77556157
@ -45,6 +45,11 @@ class SyncedLyrics extends HookConsumerWidget {
|
|||||||
|
|
||||||
final lyricValue = timedLyricsQuery.data;
|
final lyricValue = timedLyricsQuery.data;
|
||||||
|
|
||||||
|
final isUnSyncLyric = useMemoized(
|
||||||
|
() => lyricValue?.lyrics.every((l) => l.time == Duration.zero),
|
||||||
|
[lyricValue],
|
||||||
|
);
|
||||||
|
|
||||||
final lyricsMap = useMemoized(
|
final lyricsMap = useMemoized(
|
||||||
() =>
|
() =>
|
||||||
lyricValue?.lyrics
|
lyricValue?.lyrics
|
||||||
@ -72,6 +77,9 @@ class SyncedLyrics extends HookConsumerWidget {
|
|||||||
: textTheme.headlineMedium?.copyWith(fontSize: 25))
|
: textTheme.headlineMedium?.copyWith(fontSize: 25))
|
||||||
?.copyWith(color: palette.titleTextColor);
|
?.copyWith(color: palette.titleTextColor);
|
||||||
|
|
||||||
|
var bodyTextTheme = textTheme.bodyLarge?.copyWith(
|
||||||
|
color: palette.bodyTextColor,
|
||||||
|
);
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
@ -93,7 +101,9 @@ class SyncedLyrics extends HookConsumerWidget {
|
|||||||
: textTheme.titleLarge,
|
: textTheme.titleLarge,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (lyricValue != null && lyricValue.lyrics.isNotEmpty)
|
if (lyricValue != null &&
|
||||||
|
lyricValue.lyrics.isNotEmpty &&
|
||||||
|
isUnSyncLyric == false)
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
@ -102,7 +112,7 @@ class SyncedLyrics extends HookConsumerWidget {
|
|||||||
final lyricSlice = lyricValue.lyrics[index];
|
final lyricSlice = lyricValue.lyrics[index];
|
||||||
final isActive = lyricSlice.time.inSeconds == currentTime;
|
final isActive = lyricSlice.time.inSeconds == currentTime;
|
||||||
|
|
||||||
if (isActive) {
|
if (isActive && isUnSyncLyric == true) {
|
||||||
controller.scrollToIndex(
|
controller.scrollToIndex(
|
||||||
index,
|
index,
|
||||||
preferPosition: AutoScrollPosition.middle,
|
preferPosition: AutoScrollPosition.middle,
|
||||||
@ -173,8 +183,39 @@ class SyncedLyrics extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (playlist.activeTrack != null &&
|
if (playlist.activeTrack != null &&
|
||||||
(lyricValue == null || lyricValue.lyrics.isEmpty == true))
|
(timedLyricsQuery.isLoading || timedLyricsQuery.isRefreshing))
|
||||||
const Expanded(child: ShimmerLyrics()),
|
const Expanded(child: ShimmerLyrics())
|
||||||
|
else if (playlist.activeTrack != null &&
|
||||||
|
(timedLyricsQuery.hasError))
|
||||||
|
Text(
|
||||||
|
"Sorry, no Lyrics were found for `${playlist.activeTrack?.name}` :'(\n${timedLyricsQuery.error.toString()}",
|
||||||
|
style: bodyTextTheme,
|
||||||
|
)
|
||||||
|
else if (isUnSyncLyric == true)
|
||||||
|
Expanded(
|
||||||
|
child: Center(
|
||||||
|
child: RichText(
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
text: TextSpan(
|
||||||
|
style: bodyTextTheme,
|
||||||
|
children: [
|
||||||
|
const TextSpan(
|
||||||
|
text:
|
||||||
|
"Synced lyrics is not available for this song. Please use the",
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: " Plain Lyrics ",
|
||||||
|
style: textTheme.bodyLarge?.copyWith(
|
||||||
|
color: palette.bodyTextColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const TextSpan(text: "tab instead."),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Align(
|
Align(
|
||||||
|
Loading…
Reference in New Issue
Block a user