mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 08:46:18 +01:00
Fix dynamic color scheme not applied to some pages
This commit is contained in:
parent
91bf1a0108
commit
1143173534
3 changed files with 18 additions and 5 deletions
|
@ -1,4 +1,5 @@
|
|||
import 'package:clock/clock.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Hold non-persisted global variables
|
||||
class SessionStorage {
|
||||
|
@ -16,6 +17,8 @@ class SessionStorage {
|
|||
|
||||
/// Whether the dynamic_color library is supported in this platform
|
||||
bool isSupportDynamicColor = false;
|
||||
ColorScheme? lightDynamicColorScheme;
|
||||
ColorScheme? darkDynamicColorScheme;
|
||||
|
||||
DateTime lastSuspendTime = clock.now();
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'package:flex_seed_scheme/flex_seed_scheme.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:nc_photos/controller/pref_controller.dart';
|
||||
import 'package:nc_photos/session_storage.dart';
|
||||
import 'package:nc_photos/theme/dimension.dart';
|
||||
import 'package:np_ui/np_ui.dart';
|
||||
|
||||
|
@ -116,12 +117,20 @@ ThemeData buildTheme(BuildContext context, Brightness brightness) {
|
|||
}
|
||||
|
||||
ThemeData buildLightTheme(BuildContext context, [ColorScheme? dynamicScheme]) {
|
||||
final colorScheme = _getColorScheme(context, dynamicScheme, Brightness.light);
|
||||
final colorScheme = _getColorScheme(
|
||||
context,
|
||||
dynamicScheme ?? SessionStorage().lightDynamicColorScheme,
|
||||
Brightness.light,
|
||||
);
|
||||
return _applyColorScheme(colorScheme);
|
||||
}
|
||||
|
||||
ThemeData buildDarkTheme(BuildContext context, [ColorScheme? dynamicScheme]) {
|
||||
final colorScheme = _getColorScheme(context, dynamicScheme, Brightness.dark);
|
||||
final colorScheme = _getColorScheme(
|
||||
context,
|
||||
dynamicScheme ?? SessionStorage().darkDynamicColorScheme,
|
||||
Brightness.dark,
|
||||
);
|
||||
if (context.read<PrefController>().isUseBlackInDarkTheme.value) {
|
||||
return _applyColorScheme(colorScheme.copyWith(
|
||||
background: Colors.black,
|
||||
|
|
|
@ -137,9 +137,10 @@ class _WrappedAppState extends State<_WrappedApp>
|
|||
previous.secondarySeedColor != current.secondarySeedColor,
|
||||
builder: (context, state) => DynamicColorBuilder(
|
||||
builder: (lightDynamic, darkDynamic) {
|
||||
if (lightDynamic != null) {
|
||||
SessionStorage().isSupportDynamicColor = true;
|
||||
}
|
||||
SessionStorage()
|
||||
..lightDynamicColorScheme = lightDynamic
|
||||
..darkDynamicColorScheme = darkDynamic
|
||||
..isSupportDynamicColor = lightDynamic != null;
|
||||
final ThemeMode themeMode;
|
||||
if (state.isFollowSystemTheme) {
|
||||
themeMode = ThemeMode.system;
|
||||
|
|
Loading…
Reference in a new issue