<base:NavigationViewBase
    x:Class="Bili.App.Controls.App.XboxNavigationView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:base="using:Bili.App.Controls.Base"
    xmlns:controls="using:Bili.App.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ext="using:Bili.App.Resources.Extension"
    xmlns:icons="using:Richasy.FluentIcon.Uwp"
    xmlns:loc="using:Bili.App.Resources.Extension"
    xmlns:local="using:Bili.App.Controls.App"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
    d:DesignHeight="300"
    d:DesignWidth="400"
    mc:Ignorable="d">

    <base:NavigationViewBase.Resources>
        <Style x:Key="BiliNavigationViewStyle" TargetType="muxc:NavigationView">
            <Setter Property="IsPaneToggleButtonVisible" Value="False" />
            <Setter Property="IsBackButtonVisible" Value="Collapsed" />
            <Setter Property="OpenPaneLength" Value="240" />
            <Setter Property="IsTitleBarAutoPaddingEnabled" Value="False" />
        </Style>
    </base:NavigationViewBase.Resources>

    <Grid>
        <muxc:NavigationView
            x:Name="RootNavView"
            Style="{StaticResource BiliNavigationViewStyle}"
            ItemInvoked="OnRootNavViewItemInvokedAsync"
            LosingFocus="OnRootNavViewLosingFocus"
            NoFocusCandidateFound="OnRootNavViewNoFocusCandidateFound"
            PaneDisplayMode="LeftCompact"
            XYFocusKeyboardNavigation="Enabled">
            <muxc:NavigationView.MenuItems>
                <muxc:NavigationViewItem
                    x:Name="SignInItem"
                    Content="{loc:Locale Name=SignIn}"
                    IsEnabled="{x:Bind AccountViewModel.TrySignInCommand.IsRunning, Mode=OneWay, Converter={StaticResource ObjectToBoolReverseConverter}}"
                    Visibility="{x:Bind AccountViewModel.IsConnected, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
                    <muxc:NavigationViewItem.Icon>
                        <icons:RegularFluentIcon Symbol="Person16" />
                    </muxc:NavigationViewItem.Icon>
                </muxc:NavigationViewItem>
                <muxc:NavigationViewItem
                    x:Name="AccountItem"
                    ext:NavigationExtension.PageId="XboxAccount"
                    Visibility="{x:Bind AccountViewModel.IsConnected, Mode=OneWay}">
                    <StackPanel Orientation="Horizontal" Spacing="12">
                        <controls:CommonImageEx
                            Width="24"
                            Height="24"
                            VerticalAlignment="Center"
                            CornerRadius="12"
                            ImageUrl="{x:Bind AccountViewModel.Avatar, Mode=OneWay}" />
                        <TextBlock VerticalAlignment="Center" Text="{x:Bind AccountViewModel.DisplayName, Mode=OneWay}" />
                    </StackPanel>
                </muxc:NavigationViewItem>
                <muxc:NavigationViewItem ext:NavigationExtension.PageId="PreSearch" Content="{loc:Locale Name=Search}">
                    <muxc:NavigationViewItem.Icon>
                        <icons:RegularFluentIcon Symbol="Search16" />
                    </muxc:NavigationViewItem.Icon>
                </muxc:NavigationViewItem>
                <muxc:NavigationViewItemHeader Content="{loc:Locale Name=Navigation}" />
                <muxc:NavigationViewItem
                    ext:NavigationExtension.PageId="Recommend"
                    Content="{loc:Locale Name=Recommend}"
                    TabIndex="1">
                    <muxc:NavigationViewItem.Icon>
                        <icons:RegularFluentIcon Symbol="Home16" />
                    </muxc:NavigationViewItem.Icon>
                </muxc:NavigationViewItem>
                <muxc:NavigationViewItem ext:NavigationExtension.PageId="Popular" Content="{loc:Locale Name=Popular}">
                    <muxc:NavigationViewItem.Icon>
                        <icons:RegularFluentIcon Symbol="Rocket16" />
                    </muxc:NavigationViewItem.Icon>
                </muxc:NavigationViewItem>
                <muxc:NavigationViewItem ext:NavigationExtension.PageId="Rank" Content="{loc:Locale Name=Rank}">
                    <muxc:NavigationViewItem.Icon>
                        <icons:RegularFluentIcon Symbol="Trophy16" />
                    </muxc:NavigationViewItem.Icon>
                </muxc:NavigationViewItem>
                <muxc:NavigationViewItem ext:NavigationExtension.PageId="VideoPartition" Content="{loc:Locale Name=Partition}">
                    <muxc:NavigationViewItem.Icon>
                        <icons:RegularFluentIcon Symbol="Apps16" />
                    </muxc:NavigationViewItem.Icon>
                </muxc:NavigationViewItem>
                <muxc:NavigationViewItem ext:NavigationExtension.PageId="Live" Content="{loc:Locale Name=Live}">
                    <muxc:NavigationViewItem.Icon>
                        <icons:RegularFluentIcon Symbol="Video16" />
                    </muxc:NavigationViewItem.Icon>
                </muxc:NavigationViewItem>
                <muxc:NavigationViewItem ext:NavigationExtension.PageId="Dynamic" Content="{loc:Locale Name=DynamicFeed}">
                    <muxc:NavigationViewItem.Icon>
                        <icons:RegularFluentIcon Symbol="DesignIdeas16" />
                    </muxc:NavigationViewItem.Icon>
                </muxc:NavigationViewItem>
                <muxc:NavigationViewItemSeparator />

                <muxc:NavigationViewItemHeader Content="{loc:Locale Name=Topic}" />
                <muxc:NavigationViewItem ext:NavigationExtension.PageId="Bangumi" Content="{loc:Locale Name=Bangumi}">
                    <muxc:NavigationViewItem.Icon>
                        <icons:RegularFluentIcon Symbol="Cookies20" />
                    </muxc:NavigationViewItem.Icon>
                </muxc:NavigationViewItem>
                <muxc:NavigationViewItem ext:NavigationExtension.PageId="DomesticAnime" Content="{loc:Locale Name=DomesticAnime}">
                    <muxc:NavigationViewItem.Icon>
                        <icons:RegularFluentIcon Symbol="FastAcceleration24" />
                    </muxc:NavigationViewItem.Icon>
                </muxc:NavigationViewItem>
                <muxc:NavigationViewItem ext:NavigationExtension.PageId="Documentary" Content="{loc:Locale Name=Documentary}">
                    <muxc:NavigationViewItem.Icon>
                        <icons:RegularFluentIcon Symbol="LeafTwo16" />
                    </muxc:NavigationViewItem.Icon>
                </muxc:NavigationViewItem>
                <muxc:NavigationViewItem ext:NavigationExtension.PageId="Movie" Content="{loc:Locale Name=Movie}">
                    <muxc:NavigationViewItem.Icon>
                        <icons:RegularFluentIcon Symbol="MoviesAndTv16" />
                    </muxc:NavigationViewItem.Icon>
                </muxc:NavigationViewItem>
                <muxc:NavigationViewItem ext:NavigationExtension.PageId="TV" Content="{loc:Locale Name=TV}">
                    <muxc:NavigationViewItem.Icon>
                        <icons:RegularFluentIcon Symbol="VideoClip20" />
                    </muxc:NavigationViewItem.Icon>
                </muxc:NavigationViewItem>
            </muxc:NavigationView.MenuItems>

            <muxc:NavigationView.Content>
                <Grid
                    x:Name="MainGrid"
                    Background="{ThemeResource LayerFillColorDefaultBrush}"
                    BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
                    BorderThickness="1,1,0,0"
                    CornerRadius="8,0,0,0"
                    RowSpacing="8">
                    <Frame x:Name="MainFrame" Loaded="OnFrameLoaded" />
                </Grid>
            </muxc:NavigationView.Content>
        </muxc:NavigationView>
    </Grid>
</base:NavigationViewBase>
