Merge pull request 'fix saving and displaying theme name' (#829) from themeName into theme-loading-fix
Reviewed-on: #829
This commit is contained in:
commit
726c63c485
|
@ -90,6 +90,7 @@ class Settings extends ChangeNotifier {
|
||||||
bool get useSemanticDebugger => _useSemanticDebugger;
|
bool get useSemanticDebugger => _useSemanticDebugger;
|
||||||
|
|
||||||
String? _themeId;
|
String? _themeId;
|
||||||
|
String? get themeId => _themeId;
|
||||||
String? _mode;
|
String? _mode;
|
||||||
OpaqueThemeType get theme => themeloader.getTheme(_themeId, _mode);
|
OpaqueThemeType get theme => themeloader.getTheme(_themeId, _mode);
|
||||||
void setTheme(String themeId, String mode) {
|
void setTheme(String themeId, String mode) {
|
||||||
|
@ -483,7 +484,7 @@ class Settings extends ChangeNotifier {
|
||||||
dynamic asJson() {
|
dynamic asJson() {
|
||||||
return {
|
return {
|
||||||
"Locale": this.locale.toString(),
|
"Locale": this.locale.toString(),
|
||||||
"Theme": theme.theme,
|
"Theme": _themeId,
|
||||||
"ThemeMode": theme.mode,
|
"ThemeMode": theme.mode,
|
||||||
"ThemeImages": _themeImages,
|
"ThemeImages": _themeImages,
|
||||||
"PreviousPid": -1,
|
"PreviousPid": -1,
|
||||||
|
|
|
@ -132,7 +132,7 @@ class YmlTheme extends OpaqueThemeType {
|
||||||
val = yml["themes"][mode]["theme"][val] ?? val;
|
val = yml["themes"][mode]["theme"][val] ?? val;
|
||||||
}
|
}
|
||||||
if (!(val is int)) {
|
if (!(val is int)) {
|
||||||
val = yml["themes"][mode]?["colors"][val] ?? val;
|
val = yml["themes"][mode]?["colors"]?[val] ?? val;
|
||||||
}
|
}
|
||||||
if (!(val is int)) {
|
if (!(val is int)) {
|
||||||
val = yml["colors"]?[val];
|
val = yml["colors"]?[val];
|
||||||
|
|
|
@ -92,7 +92,7 @@ class _GlobalSettingsAppearanceViewState extends State<GlobalSettingsAppearanceV
|
||||||
child: DropdownButton<String>(
|
child: DropdownButton<String>(
|
||||||
key: Key("DropdownTheme"),
|
key: Key("DropdownTheme"),
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
value: Provider.of<Settings>(context).theme.theme,
|
value: Provider.of<Settings>(context).themeId,
|
||||||
onChanged: (String? newValue) {
|
onChanged: (String? newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
settings.setTheme(newValue!, settings.theme.mode);
|
settings.setTheme(newValue!, settings.theme.mode);
|
||||||
|
@ -102,7 +102,7 @@ class _GlobalSettingsAppearanceViewState extends State<GlobalSettingsAppearanceV
|
||||||
items: settings.themeloader.themes.keys.map<DropdownMenuItem<String>>((String themeId) {
|
items: settings.themeloader.themes.keys.map<DropdownMenuItem<String>>((String themeId) {
|
||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
value: themeId,
|
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())),
|
}).toList())),
|
||||||
leading: Icon(Icons.palette, color: settings.current().mainTextColor),
|
leading: Icon(Icons.palette, color: settings.current().mainTextColor),
|
||||||
|
@ -330,7 +330,7 @@ class _GlobalSettingsAppearanceViewState extends State<GlobalSettingsAppearanceV
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Since we don't seem to able to dynamically pull translations, this function maps themes to their names
|
/// 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) {
|
switch (theme) {
|
||||||
case cwtch_theme:
|
case cwtch_theme:
|
||||||
return AppLocalizations.of(context)!.themeNameCwtch;
|
return AppLocalizations.of(context)!.themeNameCwtch;
|
||||||
|
@ -353,7 +353,7 @@ class _GlobalSettingsAppearanceViewState extends State<GlobalSettingsAppearanceV
|
||||||
case "juniper":
|
case "juniper":
|
||||||
return "Juniper"; // Juniper is a noun, and doesn't get subject to translation...
|
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 {
|
void importThemeCheck(BuildContext context, Settings settings, String themesDir, String newThemeDirectory) async {
|
||||||
|
|
|
@ -259,7 +259,7 @@ class _MessageViewState extends State<MessageView> {
|
||||||
actions: appBarButtons,
|
actions: appBarButtons,
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: EdgeInsets.fromLTRB(8.0, 8.0, 8.0, 182.0),
|
padding: EdgeInsets.fromLTRB(8.0, 8.0, 8.0, 164.0),
|
||||||
child: MessageList(
|
child: MessageList(
|
||||||
scrollListener,
|
scrollListener,
|
||||||
)),
|
)),
|
||||||
|
|
|
@ -123,7 +123,10 @@ class _MessageListState extends State<MessageList> {
|
||||||
image: AssetImage("assets/core/negative_heart_512px.png"),
|
image: AssetImage("assets/core/negative_heart_512px.png"),
|
||||||
colorFilter: ColorFilter.mode(Provider.of<Settings>(context).theme.hilightElementColor.withOpacity(0.15), BlendMode.srcIn))),
|
colorFilter: ColorFilter.mode(Provider.of<Settings>(context).theme.hilightElementColor.withOpacity(0.15), BlendMode.srcIn))),
|
||||||
// Don't load messages for syncing server...
|
// Don't load messages for syncing server...
|
||||||
child: loadMessages
|
child:
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 20.0),
|
||||||
|
child: loadMessages
|
||||||
? ScrollablePositionedList.builder(
|
? ScrollablePositionedList.builder(
|
||||||
itemPositionsListener: widget.scrollListener,
|
itemPositionsListener: widget.scrollListener,
|
||||||
itemScrollController: Provider.of<ContactInfoState>(outerContext).messageScrollController,
|
itemScrollController: Provider.of<ContactInfoState>(outerContext).messageScrollController,
|
||||||
|
@ -152,7 +155,7 @@ class _MessageListState extends State<MessageList> {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: null))
|
: null)))
|
||||||
])));
|
])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue