mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-30 15:58:51 +02:00
feat(downloads): support up to 3 concurrent downloads
The Dart queue loop was already built around an activeDownloads map and per-item progress tracking but was gated to one download at a time. Add a concurrentDownloads setting (1-3, default 1) exposed in Download Settings > Performance, and let the scheduler keep up to that many items in flight. The experimental Android native worker is still strictly sequential, so it is skipped in favor of the Dart queue while concurrency is enabled.
This commit is contained in:
@@ -195,6 +195,20 @@ class _DownloadSettingsPageState extends ConsumerState<DownloadSettingsPage> {
|
||||
settings.downloadNetworkMode,
|
||||
),
|
||||
),
|
||||
SettingsItem(
|
||||
icon: Icons.dynamic_feed_outlined,
|
||||
title: context.l10n.settingsConcurrentDownloads,
|
||||
subtitle: settings.concurrentDownloads <= 1
|
||||
? context.l10n.concurrentDownloadsOne
|
||||
: context.l10n.concurrentDownloadsCount(
|
||||
settings.concurrentDownloads,
|
||||
),
|
||||
onTap: () => _showConcurrentDownloadsPicker(
|
||||
context,
|
||||
ref,
|
||||
settings.concurrentDownloads,
|
||||
),
|
||||
),
|
||||
if (Platform.isAndroid)
|
||||
SettingsSwitchItem(
|
||||
icon: Icons.downloading_outlined,
|
||||
@@ -598,6 +612,73 @@ class _DownloadSettingsPageState extends ConsumerState<DownloadSettingsPage> {
|
||||
);
|
||||
}
|
||||
|
||||
void _showConcurrentDownloadsPicker(
|
||||
BuildContext context,
|
||||
WidgetRef ref,
|
||||
int current,
|
||||
) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
useRootNavigator: true,
|
||||
backgroundColor: colorScheme.surfaceContainerHigh,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(28)),
|
||||
),
|
||||
builder: (context) => SafeArea(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(24, 24, 24, 8),
|
||||
child: Text(
|
||||
context.l10n.settingsConcurrentDownloads,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(24, 0, 24, 16),
|
||||
child: Text(
|
||||
context.l10n.settingsConcurrentDownloadsSubtitle,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
for (final count in const [1, 2, 3])
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
count == 1
|
||||
? Icons.looks_one_outlined
|
||||
: count == 2
|
||||
? Icons.looks_two_outlined
|
||||
: Icons.looks_3_outlined,
|
||||
),
|
||||
title: Text(
|
||||
count == 1
|
||||
? context.l10n.concurrentDownloadsOne
|
||||
: context.l10n.concurrentDownloadsCount(count),
|
||||
),
|
||||
trailing: current == count
|
||||
? Icon(Icons.check, color: colorScheme.primary)
|
||||
: null,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(settingsProvider.notifier)
|
||||
.setConcurrentDownloads(count);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showSongLinkRegionPicker(
|
||||
BuildContext context,
|
||||
WidgetRef ref,
|
||||
|
||||
Reference in New Issue
Block a user