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/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.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:spotube/hooks/use_synced_lyrics.dart';
|
||||||
import 'package:scroll_to_index/scroll_to_index.dart';
|
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||||
import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.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/services/queries/queries.dart';
|
||||||
|
|
||||||
import 'package:spotube/utils/type_conversion_utils.dart';
|
import 'package:spotube/utils/type_conversion_utils.dart';
|
||||||
@ -114,9 +116,7 @@ class SyncedLyrics extends HookConsumerWidget {
|
|||||||
? Container(
|
? Container(
|
||||||
padding: index == lyricValue.lyrics.length - 1
|
padding: index == lyricValue.lyrics.length - 1
|
||||||
? EdgeInsets.only(
|
? EdgeInsets.only(
|
||||||
bottom:
|
bottom: mediaQuery.size.height / 2,
|
||||||
MediaQuery.of(context).size.height /
|
|
||||||
2,
|
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
)
|
)
|
||||||
@ -138,11 +138,25 @@ class SyncedLyrics extends HookConsumerWidget {
|
|||||||
: FontWeight.normal,
|
: FontWeight.normal,
|
||||||
fontSize: (isActive ? 28 : 26) *
|
fontSize: (isActive ? 28 : 26) *
|
||||||
(textZoomLevel.value / 100),
|
(textZoomLevel.value / 100),
|
||||||
shadows: kElevationToShadow[9],
|
|
||||||
),
|
),
|
||||||
child: Text(
|
child: InkWell(
|
||||||
lyricSlice.text,
|
onTap: () async {
|
||||||
textAlign: TextAlign.center,
|
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,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user