mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix: lyrics page doesn't scroll to top after song ends #885
This commit is contained in:
parent
67ae2e8159
commit
c7d8ed567a
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
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:gap/gap.dart';
|
import 'package:gap/gap.dart';
|
||||||
@ -56,7 +58,11 @@ class SyncedLyrics extends HookConsumerWidget {
|
|||||||
ref.listen(
|
ref.listen(
|
||||||
audioPlayerProvider.select((s) => s.activeTrack),
|
audioPlayerProvider.select((s) => s.activeTrack),
|
||||||
(previous, next) {
|
(previous, next) {
|
||||||
controller.scrollToIndex(0);
|
controller.animateTo(
|
||||||
|
0,
|
||||||
|
duration: const Duration(milliseconds: 500),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
);
|
||||||
ref.read(syncedLyricsDelayProvider.notifier).state = 0;
|
ref.read(syncedLyricsDelayProvider.notifier).state = 0;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -69,6 +75,23 @@ class SyncedLyrics extends HookConsumerWidget {
|
|||||||
final bodyTextTheme = textTheme.bodyLarge?.copyWith(
|
final bodyTextTheme = textTheme.bodyLarge?.copyWith(
|
||||||
color: palette.bodyTextColor,
|
color: palette.bodyTextColor,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() {
|
||||||
|
StreamSubscription? subscription;
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
subscription = audioPlayer.positionStream.listen((event) {
|
||||||
|
if (event > Duration.zero) return;
|
||||||
|
controller.animateTo(
|
||||||
|
0,
|
||||||
|
duration: const Duration(milliseconds: 500),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return subscription?.cancel;
|
||||||
|
}, [controller]);
|
||||||
|
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
CustomScrollView(
|
CustomScrollView(
|
||||||
|
Loading…
Reference in New Issue
Block a user