refactor: Use AppSettings enum based configuration everywhere and fix load from json on web
This commit is contained in:
parent
4f0ed3e93f
commit
4c357f6249
46 changed files with 357 additions and 402 deletions
|
|
@ -18,7 +18,9 @@ class SettingsStyle extends StatefulWidget {
|
|||
|
||||
class SettingsStyleController extends State<SettingsStyle> {
|
||||
void setChatColor(Color? color) async {
|
||||
AppConfig.colorSchemeSeed = color;
|
||||
AppSettings.colorSchemeSeedInt.setItem(
|
||||
color?.toARGB32() ?? AppSettings.colorSchemeSeedInt.defaultValue,
|
||||
);
|
||||
ThemeController.of(context).setPrimaryColor(color);
|
||||
}
|
||||
|
||||
|
|
@ -156,11 +158,7 @@ class SettingsStyleController extends State<SettingsStyle> {
|
|||
}
|
||||
|
||||
void changeFontSizeFactor(double d) {
|
||||
setState(() => AppConfig.fontSizeFactor = d);
|
||||
Matrix.of(context).store.setString(
|
||||
SettingKeys.fontSizeFactor,
|
||||
AppConfig.fontSizeFactor.toString(),
|
||||
);
|
||||
AppSettings.fontSizeFactor.setItem(d);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ class SettingsStyleView extends StatelessWidget {
|
|||
style: TextStyle(
|
||||
color: theme.onBubbleColor,
|
||||
fontSize: AppConfig.messageFontSize *
|
||||
AppConfig.fontSizeFactor,
|
||||
AppSettings.fontSizeFactor.value,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -263,7 +263,7 @@ class SettingsStyleView extends StatelessWidget {
|
|||
style: TextStyle(
|
||||
color: theme.colorScheme.onSurface,
|
||||
fontSize: AppConfig.messageFontSize *
|
||||
AppConfig.fontSizeFactor,
|
||||
AppSettings.fontSizeFactor.value,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -325,13 +325,15 @@ class SettingsStyleView extends StatelessWidget {
|
|||
),
|
||||
ListTile(
|
||||
title: Text(L10n.of(context).fontSize),
|
||||
trailing: Text('× ${AppConfig.fontSizeFactor}'),
|
||||
trailing: Text(
|
||||
'× ${AppSettings.fontSizeFactor.value}',
|
||||
),
|
||||
),
|
||||
Slider.adaptive(
|
||||
min: 0.5,
|
||||
max: 2.5,
|
||||
divisions: 20,
|
||||
value: AppConfig.fontSizeFactor,
|
||||
value: AppSettings.fontSizeFactor.value,
|
||||
semanticFormatterCallback: (d) => d.toString(),
|
||||
onChanged: controller.changeFontSizeFactor,
|
||||
),
|
||||
|
|
@ -349,21 +351,15 @@ class SettingsStyleView extends StatelessWidget {
|
|||
),
|
||||
SettingsSwitchListTile.adaptive(
|
||||
title: L10n.of(context).presencesToggle,
|
||||
onChanged: (b) => AppConfig.showPresences = b,
|
||||
storeKey: SettingKeys.showPresences,
|
||||
defaultValue: AppConfig.showPresences,
|
||||
setting: AppSettings.showPresences,
|
||||
),
|
||||
SettingsSwitchListTile.adaptive(
|
||||
title: L10n.of(context).separateChatTypes,
|
||||
onChanged: (b) => AppConfig.separateChatTypes = b,
|
||||
storeKey: SettingKeys.separateChatTypes,
|
||||
defaultValue: AppConfig.separateChatTypes,
|
||||
setting: AppSettings.separateChatTypes,
|
||||
),
|
||||
SettingsSwitchListTile.adaptive(
|
||||
title: L10n.of(context).displayNavigationRail,
|
||||
onChanged: (b) => AppConfig.displayNavigationRail = b,
|
||||
storeKey: SettingKeys.displayNavigationRail,
|
||||
defaultValue: AppConfig.displayNavigationRail,
|
||||
setting: AppSettings.displayNavigationRail,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue