<base:RankPageBase
    x:Class="Bili.App.Pages.Xbox.RankPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:app="using:Bili.App.Controls.App"
    xmlns:base="using:Bili.App.Pages.Base"
    xmlns:behaviors="using:Bili.App.Behaviors"
    xmlns:community="using:Bili.Models.Data.Community"
    xmlns:controls="using:Bili.App.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
    xmlns:loc="using:Bili.App.Resources.Extension"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
    xmlns:video="using:Bili.ViewModels.Interfaces.Video"
    xmlns:videos="using:Bili.App.Controls.Videos"
    mc:Ignorable="d">

    <interactivity:Interaction.Behaviors>
        <behaviors:InitializeBehavior />
    </interactivity:Interaction.Behaviors>

    <Grid RowSpacing="12">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <app:PageHeader
            Title="{loc:Locale Name=Rank}"
            IsShowLogo="True"
            IsTabStop="False" />
        <muxc:NavigationView
            x:Name="RankNavigationView"
            Style="{StaticResource XboxSideNavigationViewStyle}"
            Grid.Row="1"
            ItemInvoked="OnDetailNavigationViewItemInvoked"
            MenuItemsSource="{x:Bind ViewModel.Partitions}"
            SelectedItem="{x:Bind ViewModel.CurrentPartition, Mode=OneWay}">
            <muxc:NavigationView.MenuItemTemplate>
                <DataTemplate x:DataType="community:Partition">
                    <muxc:NavigationViewItem Content="{x:Bind}">
                        <muxc:NavigationViewItem.ContentTemplate>
                            <DataTemplate x:DataType="community:Partition">
                                <StackPanel Orientation="Horizontal" Spacing="8">
                                    <Image
                                        Width="20"
                                        Height="20"
                                        VerticalAlignment="Center"
                                        Source="{x:Bind Image.Uri}" />
                                    <TextBlock
                                        Style="{StaticResource BodyTextBlockStyle}"
                                        VerticalAlignment="Center"
                                        Text="{x:Bind Name}" />
                                </StackPanel>
                            </DataTemplate>
                        </muxc:NavigationViewItem.ContentTemplate>
                    </muxc:NavigationViewItem>
                </DataTemplate>
            </muxc:NavigationView.MenuItemTemplate>

            <ScrollViewer
                x:Name="ContentScrollViewer"
                Padding="{x:Bind CoreViewModel.PageHorizontalPadding, Converter={StaticResource HorizontalThicknessConverter}, Mode=OneWay}"
                HorizontalScrollMode="Disabled"
                IsTabStop="False"
                VerticalScrollBarVisibility="Auto"
                Visibility="{x:Bind ViewModel.IsError, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
                <controls:VerticalRepeaterView
                    x:Name="VideoView"
                    Margin="20,0,20,12"
                    HeaderVisibility="Collapsed"
                    IsTabStop="False"
                    ItemOrientation="Horizontal"
                    ItemsSource="{x:Bind ViewModel.Videos}"
                    MinWideItemHeight="242"
                    Visibility="{x:Bind ViewModel.IsReloading, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
                    <controls:VerticalRepeaterView.ItemTemplate>
                        <DataTemplate x:DataType="video:IVideoItemViewModel">
                            <videos:VideoItem
                                Style="{StaticResource HorizontalVideoItemStyle}"
                                IsCustom="True"
                                ViewModel="{x:Bind}" />
                        </DataTemplate>
                    </controls:VerticalRepeaterView.ItemTemplate>
                </controls:VerticalRepeaterView>
            </ScrollViewer>

        </muxc:NavigationView>


        <controls:ErrorPanel
            x:Name="ErrorPanel"
            Grid.Row="1"
            ActionContent="{loc:Locale Name=Refresh}"
            IsTabStop="False"
            Text="{x:Bind ViewModel.ErrorText, Mode=OneWay}"
            Visibility="{x:Bind ViewModel.IsError, Mode=OneWay}">
            <interactivity:Interaction.Behaviors>
                <behaviors:ReloadBehavior />
            </interactivity:Interaction.Behaviors>
        </controls:ErrorPanel>

        <muxc:ProgressRing
            x:Name="InitializeRing"
            Style="{StaticResource PageProgressRingStyle}"
            Grid.Row="1"
            IsActive="{x:Bind ViewModel.IsReloading, Mode=OneWay}" />
    </Grid>
</base:RankPageBase>
