public async Task ApplyThemeAsync(string themeName) { await Js.ApplyThemeAsync(themeName); CurrentThemeName = await Js.GetCurrentThemeNameAsync(); if (IsStorageEnabled) { await Js.StorageSetItemAsync(ThemeStorageKey, CurrentThemeName); } $"Current theme changed to '{CurrentThemeName}'" .Log(nameof(CandyThemeManager), nameof(OnInitializedAsync)); StateHasChanged(); }
protected override async Task OnInitializedAsync() { ThemeNames = await Js.GetThemeNamesAsync(); CurrentThemeName = IsStorageEnabled ? await Js.StorageGetItemAsync(ThemeStorageKey) : string.Empty; if (string.IsNullOrWhiteSpace(CurrentThemeName)) { CurrentThemeName = DefaultThemeName; } if (IsStorageEnabled) { await Js.StorageSetItemAsync(ThemeStorageKey, CurrentThemeName); } await Js.ApplyThemeAsync(CurrentThemeName); $"Loaded {ThemeNames?.Count} themes. Current Theme: {CurrentThemeName}" .Log(nameof(CandyThemeManager), nameof(OnInitializedAsync)); }