🐛 Bug fixes and optimization
This commit is contained in:
parent
586f47575c
commit
3ca01ef147
@ -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()),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user