feat(playlists): Playlist-Detailansicht mit Drag&Drop-Umsortieren
PlaylistDetailScreen zeigt die Songs einer Playlist (watchPlaylistSongs), erlaubt Entfernen einzelner Songs und Umsortieren per Drag & Drop (ReorderableListView.builder). Tippen auf einen Song spielt die Playlist ab dieser Stelle. Leer-Zustand mit Hinweistext. Da bestehende position-Werte nach Einfügereihenfolge lückenhaft sein können, schreibt das Umsortieren nicht nur den verschobenen Song um, sondern vergibt für die gesamte Playlist neue lückenlose Positionen (0..N-1): MeloDb.reorderAllPlaylistSongs (in einer Transaktion) + PlaylistService.reorderAll als dünner Wrapper. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 4.5
parent
4b5d77c196
commit
96d9f38a64
@@ -39,4 +39,26 @@ void main() {
|
||||
expect(await db.watchIsFavorite('song-1').first, true);
|
||||
expect(notified, true);
|
||||
});
|
||||
|
||||
test('reorderAll schreibt lückenlose Positionen 0..N-1 in neuer Reihenfolge', () async {
|
||||
final playlistId = await db.createPlaylist('Mix');
|
||||
for (final id in ['song-1', 'song-2', 'song-3']) {
|
||||
await db.into(db.songs).insert(SongsCompanion.insert(
|
||||
id: id, path: '/$id.mp3', title: id, dateAddedMs: 0, updatedAtMs: 0,
|
||||
));
|
||||
}
|
||||
// Ursprüngliche (evtl. lückenhafte) Positionen.
|
||||
await db.addSongToPlaylist(playlistId, 'song-1', 0);
|
||||
await db.addSongToPlaylist(playlistId, 'song-2', 5);
|
||||
await db.addSongToPlaylist(playlistId, 'song-3', 9);
|
||||
|
||||
var notified = false;
|
||||
service.addListener(() => notified = true);
|
||||
|
||||
await service.reorderAll(playlistId, ['song-3', 'song-1', 'song-2']);
|
||||
|
||||
final songs = await db.watchPlaylistSongs(playlistId).first;
|
||||
expect(songs.map((s) => s.id).toList(), ['song-3', 'song-1', 'song-2']);
|
||||
expect(notified, true);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user