mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
feat: jump to specific time on lyric click (#590)
This commit is contained in:
parent
48e90a4229
commit
a14fb9ec38
@ -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,8 +138,21 @@ class SyncedLyrics extends HookConsumerWidget {
|
||||
: FontWeight.normal,
|
||||
fontSize: (isActive ? 28 : 26) *
|
||||
(textZoomLevel.value / 100),
|
||||
shadows: kElevationToShadow[9],
|
||||
),
|
||||
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,
|
||||
@ -147,6 +160,7 @@ class SyncedLyrics extends HookConsumerWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user