feat: jump to specific time on lyric click (#590)

This commit is contained in:
Kingkor Roy Tirtho 2023-08-26 12:38:29 +06:00
parent 48e90a4229
commit a14fb9ec38

View File

@ -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';
@ -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';
@ -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,
)
@ -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,
),
),
),
),