Skip to content

Commit

Permalink
feat: jump to specific time on lyric click (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Aug 26, 2023
1 parent 48e90a4 commit a14fb9e
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions lib/pages/lyrics/synced_lyrics.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
Expand All @@ -11,6 +12,7 @@ import 'package:spotube/hooks/use_auto_scroll_controller.dart';
import 'package:spotube/hooks/use_synced_lyrics.dart';
import 'package:scroll_to_index/scroll_to_index.dart';
import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart';
import 'package:spotube/services/audio_player/audio_player.dart';
import 'package:spotube/services/queries/queries.dart';

import 'package:spotube/utils/type_conversion_utils.dart';
Expand Down Expand Up @@ -114,9 +116,7 @@ class SyncedLyrics extends HookConsumerWidget {
? Container(
padding: index == lyricValue.lyrics.length - 1
? EdgeInsets.only(
bottom:
MediaQuery.of(context).size.height /
2,
bottom: mediaQuery.size.height / 2,
)
: null,
)
Expand All @@ -138,11 +138,25 @@ class SyncedLyrics extends HookConsumerWidget {
: FontWeight.normal,
fontSize: (isActive ? 28 : 26) *
(textZoomLevel.value / 100),
shadows: kElevationToShadow[9],
),
child: Text(
lyricSlice.text,
textAlign: TextAlign.center,
child: InkWell(
onTap: () async {
final duration =
await audioPlayer.duration ??
Duration.zero;
final time = Duration(
seconds:
lyricSlice.time.inSeconds - delay,
);
if (time > duration || time.isNegative) {
return;
}
audioPlayer.seek(time);
},
child: Text(
lyricSlice.text,
textAlign: TextAlign.center,
),
),
),
),
Expand Down

0 comments on commit a14fb9e

Please sign in to comment.