diff --git a/docs/prompt.md b/docs/prompt.md
index e175e85..09ec7bc 100644
--- a/docs/prompt.md
+++ b/docs/prompt.md
@@ -44,3 +44,8 @@ Folgende Dateien wurden in diesem Prompt verändert:
- Use the first three letters of the username as the avatar for the profile and remove the team name input in the settings.
Folgende Dateien wurden in diesem Prompt verändert:
- frontend_splatournament_manager/lib/widgets/profile_widget.dart
+
+- Save the theme preferences so they persist across restarts.
+Folgende Dateien wurden in diesem Prompt verändert:
+ - frontend_splatournament_manager/pubspec.yaml
+ - frontend_splatournament_manager/lib/providers/theme_provider.dart
diff --git a/frontend_splatournament_manager/lib/providers/theme_provider.dart b/frontend_splatournament_manager/lib/providers/theme_provider.dart
index f456b50..f3a1191 100644
--- a/frontend_splatournament_manager/lib/providers/theme_provider.dart
+++ b/frontend_splatournament_manager/lib/providers/theme_provider.dart
@@ -1,12 +1,51 @@
import 'package:flutter/material.dart';
+import 'package:shared_preferences/shared_preferences.dart';
class ThemeProvider extends ChangeNotifier {
+ static const String _themeKey = 'theme_mode';
ThemeMode _themeMode = ThemeMode.system;
ThemeMode get theme => _themeMode;
- void setTheme(ThemeMode mode) {
- _themeMode = mode;
+ ThemeProvider() {
+ _loadTheme();
+ }
+
+ Future _loadTheme() async {
+ final prefs = await SharedPreferences.getInstance();
+ final themeName = prefs.getString(_themeKey) ?? 'system';
+ _themeMode = _themeFromString(themeName);
notifyListeners();
}
+
+ Future setTheme(ThemeMode mode) async {
+ _themeMode = mode;
+ notifyListeners();
+
+ final prefs = await SharedPreferences.getInstance();
+ await prefs.setString(_themeKey, _themeToString(mode));
+ }
+
+ String _themeToString(ThemeMode mode) {
+ switch (mode) {
+ case ThemeMode.light:
+ return 'light';
+ case ThemeMode.dark:
+ return 'dark';
+ case ThemeMode.system:
+ return 'system';
+ }
+ }
+
+ ThemeMode _themeFromString(String theme) {
+ switch (theme) {
+ case 'light':
+ return ThemeMode.light;
+ case 'dark':
+ return ThemeMode.dark;
+ case 'system':
+ default:
+ return ThemeMode.system;
+ }
+ }
}
\ No newline at end of file
diff --git a/frontend_splatournament_manager/pubspec.yaml b/frontend_splatournament_manager/pubspec.yaml
index 55871e1..be81728 100644
--- a/frontend_splatournament_manager/pubspec.yaml
+++ b/frontend_splatournament_manager/pubspec.yaml
@@ -40,6 +40,7 @@ dependencies:
intl: ^0.20.2
flutter_secure_storage: ^10.0.0
jwt_decoder: ^2.0.1
+ shared_preferences: ^2.3.3
dev_dependencies:
flutter_test: