💄 Better queue view

This commit is contained in:
2025-12-18 00:25:39 +08:00
parent e4797fa2f9
commit 771c1778b4
2 changed files with 53 additions and 47 deletions

View File

@@ -1172,6 +1172,7 @@ class _QueueView extends HookConsumerWidget {
return ReorderableListView.builder( return ReorderableListView.builder(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
itemCount: playlist.medias.length, itemCount: playlist.medias.length,
buildDefaultDragHandles: false,
onReorder: (oldIndex, newIndex) { onReorder: (oldIndex, newIndex) {
if (oldIndex < newIndex) { if (oldIndex < newIndex) {
newIndex -= 1; newIndex -= 1;
@@ -1201,6 +1202,10 @@ class _QueueView extends HookConsumerWidget {
), ),
onDismissed: (direction) => player.remove(index), onDismissed: (direction) => player.remove(index),
child: TrackTile( child: TrackTile(
leading: Text(
(index + 1).toString().padLeft(2, '0'),
style: TextStyle(fontSize: 14),
).padding(right: 8),
track: db.Track( track: db.Track(
id: -1, id: -1,
path: trackPath, path: trackPath,
@@ -1220,54 +1225,56 @@ class _QueueView extends HookConsumerWidget {
padding: const EdgeInsets.symmetric(horizontal: 16), padding: const EdgeInsets.symmetric(horizontal: 16),
), ),
), ),
data: (track) => Dismissible( data: (track) =>
key: Key('queue_item_$index'), ReorderableDelayedDragStartListener(
direction: DismissDirection.endToStart, index: index,
background: Container( child: Dismissible(
color: Colors.red, key: Key('queue_item_$index'),
alignment: Alignment.centerRight, direction: DismissDirection.endToStart,
padding: const EdgeInsets.only(right: 20), background: Container(
child: const Icon(Icons.delete, color: Colors.white), color: Colors.red,
), alignment: Alignment.centerRight,
onDismissed: (direction) => player.remove(index), padding: const EdgeInsets.only(right: 20),
child: TrackTile( child: const Icon(
leading: Row( Icons.delete,
children: [ color: Colors.white,
Icon( ),
Icons.drag_handle,
size: 20,
color: Theme.of(
context,
).colorScheme.onSurface.withValues(alpha: 0.5),
), ),
const SizedBox(width: 8), onDismissed: (direction) => player.remove(index),
Text( child: TrackTile(
(index + 1).toString().padLeft(2, '0'), leading: Text(
style: TextStyle(fontSize: 14), (index + 1).toString().padLeft(2, '0'),
style: TextStyle(fontSize: 14),
).padding(right: 8),
track:
track ??
db.Track(
id: -1,
path: trackPath,
title: Uri.parse(
media.uri,
).pathSegments.last,
artist:
media.extras?['artist'] as String? ??
'Unknown Artist',
album: media.extras?['album'] as String?,
duration: null,
artUri: null,
lyrics: null,
lyricsOffset: 0,
addedAt: DateTime.now(),
),
isPlaying: isCurrent,
onTap: () => player.jump(index),
padding: const EdgeInsets.symmetric(
horizontal: 16,
),
), ),
], ),
).padding(right: 4), ).clipRRect(
track: all: 8,
track ?? key: Key('queue_item_error_${index}_rect'),
db.Track( ),
id: -1,
path: trackPath,
title: Uri.parse(media.uri).pathSegments.last,
artist:
media.extras?['artist'] as String? ??
'Unknown Artist',
album: media.extras?['album'] as String?,
duration: null,
artUri: null,
lyrics: null,
lyricsOffset: 0,
addedAt: DateTime.now(),
),
isPlaying: isCurrent,
onTap: () => player.jump(index),
padding: const EdgeInsets.symmetric(horizontal: 16),
),
),
); );
}, },
); );

View File

@@ -34,7 +34,6 @@ class TrackTile extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
margin: const EdgeInsets.only(bottom: 8),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isPlaying color: isPlaying
? Theme.of(context).colorScheme.primary.withOpacity(0.2) ? Theme.of(context).colorScheme.primary.withOpacity(0.2)