fix saving and displaying theme name

This commit is contained in:
Dan Ballard 2024-02-13 18:24:39 -08:00 committed by Sarah Jamie Lewis
parent 3d2b960a20
commit a6c0e8105d
Signed by: sarah
GPG Key ID: F27FD21A270837EF
2 changed files with 6 additions and 5 deletions

View File

@ -88,6 +88,7 @@ class Settings extends ChangeNotifier {
bool get useSemanticDebugger => _useSemanticDebugger;
String? _themeId;
String? get themeId => _themeId;
String? _mode;
OpaqueThemeType get theme => themeloader.getTheme(_themeId, _mode);
void setTheme(String themeId, String mode) {
@ -481,7 +482,7 @@ class Settings extends ChangeNotifier {
dynamic asJson() {
return {
"Locale": this.locale.toString(),
"Theme": theme.theme,
"Theme": _themeId,
"ThemeMode": theme.mode,
"ThemeImages": _themeImages,
"PreviousPid": -1,

View File

@ -91,7 +91,7 @@ class _GlobalSettingsAppearanceViewState extends State<GlobalSettingsAppearanceV
child: DropdownButton<String>(
key: Key("DropdownTheme"),
isExpanded: true,
value: Provider.of<Settings>(context).theme.theme,
value: Provider.of<Settings>(context).themeId,
onChanged: (String? newValue) {
setState(() {
settings.setTheme(newValue!, settings.theme.mode);
@ -101,7 +101,7 @@ class _GlobalSettingsAppearanceViewState extends State<GlobalSettingsAppearanceV
items: settings.themeloader.themes.keys.map<DropdownMenuItem<String>>((String themeId) {
return DropdownMenuItem<String>(
value: themeId,
child: Text(getThemeName(context, themeId), style: settings.scaleFonts(defaultDropDownMenuItemTextStyle)), //"ddi_$themeId", key: Key("ddi_$themeId")),
child: Text(getThemeName(context, settings, themeId), style: settings.scaleFonts(defaultDropDownMenuItemTextStyle)), //"ddi_$themeId", key: Key("ddi_$themeId")),
);
}).toList())),
leading: Icon(Icons.palette, color: settings.current().mainTextColor),
@ -329,7 +329,7 @@ class _GlobalSettingsAppearanceViewState extends State<GlobalSettingsAppearanceV
}
/// Since we don't seem to able to dynamically pull translations, this function maps themes to their names
String getThemeName(context, String theme) {
String getThemeName(context, Settings settings, String theme) {
switch (theme) {
case cwtch_theme:
return AppLocalizations.of(context)!.themeNameCwtch;
@ -352,7 +352,7 @@ class _GlobalSettingsAppearanceViewState extends State<GlobalSettingsAppearanceV
case "juniper":
return "Juniper"; // Juniper is a noun, and doesn't get subject to translation...
}
return theme;
return settings.themeloader.themes[theme]?[settings.theme.mode]?.theme ?? theme;
}
void importThemeCheck(BuildContext context, Settings settings, String themesDir, String newThemeDirectory) async {