Skip to content

Commit 9b828ea

Browse files
committed
feat: Added a whole route to configure the app theme.
1 parent 9b8028e commit 9b828ea

File tree

6 files changed

+76
-16
lines changed

6 files changed

+76
-16
lines changed

lib/i18n/de/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@
2828
},
2929
"theme": {
3030
"title": "Thema",
31-
"values(map)": {
31+
"subtitle": "Ändern Sie den Anwendungsthemen und Helligkeit.",
32+
"name(map)": {
3233
"system": "System",
3334
"light": "Hell",
3435
"dark": "Dunkel"
36+
},
37+
"description(map)": {
38+
"system": "Verwenden Sie das Systemthema.",
39+
"light": "Verwenden Sie das Hellenthema.",
40+
"dark": "Verwenden Sie das Dunkelthema."
3541
}
3642
}
3743
},

lib/i18n/en/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@
2828
},
2929
"theme": {
3030
"title": "Theme",
31-
"values(map)": {
31+
"subtitle": "Change the application theme and brightness.",
32+
"name(map)": {
3233
"system": "System",
3334
"light": "Light",
3435
"dark": "Dark"
36+
},
37+
"description(map)": {
38+
"system": "Follow the system theme.",
39+
"light": "Use the light theme.",
40+
"dark": "Use the dark theme."
3541
}
3642
}
3743
},

lib/i18n/fr/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@
2828
},
2929
"theme": {
3030
"title": "Thème",
31-
"values(map)": {
31+
"subtitle": "Changer le thème de l'application et la luminosité.",
32+
"name(map)": {
3233
"system": "Système",
3334
"light": "Lumineux",
3435
"dark": "Sombre"
36+
},
37+
"description(map)": {
38+
"system": "Suivre le thème du système.",
39+
"light": "Utiliser le thème lumineux.",
40+
"dark": "Utiliser le thème sombre."
3541
}
3642
}
3743
},

lib/i18n/it/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@
2828
},
2929
"theme": {
3030
"title": "Tema",
31-
"values(map)": {
31+
"subtitle": "Cambia il tema dell'applicazione e la luminosità.",
32+
"name(map)": {
3233
"system": "Sistema",
3334
"light": "Chiaro",
3435
"dark": "Scuro"
36+
},
37+
"description(map)": {
38+
"system": "Usa il tema del sistema.",
39+
"light": "Usa il tema scuro.",
40+
"dark": "Usa il tema scuro."
3541
}
3642
}
3743
},

lib/i18n/pt/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@
2828
},
2929
"theme": {
3030
"title": "Tema",
31-
"values(map)": {
31+
"subtitle": "Altere o tema da aplicação e a luminosidade.",
32+
"name(map)": {
3233
"system": "Sistema",
3334
"light": "Claro",
3435
"dark": "Escuro"
36+
},
37+
"description(map)": {
38+
"system": "Use o tema do sistema.",
39+
"light": "Use o tema escuro.",
40+
"dark": "Use o tema escuro."
3541
}
3642
}
3743
},

lib/pages/settings/entries/theme.dart

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
22
import 'package:flutter_riverpod/flutter_riverpod.dart';
33
import 'package:open_authenticator/i18n/translations.g.dart';
44
import 'package:open_authenticator/model/settings/theme.dart';
5-
import 'package:open_authenticator/widgets/form/dropdown_list_tile.dart';
65

76
/// Allows to configure [themeSettingsEntryProvider].
87
class ThemeSettingsEntryWidget extends ConsumerWidget {
@@ -14,23 +13,54 @@ class ThemeSettingsEntryWidget extends ConsumerWidget {
1413
@override
1514
Widget build(BuildContext context, WidgetRef ref) {
1615
AsyncValue<ThemeMode> theme = ref.watch(themeSettingsEntryProvider);
17-
return DropdownListTile(
16+
return ListTile(
1817
enabled: theme.hasValue,
1918
title: Text(translations.settings.application.theme.title),
20-
value: theme.value,
21-
choices: [
22-
for (ThemeMode mode in ThemeMode.values)
23-
DropdownListTileChoice(
24-
title: translations.settings.application.theme.values[mode.name]!,
25-
icon: mode.icon,
26-
value: mode,
19+
subtitle: Text(translations.settings.application.theme.subtitle),
20+
leading: Icon(theme.value?.icon),
21+
trailing: const Padding(
22+
padding: EdgeInsets.symmetric(horizontal: 10),
23+
child: Icon(Icons.chevron_right),
24+
),
25+
onTap: () {
26+
Navigator.push(
27+
context,
28+
MaterialPageRoute(
29+
builder: (context) => _ThemeRouteWidget(),
2730
),
28-
],
29-
onChoiceSelected: (choice) => ref.read(themeSettingsEntryProvider.notifier).changeValue(choice.value),
31+
);
32+
},
3033
);
3134
}
3235
}
3336

37+
/// Allows to configure the theme.
38+
class _ThemeRouteWidget extends ConsumerWidget {
39+
@override
40+
Widget build(BuildContext context, WidgetRef ref) {
41+
AsyncValue<ThemeMode> theme = ref.watch(themeSettingsEntryProvider);
42+
return Scaffold(
43+
appBar: AppBar(
44+
title: Text(translations.settings.application.theme.title),
45+
),
46+
body: ListView(
47+
shrinkWrap: true,
48+
children: [
49+
for (ThemeMode mode in ThemeMode.values)
50+
ListTile(
51+
leading: Icon(mode.icon),
52+
title: Text(translations.settings.application.theme.name[mode.name]!),
53+
subtitle: Text(translations.settings.application.theme.description[mode.name]!),
54+
trailing: theme.value == mode ? const Icon(Icons.check) : null,
55+
onTap: () => ref.read(themeSettingsEntryProvider.notifier).changeValue(mode),
56+
),
57+
],
58+
),
59+
);
60+
}
61+
62+
}
63+
3464
/// Allows to associate an icon with a theme mode.
3565
extension _Icon on ThemeMode? {
3666
/// Returns the icon associated with the current theme mode.

0 commit comments

Comments
 (0)