Line data Source code
1 : // Copyright 2023 The terCAD team. All rights reserved.
2 : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
3 :
4 : import 'package:app_finance/_classes/storage/app_preferences.dart';
5 : import 'package:app_finance/_configs/custom_color_scheme.dart';
6 : import 'package:material_ui/material_ui.dart';
7 :
8 : class AppPalette extends ValueNotifier<String> {
9 2 : static get state => AppPreferences.get(AppPreferences.prefColor) ?? AppColors.colorApp;
10 4 : static get light => AppPreferences.get(AppPreferences.prefPalette) ?? AppDefaultColors().toString();
11 4 : static get dark => AppPreferences.get(AppPreferences.prefPaletteDark) ?? AppDarkColors().toString();
12 :
13 3 : AppPalette() : super(state);
14 :
15 0 : Future<void> setMode(String newValue) async {
16 0 : if (newValue != value) {
17 0 : value = newValue;
18 0 : await AppPreferences.set(AppPreferences.prefColor, value);
19 0 : notifyListeners();
20 : }
21 : }
22 :
23 0 : Future<void> set(AppDefaultColors light, AppDefaultColors dark) async {
24 0 : await AppPreferences.set(AppPreferences.prefPalette, light.toString());
25 0 : await AppPreferences.set(AppPreferences.prefPaletteDark, dark.toString());
26 0 : notifyListeners();
27 : }
28 : }
|