refactor: replace HookConsumerWidget with ConsumerWidget and add ThemeModePrefTile

This commit is contained in:
TheLastFlame
2024-10-03 17:41:09 +10:00
parent 0ff4a04a4b
commit 55230f6f0f
2 changed files with 46 additions and 35 deletions

View File

@@ -19,39 +19,10 @@ class GeneralSettingTiles extends HookConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final t = ref.watch(translationsProvider);
final themeMode = ref.watch(themePreferencesProvider);
return Column(
children: [
const LocalePrefTile(),
ListTile(
title: Text(t.settings.general.themeMode),
subtitle: Text(themeMode.present(t)),
leading: const Icon(FluentIcons.weather_moon_20_regular),
onTap: () async {
final selectedThemeMode = await showDialog<AppThemeMode>(
context: context,
builder: (context) {
return SimpleDialog(
title: Text(t.settings.general.themeMode),
children: AppThemeMode.values
.map(
(e) => RadioListTile(
title: Text(e.present(t)),
value: e,
groupValue: themeMode,
onChanged: Navigator.of(context).maybePop,
),
)
.toList(),
);
},
);
if (selectedThemeMode != null) {
await ref.read(themePreferencesProvider.notifier).changeThemeMode(selectedThemeMode);
}
},
),
const ThemeModePrefTile(),
const EnableAnalyticsPrefTile(),
SwitchListTile(
title: Text(t.settings.general.autoIpCheck),