<?xml version="1.0" encoding="utf-8"?>
<Window
    x:Class="Sonex.Client.AppWindows.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Sonex.Client"
    xmlns:sc="using:Sonex.Client.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:helpers="using:Sonex.Client.Helpers"
    mc:Ignorable="d"
    xmlns:ic="using:FluentIcons.WinUI"
    Title="Sonex">
    <Window.SystemBackdrop>
        <MicaBackdrop />
    </Window.SystemBackdrop>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <TitleBar
            x:Name="titleBar"
            BackRequested="TitleBar_BackRequested"
            IsBackButtonVisible="{x:Bind navFrame.CanGoBack, Mode=OneWay}"
            IsPaneToggleButtonVisible="True"
            PaneToggleRequested="TitleBar_PaneToggleRequested"
            Margin="0"
            Padding="0"
            VerticalAlignment="Top"
            HorizontalContentAlignment="Left"
            VerticalContentAlignment="Top"
            >


            <!--  This is a workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/10374, once fixed we should just be using IconSource  -->
            <!--<TitleBar.IconSource >
                <ImageIconSource ImageSource="/Assets/sonex_logo.svg" />
            </TitleBar.IconSource>-->
            <TitleBar.LeftHeader>
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Spacing="8">
                    <Image Source="/Assets/sonex_logo.svg"  Height="22" Margin="8 0 0 0"/>
                </StackPanel>
            </TitleBar.LeftHeader>

            <TitleBar.Content>
                <AutoSuggestBox QueryIcon="Find" PlaceholderText="Search..." Width="300">
                </AutoSuggestBox>
            </TitleBar.Content>
            <TitleBar.RightHeader>
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Spacing="8" HorizontalAlignment="Right">
                    <PersonPicture Width="30" Height="30" Initials="SJ" />
                    <Border VerticalAlignment="Center">
                        <TextBlock Text="Samuel Jendryke"/>
                    </Border>

                </StackPanel>
            </TitleBar.RightHeader>
        </TitleBar>
        <NavigationView
            x:Name="navView"
            Grid.Row="1"
            IsBackButtonVisible="Collapsed"
            
            IsPaneToggleButtonVisible="False"
            IsSettingsVisible="False"
            SelectionChanged="navView_SelectionChanged">


            <NavigationView.MenuItems>
                <!-- Nested NavigationViewItem for Home with submenu -->
                <NavigationViewItem Content="Home" SelectsOnInvoked="False">
                    <NavigationViewItem.MenuItems>
                        <NavigationViewItem Content="Title Sample" Tag="TitleSample"/>
                        <NavigationViewItem Content="Title Sample" Tag="TitleSample"/>
                        <NavigationViewItem Content="Table Sample" Tag="TableSample"/>
                    </NavigationViewItem.MenuItems>
                </NavigationViewItem>
                <!-- END -->
                <NavigationViewItem Content="Menu Item2"  Icon="Save" Tag="BlankPage2" />
                <NavigationViewItem Content="Menu Item3"  Icon="Refresh" Tag="BlankPage3" />
                <NavigationViewItem Content="Menu Item4"  Icon="Download"       Tag="BlankPage43" />


                <NavigationViewItemSeparator/>
                <NavigationViewItemHeader Content="Administrator"/>
                <sc:NavigationViewImageItem Content="Access Control" IconPath="Assets/icons8/icons8-user-shield-48.png" Tag="Administrator.Users.Users" SelectsOnInvoked="False">
                    <NavigationViewItem.MenuItems>
                        <sc:NavigationViewImageItem Content="Accounts"  IconPath="Assets/icons8/icons8-person-48.png" Tag="Administrator.Accounts.Accounts"/>
                        <sc:NavigationViewImageItem Content="Groups"  IconPath="Assets/icons8/icons8-group-48.png"  Tag="Administrator.Accounts.Accounts"/>
                        <sc:NavigationViewImageItem Content="Permissions"  IconPath="Assets/icons8/icons8-access-48.png"  Tag="Administrator.Accounts.Accounts"/>

                    </NavigationViewItem.MenuItems>
                </sc:NavigationViewImageItem>



            </NavigationView.MenuItems>


            <Frame x:Name="navFrame" IsNavigationStackEnabled="False" >
                <Frame.ContentTransitions>
                    <TransitionCollection>
                        <NavigationThemeTransition  />
                    </TransitionCollection>
                </Frame.ContentTransitions>
            </Frame>

        </NavigationView>
    </Grid>
</Window>
