themeVariant is optional

This commit is contained in:
RMidhunSuresh 2022-06-06 17:20:16 +05:30
parent a639fc5467
commit 0dac00f327
1 changed files with 5 additions and 2 deletions

View File

@ -131,7 +131,7 @@ export class ThemeLoader {
}
}
setTheme(themeName: string, themeVariant: "light" | "dark" | "default", log?: ILogItem) {
setTheme(themeName: string, themeVariant?: "light" | "dark" | "default", log?: ILogItem) {
this._platform.logger.wrapOrRun(log, { l: "change theme", name: themeName, variant: themeVariant }, () => {
let cssLocation: string;
let themeDetails = this._themeMapping[themeName];
@ -139,7 +139,10 @@ export class ThemeLoader {
cssLocation = themeDetails.cssLocation;
}
else {
cssLocation = themeDetails[themeVariant ?? "default"].cssLocation;
if (!themeVariant) {
throw new Error("themeVariant is undefined!");
}
cssLocation = themeDetails[themeVariant].cssLocation;
}
this._platform.replaceStylesheet(cssLocation);
this._platform.settingsStorage.setString("theme-name", themeName);