mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-10-21 15:02:21 +02:00
refactor(settings): migrate remaining sheet choices
Single-choice sheet rows still built their own checkmark trailing, with inconsistent colours, so only three rows used AppSheetOption.choice. Move the remaining sixteen rows to it, drop the now unused colour plumbing, and remove a duplicate Semantics wrapper that announced selection twice.
This commit is contained in:
1 parent
bfd180909c
commit
6b6db4ca2e
7 files changed
+19
-73
No files matched your search
@@ -486,7 +486,6 @@ class _DownloadSettingsPageState extends ConsumerState<DownloadSettingsPage> {
|
||||
WidgetRef ref,
|
||||
String current,
|
||||
) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
showAppScrollableBottomSheet<void>(
|
||||
context: context,
|
||||
title: context.l10n.settingsDownloadNetwork,
|
||||
@@ -497,14 +496,11 @@ class _DownloadSettingsPageState extends ConsumerState<DownloadSettingsPage> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AppSheetOption(
|
||||
AppSheetOption.choice(
|
||||
leading: const AppIcon(Icons.signal_cellular_alt),
|
||||
title: Text(context.l10n.settingsDownloadNetworkAny),
|
||||
subtitle: Text(context.l10n.downloadNetworkAnySubtitle),
|
||||
selected: current == 'any',
|
||||
trailing: current == 'any'
|
||||
? AppIcon(Icons.check, color: colorScheme.primary)
|
||||
: null,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(settingsProvider.notifier)
|
||||
@@ -512,14 +508,11 @@ class _DownloadSettingsPageState extends ConsumerState<DownloadSettingsPage> {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
AppSheetOption(
|
||||
AppSheetOption.choice(
|
||||
leading: const AppIcon(Icons.wifi),
|
||||
title: Text(context.l10n.settingsDownloadNetworkWifiOnly),
|
||||
subtitle: Text(context.l10n.downloadNetworkWifiOnlySubtitle),
|
||||
selected: current == 'wifi_only',
|
||||
trailing: current == 'wifi_only'
|
||||
? AppIcon(Icons.check, color: colorScheme.primary)
|
||||
: null,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(settingsProvider.notifier)
|
||||
@@ -870,13 +863,10 @@ class _RegionPickerSheetState extends State<_RegionPickerSheet> {
|
||||
final code = matches[index];
|
||||
final isSelected = code == widget.selected;
|
||||
final countryName = widget.countryNameOf(context, code);
|
||||
return AppSheetOption(
|
||||
return AppSheetOption.choice(
|
||||
title: Text(countryName != code ? countryName : code),
|
||||
subtitle: countryName != code ? Text(code) : null,
|
||||
selected: isSelected,
|
||||
trailing: isSelected
|
||||
? AppIcon(Icons.check, color: colorScheme.primary)
|
||||
: null,
|
||||
onTap: () => widget.onSelected(code),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1119,11 +1119,9 @@ class _SettingItemState extends State<_SettingItem> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (final option in widget.setting.options ?? <String>[])
|
||||
AppSheetOption(
|
||||
AppSheetOption.choice(
|
||||
title: Text(option),
|
||||
trailing: option == widget.value
|
||||
? const AppIcon(CupertinoIcons.check_mark)
|
||||
: null,
|
||||
selected: option == widget.value,
|
||||
onTap: () => Navigator.pop(sheetContext, option),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -532,7 +532,7 @@ class _FilesSettingsPageState extends ConsumerState<FilesSettingsPage> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AppSheetOption(
|
||||
AppSheetOption.choice(
|
||||
leading: AppIcon(
|
||||
Icons.folder_special,
|
||||
color: colorScheme.primary,
|
||||
@@ -540,7 +540,6 @@ class _FilesSettingsPageState extends ConsumerState<FilesSettingsPage> {
|
||||
title: Text(context.l10n.storageAutomaticFolder),
|
||||
subtitle: Text(context.l10n.storageAutomaticDownloadFolder),
|
||||
selected: !isSafMode,
|
||||
trailing: !isSafMode ? const AppIcon(Icons.check) : null,
|
||||
onTap: () async {
|
||||
Navigator.pop(ctx);
|
||||
final defaultDir = await _getDefaultAndroidDirectory();
|
||||
@@ -550,12 +549,11 @@ class _FilesSettingsPageState extends ConsumerState<FilesSettingsPage> {
|
||||
notifier.setDownloadTreeUri('');
|
||||
},
|
||||
),
|
||||
AppSheetOption(
|
||||
AppSheetOption.choice(
|
||||
leading: AppIcon(Icons.folder_open, color: colorScheme.primary),
|
||||
title: Text(context.l10n.storageSafRecommended),
|
||||
subtitle: Text(context.l10n.storageDownloadFolderHint),
|
||||
selected: isSafMode,
|
||||
trailing: isSafMode ? const AppIcon(Icons.check) : null,
|
||||
onTap: () async {
|
||||
Navigator.pop(ctx);
|
||||
await _pickSafTreeAndSave();
|
||||
@@ -757,14 +755,11 @@ class _FilesSettingsPageState extends ConsumerState<FilesSettingsPage> {
|
||||
Icons.person_outline_outlined,
|
||||
),
|
||||
])
|
||||
AppSheetOption(
|
||||
AppSheetOption.choice(
|
||||
leading: AppIcon(option.$4),
|
||||
title: Text(option.$2),
|
||||
subtitle: Text(option.$3),
|
||||
selected: current == option.$1,
|
||||
trailing: current == option.$1
|
||||
? const AppIcon(Icons.check)
|
||||
: null,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(settingsProvider.notifier)
|
||||
|
||||
@@ -335,7 +335,6 @@ class _LibrarySettingsPageState extends ConsumerState<LibrarySettingsPage> {
|
||||
}
|
||||
|
||||
void _showAutoScanPicker(BuildContext context, String current) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
showAppScrollableBottomSheet<void>(
|
||||
context: context,
|
||||
title: context.l10n.libraryAutoScan,
|
||||
@@ -350,7 +349,6 @@ class _LibrarySettingsPageState extends ConsumerState<LibrarySettingsPage> {
|
||||
icon: Icons.block,
|
||||
title: context.l10n.libraryAutoScanOff,
|
||||
selected: current == 'off',
|
||||
colorScheme: colorScheme,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(settingsProvider.notifier)
|
||||
@@ -362,7 +360,6 @@ class _LibrarySettingsPageState extends ConsumerState<LibrarySettingsPage> {
|
||||
icon: Icons.open_in_new,
|
||||
title: context.l10n.libraryAutoScanOnOpen,
|
||||
selected: current == 'on_open',
|
||||
colorScheme: colorScheme,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(settingsProvider.notifier)
|
||||
@@ -374,7 +371,6 @@ class _LibrarySettingsPageState extends ConsumerState<LibrarySettingsPage> {
|
||||
icon: Icons.today,
|
||||
title: context.l10n.libraryAutoScanDaily,
|
||||
selected: current == 'daily',
|
||||
colorScheme: colorScheme,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(settingsProvider.notifier)
|
||||
@@ -386,7 +382,6 @@ class _LibrarySettingsPageState extends ConsumerState<LibrarySettingsPage> {
|
||||
icon: Icons.date_range,
|
||||
title: context.l10n.libraryAutoScanWeekly,
|
||||
selected: current == 'weekly',
|
||||
colorScheme: colorScheme,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(settingsProvider.notifier)
|
||||
@@ -419,7 +414,6 @@ class _LibrarySettingsPageState extends ConsumerState<LibrarySettingsPage> {
|
||||
}
|
||||
|
||||
void _showDefaultViewPicker(BuildContext context, String current) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
final options = [
|
||||
('last', Icons.history, context.l10n.libraryDefaultViewLastUsed),
|
||||
('all', Icons.music_note, context.l10n.searchSongs),
|
||||
@@ -442,7 +436,6 @@ class _LibrarySettingsPageState extends ConsumerState<LibrarySettingsPage> {
|
||||
icon: icon,
|
||||
title: label,
|
||||
selected: current == value,
|
||||
colorScheme: colorScheme,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(settingsProvider.notifier)
|
||||
@@ -476,7 +469,6 @@ class _LibrarySettingsPageState extends ConsumerState<LibrarySettingsPage> {
|
||||
}
|
||||
|
||||
void _showQualityLabelModePicker(BuildContext context, String current) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
final options = [
|
||||
(
|
||||
AppSettings.libraryQualityLabelBitrate,
|
||||
@@ -520,7 +512,6 @@ class _LibrarySettingsPageState extends ConsumerState<LibrarySettingsPage> {
|
||||
icon: icon,
|
||||
title: label,
|
||||
selected: current == value,
|
||||
colorScheme: colorScheme,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(settingsProvider.notifier)
|
||||
@@ -1541,26 +1532,21 @@ class _AutoScanOption extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final bool selected;
|
||||
final ColorScheme colorScheme;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const _AutoScanOption({
|
||||
required this.icon,
|
||||
required this.title,
|
||||
required this.selected,
|
||||
required this.colorScheme,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppSheetOption(
|
||||
return AppSheetOption.choice(
|
||||
leading: AppIcon(icon),
|
||||
title: Text(title),
|
||||
selected: selected,
|
||||
trailing: selected
|
||||
? AppIcon(Icons.check, color: colorScheme.primary)
|
||||
: null,
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -240,36 +240,31 @@ class LyricsSettingsPage extends ConsumerWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AppSheetOption(
|
||||
AppSheetOption.choice(
|
||||
leading: const AppIcon(Icons.audiotrack),
|
||||
title: Text(context.l10n.lyricsModeEmbed),
|
||||
subtitle: Text(context.l10n.lyricsModeEmbedSubtitle),
|
||||
selected: current == 'embed',
|
||||
trailing: current == 'embed' ? const AppIcon(Icons.check) : null,
|
||||
onTap: () {
|
||||
ref.read(settingsProvider.notifier).setLyricsMode('embed');
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
AppSheetOption(
|
||||
AppSheetOption.choice(
|
||||
leading: const AppIcon(Icons.insert_drive_file_outlined),
|
||||
title: Text(context.l10n.lyricsModeExternal),
|
||||
subtitle: Text(context.l10n.lyricsModeExternalSubtitle),
|
||||
selected: current == 'external',
|
||||
trailing: current == 'external'
|
||||
? const AppIcon(Icons.check)
|
||||
: null,
|
||||
onTap: () {
|
||||
ref.read(settingsProvider.notifier).setLyricsMode('external');
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
AppSheetOption(
|
||||
AppSheetOption.choice(
|
||||
leading: const AppIcon(Icons.library_music_outlined),
|
||||
title: Text(context.l10n.lyricsModeBoth),
|
||||
subtitle: Text(context.l10n.lyricsModeBothSubtitle),
|
||||
selected: current == 'both',
|
||||
trailing: current == 'both' ? const AppIcon(Icons.check) : null,
|
||||
onTap: () {
|
||||
ref.read(settingsProvider.notifier).setLyricsMode('both');
|
||||
Navigator.pop(context);
|
||||
|
||||
@@ -197,7 +197,7 @@ class MetadataSettingsPage extends ConsumerWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
for (final maxDimension in options)
|
||||
AppSheetOption(
|
||||
AppSheetOption.choice(
|
||||
leading: AppIcon(
|
||||
maxDimension == 0
|
||||
? Icons.image_outlined
|
||||
@@ -205,9 +205,6 @@ class MetadataSettingsPage extends ConsumerWidget {
|
||||
),
|
||||
title: Text(_getEmbeddedCoverSizeLabel(context, maxDimension)),
|
||||
selected: currentMaxDimension == maxDimension,
|
||||
trailing: currentMaxDimension == maxDimension
|
||||
? const AppIcon(Icons.check)
|
||||
: null,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(settingsProvider.notifier)
|
||||
@@ -237,14 +234,11 @@ class MetadataSettingsPage extends ConsumerWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AppSheetOption(
|
||||
AppSheetOption.choice(
|
||||
leading: const AppIcon(Icons.segment_outlined),
|
||||
title: Text(context.l10n.optionsArtistTagModeJoined),
|
||||
subtitle: Text(context.l10n.optionsArtistTagModeJoinedSubtitle),
|
||||
selected: currentMode == artistTagModeJoined,
|
||||
trailing: currentMode == artistTagModeJoined
|
||||
? const AppIcon(Icons.check)
|
||||
: null,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(settingsProvider.notifier)
|
||||
@@ -252,16 +246,13 @@ class MetadataSettingsPage extends ConsumerWidget {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
AppSheetOption(
|
||||
AppSheetOption.choice(
|
||||
leading: const AppIcon(Icons.library_music_outlined),
|
||||
title: Text(context.l10n.optionsArtistTagModeSplitVorbis),
|
||||
subtitle: Text(
|
||||
context.l10n.optionsArtistTagModeSplitVorbisSubtitle,
|
||||
),
|
||||
selected: currentMode == artistTagModeSplitVorbis,
|
||||
trailing: currentMode == artistTagModeSplitVorbis
|
||||
? const AppIcon(Icons.check)
|
||||
: null,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(settingsProvider.notifier)
|
||||
@@ -269,14 +260,11 @@ class MetadataSettingsPage extends ConsumerWidget {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
AppSheetOption(
|
||||
AppSheetOption.choice(
|
||||
leading: const AppIcon(Icons.person_outline),
|
||||
title: Text(context.l10n.optionsArtistTagModePrimary),
|
||||
subtitle: Text(context.l10n.optionsArtistTagModePrimarySubtitle),
|
||||
selected: currentMode == artistTagModePrimary,
|
||||
trailing: currentMode == artistTagModePrimary
|
||||
? const AppIcon(Icons.check)
|
||||
: null,
|
||||
onTap: () {
|
||||
ref
|
||||
.read(settingsProvider.notifier)
|
||||
|
||||
@@ -216,16 +216,10 @@ class _AccountFormDialogState extends State<_AccountFormDialog> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (final option in (field['options'] as List).cast<String>())
|
||||
Semantics(
|
||||
AppSheetOption.choice(
|
||||
title: Text(option),
|
||||
selected: option == _choices[key],
|
||||
child: AppSheetOption(
|
||||
title: Text(option),
|
||||
selected: option == _choices[key],
|
||||
trailing: option == _choices[key]
|
||||
? const Icon(Icons.check)
|
||||
: null,
|
||||
onTap: () => Navigator.pop(sheetContext, option),
|
||||
),
|
||||
onTap: () => Navigator.pop(sheetContext, option),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user