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