feat(flutter/playlists): empty-state hint on empty playlist detail
When a playlist has zero tracks, the detail screen previously showed just the header with no indication of what to do next. Adds an inline hint mirroring the web's copy: "No tracks yet. Add some via the \"Add to playlist…\" entry on any track row." Implementation: itemCount goes from tracks.length + 1 to (tracks.isEmpty ? 2 : tracks.length + 1) and the builder emits the hint at index 1 when tracks is empty. Header still renders at index 0. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,7 @@ class _Body extends ConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final fs = Theme.of(context).extension<FabledSwordTheme>()!;
|
||||
final tracks = detail.tracks;
|
||||
final playable = tracks.where((t) => t.isAvailable).toList();
|
||||
|
||||
@@ -58,9 +59,22 @@ class _Body extends ConsumerWidget {
|
||||
onRefresh: () async =>
|
||||
ref.refresh(playlistDetailProvider(detail.playlist.id).future),
|
||||
child: ListView.builder(
|
||||
itemCount: tracks.length + 1, // header + rows
|
||||
// Header + (track rows | empty hint).
|
||||
itemCount: tracks.isEmpty ? 2 : tracks.length + 1,
|
||||
itemBuilder: (ctx, i) {
|
||||
if (i == 0) return _Header(detail: detail, playable: playable);
|
||||
if (tracks.isEmpty) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'No tracks yet. Add some via the "Add to playlist…" entry on any track row.',
|
||||
style: TextStyle(color: fs.ash),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
final t = tracks[i - 1];
|
||||
return _PlaylistTrackRow(
|
||||
row: t,
|
||||
|
||||
Reference in New Issue
Block a user