<Page
    x:Class="WslSettings.Views.OOBE.ShellPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:animations="using:CommunityToolkit.WinUI.Animations"
    xmlns:helpers="using:WslSettings.Helpers"
    xmlns:behaviors="using:WslSettings.Behaviors"
    xmlns:i="using:Microsoft.Xaml.Interactivity"
    Loaded="OnLoaded">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Button
            x:Name="PaneToggleBtn"
            Width="48"
            HorizontalAlignment="Left"
            VerticalAlignment="Center"
            Click="PaneToggleBtn_Click"
            Style="{StaticResource PaneToggleButtonStyle}" />
        <Grid Grid.Row="0"
              x:Name="AppTitleBar"
              Margin="16,0"
              Canvas.ZIndex="1"
              Height="{Binding ElementName=NavigationViewControl, Path=CompactPaneLength}"
              IsHitTestVisible="True"
              VerticalAlignment="Top"
              HorizontalAlignment="Stretch">
              <animations:Implicit.Animations>
                  <animations:OffsetAnimation Duration="0:0:0.3" />
              </animations:Implicit.Animations>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Image Grid.Column="0"
                   Source="/Assets/wsl.ico"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Left"
                   Width="16"
                   Height="16" />
            <TextBlock Grid.Column="1"
                       x:Name="AppTitleBarText"
                       VerticalAlignment="Center"
                       TextWrapping="NoWrap"
                       Style="{StaticResource CaptionTextBlockStyle}"
                       Margin="16,0,0,0"/>
        </Grid>
        <NavigationView
            Grid.Row="1"
            x:Name="NavigationViewControl"
            Canvas.ZIndex="0"
            DisplayModeChanged="NavigationViewControl_DisplayModeChanged"
            Header="{x:Bind ((ContentControl)ViewModel.Selected).Content, Mode=OneWay}"
            IsBackButtonVisible="Collapsed"
            IsBackEnabled="{x:Bind ViewModel.IsBackEnabled, Mode=OneWay}"
            IsPaneOpen="True"
            IsPaneToggleButtonVisible="False"
            IsSettingsVisible="False"
            ItemInvoked="NavigationViewControl_ItemInvoked"
            OpenPaneLength="296"
            PaneDisplayMode="Left"
            SelectedItem="{x:Bind ViewModel.Selected, Mode=OneWay}">
            <NavigationView.MenuItems>
                <!--
                TODO: Update item titles by updating <x:Uid>.Content entries in Strings/en-us/Resources.resw.
                https://docs.microsoft.com/windows/uwp/app-resources/localize-strings-ui-manifest#refer-to-a-string-resource-identifier-from-xaml
            
                TODO: Update item icons by updating FontIcon.Glyph properties.
                https://docs.microsoft.com/windows/apps/design/style/segoe-fluent-icons-font#icon-list
                -->
                <NavigationViewItem x:Uid="Settings_Shell_General" helpers:NavigationHelper.NavigateTo="WslSettings.ViewModels.OOBE.GeneralViewModel">
                    <NavigationViewItem.Icon>
                        <BitmapIcon ShowAsMonochrome="False" UriSource="/Assets/wslbw.ico" />
                    </NavigationViewItem.Icon>
                </NavigationViewItem>
                <NavigationViewItem x:Uid="Settings_Shell_WorkingAcrossFileSystems" helpers:NavigationHelper.NavigateTo="WslSettings.ViewModels.OOBE.WorkingAcrossFileSystemsViewModel">
                    <NavigationViewItem.Icon>
                        <BitmapIcon ShowAsMonochrome="False" UriSource="/Assets/SettingsOOBEFileExplorerIcon.png" />
                    </NavigationViewItem.Icon>
                </NavigationViewItem>
                <NavigationViewItem x:Uid="Settings_Shell_GUIApps" helpers:NavigationHelper.NavigateTo="WslSettings.ViewModels.OOBE.GUIAppsViewModel">
                    <NavigationViewItem.Icon>
                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xED35;"/>
                    </NavigationViewItem.Icon>
                </NavigationViewItem>
                <NavigationViewItem x:Uid="Settings_Shell_GPUAcceleration" helpers:NavigationHelper.NavigateTo="WslSettings.ViewModels.OOBE.GPUAccelerationViewModel">
                    <NavigationViewItem.Icon>
                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE964;"/>
                    </NavigationViewItem.Icon>
                </NavigationViewItem>
                <NavigationViewItem x:Uid="Settings_Shell_NetworkingIntegration" helpers:NavigationHelper.NavigateTo="WslSettings.ViewModels.OOBE.NetworkingIntegrationViewModel">
                    <NavigationViewItem.Icon>
                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE88A;"/>
                    </NavigationViewItem.Icon>
                </NavigationViewItem>
                <NavigationViewItem x:Uid="Settings_Shell_DistroManagement" helpers:NavigationHelper.NavigateTo="WslSettings.ViewModels.OOBE.DistroManagementViewModel">
                    <NavigationViewItem.Icon>
                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE912;"/>
                    </NavigationViewItem.Icon>
                </NavigationViewItem>
                <NavigationViewItemSeparator/>
                <NavigationViewItem x:Uid="Settings_Shell_DockerDesktopIntegration" helpers:NavigationHelper.NavigateTo="WslSettings.ViewModels.OOBE.DockerDesktopIntegrationViewModel">
                    <NavigationViewItem.Icon>
                        <BitmapIcon ShowAsMonochrome="False" UriSource="/Assets/SettingsOOBEDockerIcon.png" />
                    </NavigationViewItem.Icon>
                </NavigationViewItem>
                <NavigationViewItem x:Uid="Settings_Shell_VSCodeIntegration" helpers:NavigationHelper.NavigateTo="WslSettings.ViewModels.OOBE.VSCodeIntegrationViewModel">
                    <NavigationViewItem.Icon>
                        <BitmapIcon ShowAsMonochrome="False" UriSource="/Assets/SettingsOOBEVSCodeIcon.png" />
                    </NavigationViewItem.Icon>
                </NavigationViewItem>
                <NavigationViewItem x:Uid="Settings_Shell_VSIntegration" helpers:NavigationHelper.NavigateTo="WslSettings.ViewModels.OOBE.VSIntegrationViewModel">
                    <NavigationViewItem.Icon>
                        <BitmapIcon ShowAsMonochrome="False" UriSource="/Assets/SettingsOOBEVSIcon.png" />
                    </NavigationViewItem.Icon>
                </NavigationViewItem>
            </NavigationView.MenuItems>
            <NavigationView.FooterMenuItems>
                <!--
                TODO: Update item titles by updating <x:Uid>.Content entries in Strings/en-us/Resources.resw.
                https://docs.microsoft.com/windows/uwp/app-resources/localize-strings-ui-manifest#refer-to-a-string-resource-identifier-from-xaml
            
                TODO: Update item icons by updating FontIcon.Glyph properties.
                https://docs.microsoft.com/windows/apps/design/style/segoe-fluent-icons-font#icon-list
                -->
                <NavigationViewItem x:Uid="Settings_Shell_WhatsNew" Visibility="Collapsed">
                    <NavigationViewItem.Icon>
                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE789;"/>
                    </NavigationViewItem.Icon>
                </NavigationViewItem>
                <NavigationViewItem x:Uid="Settings_Shell_Settings" Tag="Settings" SelectsOnInvoked="False">
                    <NavigationViewItem.Icon>
                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xe713;"/>
                    </NavigationViewItem.Icon>
                </NavigationViewItem>
            </NavigationView.FooterMenuItems>
            <NavigationView.HeaderTemplate>
                <DataTemplate>
                    <Grid>
                        <TextBlock
                            Text="{Binding}"
                            Style="{ThemeResource TitleTextBlockStyle}" />
                    </Grid>
                </DataTemplate>
            </NavigationView.HeaderTemplate>
            <i:Interaction.Behaviors>
                <behaviors:NavigationViewHeaderBehavior
                    DefaultHeader="{x:Bind ((ContentControl)ViewModel.Selected).Content, Mode=OneWay}">
                    <behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
                        <DataTemplate>
                            <Grid>
                                <TextBlock
                                    Text="{Binding}"
                                    Style="{ThemeResource TitleTextBlockStyle}" />
                            </Grid>
                        </DataTemplate>
                    </behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
                </behaviors:NavigationViewHeaderBehavior>
            </i:Interaction.Behaviors>
            <Grid>
                <Frame x:Name="NavigationFrame" />
            </Grid>
        </NavigationView>

        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="LayoutVisualStates">
                <VisualState x:Name="WideLayout">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="720" />
                    </VisualState.StateTriggers>
                </VisualState>
                <VisualState x:Name="SmallLayout">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="600" />
                        <AdaptiveTrigger MinWindowWidth="0" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="NavigationViewControl.PaneDisplayMode" Value="LeftMinimal" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</Page>
