1
0
mirror of synced 2024-11-27 23:50:49 +01:00
GC-local-server-rewrite/WebUI/Common/MainLayout.razor
2023-02-18 01:29:20 +08:00

60 lines
2.1 KiB
Plaintext

@inherits LayoutComponentBase
<MudThemeProvider @ref="@MudThemeProvider" @bind-IsDarkMode="@IsDarkMode"/>
<MudDialogProvider/>
<MudSnackbarProvider/>
<MudLayout>
<MudAppBar Elevation="0" Dense="true">
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start"
OnClick="@(_ => DrawerToggle())"/>
<MudSpacer/>
<MudTooltip Duration="1000" Text="Powered by MudBlazor">
<MudIconButton Icon="@Icons.Custom.Brands.MudBlazor" Color="Color.Inherit"
Link="https://mudblazor.com/" Target="_blank"/>
</MudTooltip>
<MudTooltip Duration="1000" Text="Github Repository">
<MudIconButton Icon="@Icons.Custom.Brands.GitHub" Color="Color.Inherit"
Link="https://github.com/asesidaa/GC-local-server-rewrite/" Target="_blank"/>
</MudTooltip>
<MudTooltip Duration="1000" Text="@(IsDarkMode ? "Switch to Light Mode" : "Switch to DarkMode")">
<MudToggleIconButton @bind-Toggled="@IsDarkMode"
Icon="@Icons.Material.Outlined.DarkMode" Color="Color.Inherit"
ToggledIcon="@Icons.Material.Filled.LightMode"/>
</MudTooltip>
</MudAppBar>
<MudDrawer @bind-Open="drawerOpen" Elevation="1">
<MudDrawerHeader>
<MudText Typo="Typo.h6">GC Local Server WebUI</MudText>
</MudDrawerHeader>
<NavMenu/>
</MudDrawer>
<MudMainContent>
<MudContainer MaxWidth="MaxWidth.Large" Class="my-16 pt-16">
@Body
</MudContainer>
</MudMainContent>
</MudLayout>
@code {
bool drawerOpen = true;
public bool IsDarkMode { get; set; }
public MudThemeProvider MudThemeProvider { get; set; } = null!;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
IsDarkMode = await MudThemeProvider.GetSystemPreference();
StateHasChanged();
}
}
void DrawerToggle()
{
drawerOpen = !drawerOpen;
}
}