mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-04-21 07:41:58 +00:00
Apply Correct System Theme After Restart
App now looks if the system theme has been changed since last time the app was used and changes it accordingly.
This commit is contained in:
parent
a47581ac01
commit
0d9ba09183
1 changed files with 12 additions and 1 deletions
|
|
@ -91,6 +91,7 @@ class _MyAppState extends ConsumerState<MyApp> {
|
|||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_iniDateFormatting();
|
||||
_initDeepLinks();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
|
|
@ -100,7 +101,17 @@ class _MyAppState extends ConsumerState<MyApp> {
|
|||
.clearCache(showToast: false);
|
||||
}
|
||||
});
|
||||
super.initState();
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// Check if System theme has changed since last app start and adjust
|
||||
var brightness = WidgetsBinding.instance.platformDispatcher.platformBrightness;
|
||||
if (brightness == Brightness.light) {
|
||||
ref.read(themeModeStateProvider.notifier).setLightTheme();
|
||||
} else {
|
||||
ref.read(themeModeStateProvider.notifier).setDarkTheme();
|
||||
}
|
||||
});
|
||||
|
||||
var dispatcher = SchedulerBinding.instance.platformDispatcher;
|
||||
dispatcher.onPlatformBrightnessChanged = () {
|
||||
var brightness = dispatcher.platformBrightness;
|
||||
|
|
|
|||
Loading…
Reference in a new issue