From 771c1778b4f95275f727efdc122473a0c87d08e5 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 18 Dec 2025 00:25:39 +0800 Subject: [PATCH] :lipstick: Better queue view --- lib/ui/screens/player_screen.dart | 99 +++++++++++++++++-------------- lib/ui/widgets/track_tile.dart | 1 - 2 files changed, 53 insertions(+), 47 deletions(-) diff --git a/lib/ui/screens/player_screen.dart b/lib/ui/screens/player_screen.dart index 6109669..89246f1 100644 --- a/lib/ui/screens/player_screen.dart +++ b/lib/ui/screens/player_screen.dart @@ -1172,6 +1172,7 @@ class _QueueView extends HookConsumerWidget { return ReorderableListView.builder( padding: const EdgeInsets.all(16), itemCount: playlist.medias.length, + buildDefaultDragHandles: false, onReorder: (oldIndex, newIndex) { if (oldIndex < newIndex) { newIndex -= 1; @@ -1201,6 +1202,10 @@ class _QueueView extends HookConsumerWidget { ), onDismissed: (direction) => player.remove(index), child: TrackTile( + leading: Text( + (index + 1).toString().padLeft(2, '0'), + style: TextStyle(fontSize: 14), + ).padding(right: 8), track: db.Track( id: -1, path: trackPath, @@ -1220,54 +1225,56 @@ class _QueueView extends HookConsumerWidget { padding: const EdgeInsets.symmetric(horizontal: 16), ), ), - data: (track) => Dismissible( - key: Key('queue_item_$index'), - direction: DismissDirection.endToStart, - background: Container( - color: Colors.red, - alignment: Alignment.centerRight, - padding: const EdgeInsets.only(right: 20), - child: const Icon(Icons.delete, color: Colors.white), - ), - onDismissed: (direction) => player.remove(index), - child: TrackTile( - leading: Row( - children: [ - Icon( - Icons.drag_handle, - size: 20, - color: Theme.of( - context, - ).colorScheme.onSurface.withValues(alpha: 0.5), + data: (track) => + ReorderableDelayedDragStartListener( + index: index, + child: Dismissible( + key: Key('queue_item_$index'), + direction: DismissDirection.endToStart, + background: Container( + color: Colors.red, + alignment: Alignment.centerRight, + padding: const EdgeInsets.only(right: 20), + child: const Icon( + Icons.delete, + color: Colors.white, + ), ), - const SizedBox(width: 8), - Text( - (index + 1).toString().padLeft(2, '0'), - style: TextStyle(fontSize: 14), + onDismissed: (direction) => player.remove(index), + child: TrackTile( + leading: Text( + (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), - 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), - ), - ), + ), + ).clipRRect( + all: 8, + key: Key('queue_item_error_${index}_rect'), + ), ); }, ); diff --git a/lib/ui/widgets/track_tile.dart b/lib/ui/widgets/track_tile.dart index 83ef552..7e5ff29 100644 --- a/lib/ui/widgets/track_tile.dart +++ b/lib/ui/widgets/track_tile.dart @@ -34,7 +34,6 @@ class TrackTile extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - margin: const EdgeInsets.only(bottom: 8), decoration: BoxDecoration( color: isPlaying ? Theme.of(context).colorScheme.primary.withOpacity(0.2)