@inherits LayoutComponentBase
@inject NavMenuService navMenuService
@using Blazored.Toast.Configuration

<div class="page @GetMode()">
    <AuthorizeView>
        <Authorized>
            <div class="sidebar" style="@MinimizeMenuCss">
                <NavMenu  MinStatus="ToggleMinNavMenu"/>
            </div>
        </Authorized>
    </AuthorizeView>
    <main>
        <AuthorizeView>
            <Authorized>
                <div class="container-fluid" style="background-color: rgba(39, 54, 97, 0.5);">
                    <div class="row">
                        <div class="top-row px-1">
                            <div class="col-md-4" style="zoom:50%">
                                <PhToggle ToggleStateChanged="OnChangeToggleSwitchState" ToggleState=@state >
                                    <i class="fas fa-moon fa-2xl"/>
                                </PhToggle>
                            </div>
                            <div class="col-md-8" style="text-align: right;">
                                <PhLoginState/>
                            </div>
                        </div>
                    </div>
                </div>
            </Authorized>
        </AuthorizeView>
        <article class="content px-4">
            @Body
        </article>
    </main>
</div>

<BlazoredToasts Position="ToastPosition.BottomRight"
                Timeout="3"
                IconType="IconType.FontAwesome"
                SuccessClass="success-toast-override"
                SuccessIcon="fa fa-thumbs-up"
                ErrorIcon="fa fa-ban" />
@code {
    private bool state=false;
    private string MinimizeMenuCss => navMenuService.Minimized ? "width:82px" : string.Empty;
    protected void ToggleMinNavMenu(bool status)
    {
        navMenuService.Minimized = status;
    }
    private void OnChangeToggleSwitchState(bool value)
    {
        state = value;
    }
    private string GetMode()
    {
        if (state )
        {
            return "dark-mode";
        }
        else
        {
            return string.Empty;
        }
    }
}