🐛 Bug fixes and optimization

This commit is contained in:
LittleSheep 2024-08-29 22:39:54 +08:00
parent 586f47575c
commit 3ca01ef147
2 changed files with 35 additions and 7 deletions

View File

@ -3,6 +3,7 @@ import 'package:get/get.dart';
import 'package:rhythm_box/providers/auth.dart';
import 'package:rhythm_box/widgets/no_login_fallback.dart';
import 'package:rhythm_box/widgets/playlist/user_playlist_list.dart';
import 'package:rhythm_box/widgets/sized_container.dart';
class LibraryScreen extends StatefulWidget {
const LibraryScreen({super.key});
@ -18,16 +19,22 @@ class _LibraryScreenState extends State<LibraryScreen> {
Widget build(BuildContext context) {
return Material(
color: Theme.of(context).colorScheme.surface,
child: SafeArea(
child: Obx(() {
child: Scaffold(
appBar: AppBar(
title: const Text('Library'),
centerTitle: MediaQuery.of(context).size.width >= 720,
),
body: Obx(() {
if (_authenticate.auth.value == null) {
return const NoLoginFallback();
}
return const Column(
return const CenteredContainer(
child: Column(
children: [
Expanded(child: UserPlaylistList()),
],
),
);
}),
),

View File

@ -48,10 +48,31 @@ class _SyncedLyricsState extends State<SyncedLyrics> {
Color get _unFocusColor =>
Theme.of(context).colorScheme.onSurface.withOpacity(0.5);
void _syncLyricsProgress() {
for (var idx = 0; idx < _lyric!.lyrics.length; idx++) {
final lyricSlice = _lyric!.lyrics[idx];
final lyricNextSlice =
idx + 1 < _lyric!.lyrics.length ? _lyric!.lyrics[idx + 1] : null;
final isActive = _playback.durationCurrent.value.inSeconds >=
lyricSlice.time.inSeconds &&
(lyricNextSlice == null ||
lyricNextSlice.time.inSeconds >
_playback.durationCurrent.value.inSeconds);
if (isActive) {
_autoScrollController.scrollToIndex(
idx,
preferPosition: AutoScrollPosition.middle,
);
}
}
}
@override
void initState() {
super.initState();
_pullLyrics();
_pullLyrics().then((_) {
_syncLyricsProgress();
});
_subscriptions = [
_playback.state.listen((value) {
if (value.activeTrack == null) return;