@using System.Text;
@inherits LayoutComponentBase
@inject NavigationManager navigator
@inject Blazored.LocalStorage.ILocalStorageService localStorage

<MudLayout>
    <MudAppBar Elevation="0">
        @if (Program.CCharsLeft > 0)
        {
            <MudButton OnClick="()=>{navigator.NavigateTo(string.Empty); Program.CCharsLeft = 0;}" Variant="Variant.Outlined" Color="Color.Primary">Back</MudButton>
            <MudText Class="pl-8">@("CChars left: " + Program.CCharsLeft)</MudText>
        }
        <MudSpacer />
        <MudIconButton Icon="@Icons.Custom.Brands.MudBlazor" Color="Color.Inherit" Link="https://mudblazor.com/" Target="_blank" />
        <MudIconButton Icon="@Icons.Custom.Brands.LinkedIn" Color="Color.Inherit" Link="https://www.linkedin.com/in/zhentao-wei-3a3a0a182/" Target="_blank" />
    </MudAppBar>
    <MudMainContent>
        <MudContainer MaxWidth="MaxWidth.Large" Style="height: 90vh;" Class="pt-2">
            @Body
        </MudContainer>
    </MudMainContent>
</MudLayout>

@code {
    protected override async Task OnInitializedAsync()
    {
        Program.UpdateUiEvent += OnUiUpdate;
    }

    void OnUiUpdate() => StateHasChanged();
}