mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-05-15 05:10:28 +02:00
fix: prevent settings editor white screens
This commit is contained in:
@@ -1645,10 +1645,11 @@ class ExtensionNotifier extends Notifier<ExtensionState> {
|
||||
}
|
||||
|
||||
List<String> getAllDownloadProviders() {
|
||||
return state.extensions
|
||||
.where((ext) => ext.enabled && ext.hasDownloadProvider)
|
||||
.map((ext) => ext.id)
|
||||
.toList(growable: false);
|
||||
return _distinctProviderIds(
|
||||
state.extensions
|
||||
.where((ext) => ext.enabled && ext.hasDownloadProvider)
|
||||
.map((ext) => ext.id),
|
||||
);
|
||||
}
|
||||
|
||||
List<String> getAllMetadataProviders() {
|
||||
@@ -1662,10 +1663,22 @@ class ExtensionNotifier extends Notifier<ExtensionState> {
|
||||
.where((ext) => ext.searchBehavior?.primary != true)
|
||||
.map((ext) => ext.id);
|
||||
|
||||
return [
|
||||
return _distinctProviderIds([
|
||||
...primarySearchMetadataExtensions,
|
||||
...otherMetadataExtensions,
|
||||
];
|
||||
]);
|
||||
}
|
||||
|
||||
List<String> _distinctProviderIds(Iterable<String> ids) {
|
||||
final seen = <String>{};
|
||||
final result = <String>[];
|
||||
for (final id in ids) {
|
||||
final normalized = id.trim();
|
||||
if (normalized.isNotEmpty && seen.add(normalized)) {
|
||||
result.add(normalized);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
List<String> _replaceRetiredBuiltInMetadataProviders(List<String> input) {
|
||||
|
||||
@@ -755,8 +755,8 @@ class _FilesSettingsPageState extends ConsumerState<FilesSettingsPage> {
|
||||
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
useRootNavigator: true,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
backgroundColor: colorScheme.surface,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(28)),
|
||||
@@ -794,7 +794,15 @@ class _FilesSettingsPageState extends ConsumerState<FilesSettingsPage> {
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
description ??
|
||||
context.l10n.downloadFilenameDescription as String,
|
||||
context.l10n.downloadFilenameDescription(
|
||||
'{album}',
|
||||
'{artist}',
|
||||
'{date}',
|
||||
'{disc}',
|
||||
'{title}',
|
||||
'{track}',
|
||||
'{year}',
|
||||
),
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
@@ -924,7 +932,7 @@ class _FilesSettingsPageState extends ConsumerState<FilesSettingsPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
).whenComplete(controller.dispose);
|
||||
}
|
||||
|
||||
void _showAlbumFolderStructurePicker(
|
||||
|
||||
@@ -114,14 +114,13 @@ class _MetadataProviderPriorityPageState
|
||||
await ref
|
||||
.read(extensionProvider.notifier)
|
||||
.setMetadataProviderPriority(_providers);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_hasChanges = false;
|
||||
});
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(context.l10n.snackbarMetadataProviderSaved)),
|
||||
);
|
||||
}
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(context.l10n.snackbarMetadataProviderSaved)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,10 +187,7 @@ class _MetadataProviderItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Icon(
|
||||
info.icon,
|
||||
color: colorScheme.secondary,
|
||||
),
|
||||
Icon(info.icon, color: colorScheme.secondary),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
|
||||
@@ -220,14 +220,13 @@ class _ProviderPriorityPageState extends ConsumerState<ProviderPriorityPage> {
|
||||
|
||||
Future<void> _saveChanges() async {
|
||||
await ref.read(extensionProvider.notifier).setProviderPriority(_providers);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_hasChanges = false;
|
||||
});
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(context.l10n.snackbarProviderPrioritySaved)),
|
||||
);
|
||||
}
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(context.l10n.snackbarProviderPrioritySaved)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,10 +293,7 @@ class _ProviderItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Icon(
|
||||
info.icon,
|
||||
color: colorScheme.secondary,
|
||||
),
|
||||
Icon(info.icon, color: colorScheme.secondary),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
@@ -339,8 +335,5 @@ class _ProviderInfo {
|
||||
final String name;
|
||||
final IconData icon;
|
||||
|
||||
_ProviderInfo({
|
||||
required this.name,
|
||||
required this.icon,
|
||||
});
|
||||
_ProviderInfo({required this.name, required this.icon});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user