@inherits LayoutComponentBase
@using DxBlazorApplication2.Services
@inject NavigationManager NavigationManager
@inject DxThemesService ThemesService

<div class="page">
    <Drawer DrawerHeader="drawerHeader" DrawerFooter="drawerFooter">
        <DrawerBody>
            <div class="w-100">
                <NavMenu></NavMenu>
            </div>
        </DrawerBody>
        <DrawerTarget>
            <div class="nav-buttons-container">
                <NavLink href="@UrlGenerator.GetUrl(new Uri(NavigationManager.Uri).LocalPath, !ToggledSidebar)">
                    <DxButton RenderStyle="@(ThemesService.IsActiveThemeDark ? ButtonRenderStyle.Light : ButtonRenderStyle.Dark)" RenderStyleMode="@ButtonRenderStyleMode.Text" CssClass="menu-button" IconCssClass="icon icon-menu"></DxButton>
                </NavLink>
                @if (new Uri(NavigationManager.Uri).LocalPath != "/") {
                    <NavLink href="@UrlGenerator.GetUrl("/", ToggledSidebar)" class="button-link hidden">
                        <DxButton RenderStyle="@(ThemesService.IsActiveThemeDark ? ButtonRenderStyle.Light : ButtonRenderStyle.Dark)" Text="Back to Home" RenderStyleMode="@ButtonRenderStyleMode.Text" CssClass="menu-button-nav" IconCssClass="icon icon-back"></DxButton>
                    </NavLink>
                }
                @if (new Uri(NavigationManager.Uri).LocalPath.ToLower().StartsWith("/produktion/aufträgeprolinie"))
                {
                    <NavLink href="@UrlGenerator.GetUrl("/produktion/cockpit", ToggledSidebar)" class="button-link hidden">
                        <DxButton RenderStyle="@(ThemesService.IsActiveThemeDark? ButtonRenderStyle.Light: ButtonRenderStyle.Dark)" Text="Zurück zum Cockpit" RenderStyleMode="@ButtonRenderStyleMode.Text" CssClass="menu-button-nav" IconCssClass="icon icon-back"></DxButton>
                    </NavLink>
                }
            </div>
            <div class="p-4">
                @Body
            </div>
        </DrawerTarget>
    </Drawer>
</div>

@code {
    [SupplyParameterFromQuery(Name = UrlGenerator.ToggleSidebarName)]
    public bool ToggledSidebar { get; set; }

    private RenderFragment drawerHeader => @<div class="navigation-drawer-header">
        <img class="logo" src="images/logo.svg" alt="DevExpress logo" />
        <NavLink href="@UrlGenerator.GetUrl(new Uri(NavigationManager.Uri).LocalPath, !ToggledSidebar)">
            <DxButton RenderStyle="@(ThemesService.IsBootstrapDarkActive ? ButtonRenderStyle.Dark : ButtonRenderStyle.Light)" RenderStyleMode="@ButtonRenderStyleMode.Text" CssClass="menu-button-nav" IconCssClass="@(ToggledSidebar ? "icon icon-close" : "icon icon-menu")"></DxButton>
        </NavLink>
    </div>;

    private RenderFragment drawerFooter => @<div>
        <NavLink href="https://docs.devexpress.com/Blazor/400725/blazor-components" class="button-link">
            <DxButton Text="Docs" RenderStyleMode="@ButtonRenderStyleMode.Text" CssClass="footer-button" RenderStyle="ButtonRenderStyle.Light" IconCssClass="icon docs-icon"></DxButton>
        </NavLink>
        <NavLink href="https://demos.devexpress.com/blazor/" class="button-link">
            <DxButton Text="Demos" RenderStyleMode="@ButtonRenderStyleMode.Text" CssClass="footer-button" RenderStyle="ButtonRenderStyle.Light" IconCssClass="icon demos-icon"></DxButton>
        </NavLink>
    </div>;

 
}