@inherits LayoutComponentBase
@inject Blazored.LocalStorage.ILocalStorageService localStorage
TaikoWebUI
@Body
@code {
bool _drawerOpen = true;
bool _isDarkMode = false;
protected override async Task OnInitializedAsync()
{
var hasDrawerOpenEntry = await localStorage.ContainKeyAsync("drawerOpen");
if (hasDrawerOpenEntry)
{
_drawerOpen = await localStorage.GetItemAsync("drawerOpen");
}
var hasDarkModeEntry = await localStorage.ContainKeyAsync("isDarkMode");
if (hasDarkModeEntry)
{
_isDarkMode = await localStorage.GetItemAsync("isDarkMode");
}
}
private async Task DrawerToggle()
{
_drawerOpen = !_drawerOpen;
await localStorage.SetItemAsync("drawerOpen", _drawerOpen);
}
private async Task ToggleDarkMode()
{
_isDarkMode = !_isDarkMode;
await localStorage.SetItemAsync("isDarkMode", _isDarkMode);
}
private string DarkModeIcon => _isDarkMode ? Icons.Material.Filled.BrightnessLow : Icons.Material.Filled.Brightness2;
MudTheme TaikoWebUiTheme = new MudTheme()
{
Palette = new PaletteLight()
{
Primary = Colors.Indigo.Default,
PrimaryLighten = Colors.Indigo.Lighten2,
PrimaryDarken = Colors.Indigo.Darken2,
AppbarBackground = Colors.Indigo.Darken3,
},
PaletteDark = new PaletteDark()
{
Primary = Colors.Indigo.Accent1,
PrimaryLighten = Colors.Indigo.Lighten4,
PrimaryDarken = Colors.Indigo.Accent1,
},
};
}