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,61 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'database.dart';
|
||||
import 'song_grouping.dart';
|
||||
import 'song_list.dart';
|
||||
|
||||
/// Bibliotheks-Tab: Künstler-Übersicht, gruppiert aus [MeloDb.watchSongs].
|
||||
class ArtistListScreen extends StatelessWidget {
|
||||
const ArtistListScreen({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 Künstler', style: TextStyle(color: Colors.white54)),
|
||||
);
|
||||
}
|
||||
final grouped = groupByArtist(songs);
|
||||
final artists = grouped.keys.toList();
|
||||
return ListView.builder(
|
||||
itemCount: artists.length,
|
||||
itemBuilder: (context, i) {
|
||||
final artist = artists[i];
|
||||
final artistSongs = grouped[artist]!;
|
||||
return ListTile(
|
||||
title: Text(artist, maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||
subtitle: Text('${artistSongs.length} Songs'),
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => _ArtistSongsScreen(artist: artist, songs: artistSongs),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Zeigt alle Songs eines Künstlers.
|
||||
class _ArtistSongsScreen extends StatelessWidget {
|
||||
const _ArtistSongsScreen({required this.artist, required this.songs});
|
||||
final String artist;
|
||||
final List<Song> songs;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(artist)),
|
||||
body: SongList(songs),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user