|
|
|
@ -1,8 +1,18 @@
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
|
|
|
|
|
|
final Map<String, ThemeData> themeMap = {
|
|
|
|
|
'f0ck': f0ckTheme,
|
|
|
|
|
'P1nk': p1nkTheme, // done
|
|
|
|
|
'Orange': orangeTheme,
|
|
|
|
|
'Amoled': amoledTheme,
|
|
|
|
|
'Paper': paperTheme,
|
|
|
|
|
//'Iced': icedTheme,
|
|
|
|
|
'f0ck95': f0ck95Theme,
|
|
|
|
|
'f0ck95d': f0ck95dTheme,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ThemeNotifier extends StateNotifier<ThemeData> {
|
|
|
|
|
final FlutterSecureStorage secureStorage;
|
|
|
|
|
|
|
|
|
@ -11,23 +21,24 @@ class ThemeNotifier extends StateNotifier<ThemeData> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _loadTheme() async {
|
|
|
|
|
String? savedThemeName = await secureStorage.read(key: 'theme');
|
|
|
|
|
if (savedThemeName != null) {
|
|
|
|
|
final customTheme = themes.firstWhere(
|
|
|
|
|
(t) => t.name == savedThemeName,
|
|
|
|
|
orElse: () => CustomTheme(name: 'f0ck', theme: f0ckTheme),
|
|
|
|
|
);
|
|
|
|
|
state = customTheme.theme;
|
|
|
|
|
try {
|
|
|
|
|
String? savedThemeName = await secureStorage.read(key: 'theme');
|
|
|
|
|
if (savedThemeName != null && themeMap.containsKey(savedThemeName)) {
|
|
|
|
|
state = themeMap[savedThemeName]!;
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
debugPrint('Fehler beim Laden des Themes: $error');
|
|
|
|
|
state = f0ckTheme;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> updateTheme(String themeName) async {
|
|
|
|
|
await secureStorage.write(key: 'theme', value: themeName);
|
|
|
|
|
final newTheme = themes.firstWhere(
|
|
|
|
|
(t) => t.name == themeName,
|
|
|
|
|
orElse: () => CustomTheme(name: 'f0ck', theme: f0ckTheme),
|
|
|
|
|
);
|
|
|
|
|
state = newTheme.theme;
|
|
|
|
|
try {
|
|
|
|
|
await secureStorage.write(key: 'theme', value: themeName);
|
|
|
|
|
state = themeMap[themeName] ?? f0ckTheme;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
debugPrint('Fehler beim Aktualisieren des Themes: $error');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -35,28 +46,12 @@ final themeNotifierProvider = StateNotifierProvider<ThemeNotifier, ThemeData>((
|
|
|
|
|
ref,
|
|
|
|
|
) {
|
|
|
|
|
return ThemeNotifier(
|
|
|
|
|
secureStorage: FlutterSecureStorage(
|
|
|
|
|
secureStorage: const FlutterSecureStorage(
|
|
|
|
|
aOptions: AndroidOptions(encryptedSharedPreferences: true),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
class CustomTheme {
|
|
|
|
|
final String name;
|
|
|
|
|
final ThemeData theme;
|
|
|
|
|
|
|
|
|
|
CustomTheme({required this.name, required this.theme});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final List<CustomTheme> themes = [
|
|
|
|
|
CustomTheme(name: 'f0ck', theme: f0ckTheme),
|
|
|
|
|
CustomTheme(name: 'Paper', theme: paperTheme),
|
|
|
|
|
CustomTheme(name: 'Orange', theme: orangeTheme),
|
|
|
|
|
CustomTheme(name: 'Amoled', theme: amoledTheme),
|
|
|
|
|
CustomTheme(name: 'f0ck95', theme: f0ck95Theme),
|
|
|
|
|
CustomTheme(name: 'f0ck95d', theme: f0ck95dTheme),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
final ThemeData f0ckTheme = ThemeData(
|
|
|
|
|
brightness: Brightness.dark,
|
|
|
|
|
primaryColor: const Color(0xFF9FFF00),
|
|
|
|
@ -78,13 +73,53 @@ final ThemeData f0ckTheme = ThemeData(
|
|
|
|
|
bodyLarge: TextStyle(color: Colors.white),
|
|
|
|
|
bodyMedium: TextStyle(color: Colors.white),
|
|
|
|
|
),
|
|
|
|
|
buttonTheme: ButtonThemeData(
|
|
|
|
|
buttonColor: const Color(0xFF9FFF00),
|
|
|
|
|
textTheme: ButtonTextTheme.primary,
|
|
|
|
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
foregroundColor: const Color(0xFF000000),
|
|
|
|
|
backgroundColor: const Color(0xFF9FFF00),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
scrollbarTheme: ScrollbarThemeData(
|
|
|
|
|
thumbColor: WidgetStatePropertyAll<Color>(Color(0xFF2B2B2B)),
|
|
|
|
|
trackColor: WidgetStatePropertyAll<Color>(Color(0xFF424242)),
|
|
|
|
|
thumbColor: WidgetStateProperty.all<Color>(const Color(0xFF2B2B2B)),
|
|
|
|
|
trackColor: WidgetStateProperty.all<Color>(const Color(0xFF424242)),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final ThemeData p1nkTheme = ThemeData(
|
|
|
|
|
brightness: Brightness.dark,
|
|
|
|
|
primaryColor: const Color(0xFF171717),
|
|
|
|
|
scaffoldBackgroundColor: const Color(0xFF171717),
|
|
|
|
|
appBarTheme: const AppBarTheme(
|
|
|
|
|
color: Color(0xFF2B2B2B),
|
|
|
|
|
foregroundColor: Color(0xFFFF00D0),
|
|
|
|
|
elevation: 2,
|
|
|
|
|
),
|
|
|
|
|
textTheme: const TextTheme(
|
|
|
|
|
bodyLarge: TextStyle(color: Color(0xFFFFFFFF)),
|
|
|
|
|
bodyMedium: TextStyle(color: Color(0xFFFFFFFF)),
|
|
|
|
|
titleLarge: TextStyle(color: Color(0xFFFFFFFF)),
|
|
|
|
|
),
|
|
|
|
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
foregroundColor: const Color(0xFF000000),
|
|
|
|
|
backgroundColor: const Color(0xFFFF00D0),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
progressIndicatorTheme: const ProgressIndicatorThemeData(
|
|
|
|
|
color: Color(0xFFFF00D0),
|
|
|
|
|
),
|
|
|
|
|
scrollbarTheme: ScrollbarThemeData(
|
|
|
|
|
thumbColor: WidgetStateProperty.all(const Color(0xFF2B2B2B)),
|
|
|
|
|
trackColor: WidgetStateProperty.all(const Color(0xFF424242)),
|
|
|
|
|
),
|
|
|
|
|
colorScheme: const ColorScheme.dark(
|
|
|
|
|
primary: Color(0xFF171717),
|
|
|
|
|
secondary: Color(0xFFFF00D0),
|
|
|
|
|
surface: Color(0xFF171717),
|
|
|
|
|
onPrimary: Color(0xFFFFFFFF),
|
|
|
|
|
onSecondary: Color(0xFF000000),
|
|
|
|
|
onSurface: Color(0xFFFFFFFF),
|
|
|
|
|
error: Color(0xFFA72828),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@ -109,9 +144,11 @@ final ThemeData paperTheme = ThemeData(
|
|
|
|
|
bodyLarge: TextStyle(color: Color(0xFF000000)),
|
|
|
|
|
bodyMedium: TextStyle(color: Color(0xFF000000)),
|
|
|
|
|
),
|
|
|
|
|
buttonTheme: ButtonThemeData(
|
|
|
|
|
buttonColor: const Color(0xFF000000),
|
|
|
|
|
textTheme: ButtonTextTheme.primary,
|
|
|
|
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
foregroundColor: const Color(0xFFFFFFFF),
|
|
|
|
|
backgroundColor: const Color(0xFF000000),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@ -136,13 +173,15 @@ final ThemeData orangeTheme = ThemeData(
|
|
|
|
|
bodyLarge: TextStyle(color: Colors.white),
|
|
|
|
|
bodyMedium: TextStyle(color: Colors.white),
|
|
|
|
|
),
|
|
|
|
|
buttonTheme: ButtonThemeData(
|
|
|
|
|
buttonColor: const Color(0xFFFF6F00),
|
|
|
|
|
textTheme: ButtonTextTheme.primary,
|
|
|
|
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
backgroundColor: const Color(0xFFFF6F00),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
scrollbarTheme: ScrollbarThemeData(
|
|
|
|
|
thumbColor: WidgetStatePropertyAll<Color>(Color(0xFF2B2B2B)),
|
|
|
|
|
trackColor: WidgetStatePropertyAll<Color>(Color(0xFF424242)),
|
|
|
|
|
thumbColor: WidgetStateProperty.all<Color>(const Color(0xFF2B2B2B)),
|
|
|
|
|
trackColor: WidgetStateProperty.all<Color>(const Color(0xFF424242)),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@ -169,9 +208,11 @@ final ThemeData amoledTheme = ThemeData(
|
|
|
|
|
bodyLarge: TextStyle(color: Colors.white),
|
|
|
|
|
bodyMedium: TextStyle(color: Colors.white),
|
|
|
|
|
),
|
|
|
|
|
buttonTheme: ButtonThemeData(
|
|
|
|
|
buttonColor: const Color(0xFFFFFFFF),
|
|
|
|
|
textTheme: ButtonTextTheme.primary,
|
|
|
|
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
foregroundColor: Colors.black,
|
|
|
|
|
backgroundColor: const Color(0xFFFFFFFF),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
scrollbarTheme: ScrollbarThemeData(
|
|
|
|
|
thumbColor: WidgetStateProperty.all<Color>(const Color(0xFF1D1C1C)),
|
|
|
|
@ -199,13 +240,15 @@ final ThemeData f0ck95Theme = ThemeData(
|
|
|
|
|
bodyLarge: TextStyle(color: Colors.black),
|
|
|
|
|
bodyMedium: TextStyle(color: Colors.black),
|
|
|
|
|
),
|
|
|
|
|
buttonTheme: ButtonThemeData(
|
|
|
|
|
buttonColor: Colors.black,
|
|
|
|
|
textTheme: ButtonTextTheme.primary,
|
|
|
|
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
backgroundColor: Colors.black,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
scrollbarTheme: ScrollbarThemeData(
|
|
|
|
|
thumbColor: WidgetStatePropertyAll<Color>(Color(0xFF2B2B2B)),
|
|
|
|
|
trackColor: WidgetStatePropertyAll<Color>(Color(0xFF424242)),
|
|
|
|
|
thumbColor: WidgetStateProperty.all<Color>(const Color(0xFF2B2B2B)),
|
|
|
|
|
trackColor: WidgetStateProperty.all<Color>(const Color(0xFF424242)),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@ -229,12 +272,14 @@ final ThemeData f0ck95dTheme = ThemeData(
|
|
|
|
|
bodyLarge: TextStyle(color: Colors.white),
|
|
|
|
|
bodyMedium: TextStyle(color: Colors.white),
|
|
|
|
|
),
|
|
|
|
|
buttonTheme: ButtonThemeData(
|
|
|
|
|
buttonColor: Colors.white,
|
|
|
|
|
textTheme: ButtonTextTheme.primary,
|
|
|
|
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
foregroundColor: Colors.black,
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
scrollbarTheme: ScrollbarThemeData(
|
|
|
|
|
thumbColor: WidgetStatePropertyAll<Color>(Color(0xFF2B2B2B)),
|
|
|
|
|
trackColor: WidgetStatePropertyAll<Color>(Color(0xFF424242)),
|
|
|
|
|
thumbColor: WidgetStateProperty.all<Color>(const Color(0xFF2B2B2B)),
|
|
|
|
|
trackColor: WidgetStateProperty.all<Color>(const Color(0xFF424242)),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|