2024-07-31 14:48:22 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'package:solian/theme.dart';
|
|
|
|
|
|
|
|
class ThemeSwitcher extends ChangeNotifier {
|
|
|
|
ThemeData lightThemeData;
|
|
|
|
ThemeData darkThemeData;
|
|
|
|
|
|
|
|
ThemeSwitcher({
|
|
|
|
required this.lightThemeData,
|
|
|
|
required this.darkThemeData,
|
|
|
|
});
|
|
|
|
|
|
|
|
Future<void> restoreTheme() async {
|
|
|
|
final prefs = await SharedPreferences.getInstance();
|
|
|
|
if (prefs.containsKey('global_theme_color')) {
|
|
|
|
final value = prefs.getInt('global_theme_color')!;
|
|
|
|
final color = Color(value);
|
2024-09-13 12:22:10 +00:00
|
|
|
lightThemeData = AppTheme.build(Brightness.light, seedColor: color);
|
|
|
|
darkThemeData = AppTheme.build(Brightness.dark, seedColor: color);
|
2024-07-31 14:48:22 +00:00
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void setTheme(ThemeData light, dark) {
|
|
|
|
lightThemeData = light;
|
|
|
|
darkThemeData = dark;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|