From 3a9d1395db8cf0bc67cc549db35244c4f2bfcb78 Mon Sep 17 00:00:00 2001 From: zarzet Date: Sat, 31 Jan 2026 13:20:14 +0700 Subject: [PATCH] feat(ui): add Clear All button to download queue header (#96) --- CHANGELOG.md | 4 ++++ lib/screens/queue_tab.dart | 49 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3734a0b..a86e09b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ ### Added +- **Clear All Queue Button**: Added "Clear All" button next to Pause/Resume in the Downloading section header ([#96](https://github.com/zarzet/SpotiFLAC-Mobile/issues/96)) + - Quickly cancel all queued downloads with one tap + - Confirmation dialog prevents accidental clears + - Useful when downloading large playlists - **IDHS Fallback**: Added I Don't Have Spotify (IDHS) as fallback link resolver when SongLink fails - Automatically tries IDHS when SongLink returns errors or rate limits - Supports both Spotify→other platforms and Deezer→other platforms lookups diff --git a/lib/screens/queue_tab.dart b/lib/screens/queue_tab.dart index 6132d45..d093fa5 100644 --- a/lib/screens/queue_tab.dart +++ b/lib/screens/queue_tab.dart @@ -793,6 +793,8 @@ final queueItems = ref.watch(downloadQueueProvider.select((s) => s.items)); ), const Spacer(), _buildPauseResumeButton(context, ref, colorScheme), + const SizedBox(width: 4), + _buildClearAllButton(context, ref, colorScheme), ], ), ), @@ -1177,6 +1179,53 @@ if (queueItems.isEmpty && ); } + Widget _buildClearAllButton( + BuildContext context, + WidgetRef ref, + ColorScheme colorScheme, + ) { + return TextButton.icon( + onPressed: () => _showClearAllDialog(context, ref, colorScheme), + icon: const Icon(Icons.clear_all, size: 18), + label: Text(context.l10n.queueClearAll), + style: TextButton.styleFrom( + visualDensity: VisualDensity.compact, + foregroundColor: colorScheme.error, + ), + ); + } + + Future _showClearAllDialog( + BuildContext context, + WidgetRef ref, + ColorScheme colorScheme, + ) async { + final confirmed = await showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text(context.l10n.queueClearAll), + content: Text(context.l10n.queueClearAllMessage), + actions: [ + TextButton( + onPressed: () => Navigator.pop(ctx, false), + child: Text(context.l10n.dialogCancel), + ), + FilledButton( + onPressed: () => Navigator.pop(ctx, true), + style: FilledButton.styleFrom( + backgroundColor: colorScheme.error, + ), + child: Text(context.l10n.dialogClear), + ), + ], + ), + ); + + if (confirmed == true && context.mounted) { + ref.read(downloadQueueProvider.notifier).clearAll(); + } + } + Widget _buildEmptyState( BuildContext context, ColorScheme colorScheme,