Untere Navigation folgt jetzt den Referenzbildern: Meine Musik / Online / Suchen / Favoriten. Der bisherige "Download"-Tab heisst "Online" und bekommt als Naechstes den YouTube-Downloader. In "Meine Musik" gibt es Unterreiter (Songs/Kuenstler/Alben) im Pillen-Stil der Referenz. Sie wechseln nur den Inhalt statt einen Bildschirm zu oeffnen; die Schnellzugriff-Kacheln "Kuenstler"/"Alben" entfallen dadurch, ebenso die damit tot gewordenen ArtistsScreen/AlbumsScreen-Huellen. 158 Tests gruen, flutter analyze ohne Befund. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018NLW1q1hzEC9goDQ1dJ98d
70 lines
2.1 KiB
Dart
70 lines
2.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../shared/cover.dart';
|
|
import 'database.dart';
|
|
import 'song_grouping.dart';
|
|
import 'song_list.dart';
|
|
|
|
/// Bibliotheks-Tab: Album-Übersicht, gruppiert aus [MeloDb.watchSongs].
|
|
class AlbumListScreen extends StatelessWidget {
|
|
const AlbumListScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final db = context.read<MeloDb>();
|
|
return StreamBuilder<List<Song>>(
|
|
stream: db.watchSongs(),
|
|
builder: (context, snapshot) {
|
|
final songs = snapshot.data ?? const [];
|
|
if (songs.isEmpty) {
|
|
return const Center(
|
|
child: Text('Keine Alben', style: TextStyle(color: Colors.white54)),
|
|
);
|
|
}
|
|
final grouped = groupByAlbum(songs);
|
|
final albums = grouped.keys.toList();
|
|
return ListView.builder(
|
|
itemCount: albums.length,
|
|
itemBuilder: (context, i) {
|
|
final album = albums[i];
|
|
final albumSongs = grouped[album]!;
|
|
final coverPath = albumSongs.first.coverPath;
|
|
return ListTile(
|
|
leading: CoverImage(
|
|
artUri: coverPath != null ? Uri.file(coverPath) : null,
|
|
size: 48,
|
|
radius: 6,
|
|
),
|
|
title: Text(album, maxLines: 1, overflow: TextOverflow.ellipsis),
|
|
subtitle: Text('${albumArtistLabel(albumSongs)} · ${albumSongs.length} Songs',
|
|
maxLines: 1, overflow: TextOverflow.ellipsis),
|
|
onTap: () => Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (_) => _AlbumSongsScreen(album: album, songs: albumSongs),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Zeigt alle Songs eines Albums.
|
|
class _AlbumSongsScreen extends StatelessWidget {
|
|
const _AlbumSongsScreen({required this.album, required this.songs});
|
|
final String album;
|
|
final List<Song> songs;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: Text(album)),
|
|
body: SongList(songs),
|
|
);
|
|
}
|
|
}
|