feat(library): add Artist and Album browsing tabs
- Library screen now has a TabBar (Alle / Künstler / Alben) inside a
DefaultTabController; scan/permission/error banners stay above the
TabBarView so they remain visible regardless of the active sub-tab
- New lib/library/song_grouping.dart: pure, unit-tested functions
groupByArtist/groupByAlbum (null artist/album -> "Unbekannt" /
"Unbekanntes Album", alphabetically sorted) plus albumArtistLabel
("Verschiedene Interpreten" when an album mixes artists)
- New lib/library/artist_list.dart + album_list.dart: StreamBuilder on
MeloDb.watchSongs(), grouped client-side, tapping a row pushes a
SongList screen for that artist/album; album rows show a CoverImage
thumbnail from the first song's coverPath
- Existing "Alle" tab content (recently-added strip, full song list,
empty state) preserved unchanged, moved into _AllSongsTab
Genre browsing is intentionally out of scope: the Songs table has no
genre column and neither scanner extracts genre metadata — needs a
schema migration + scanner work in a future task.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 4.5
parent
4477370766
commit
58ceb42769
@@ -0,0 +1,69 @@
|
||||
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),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user