<base:RecommendPageBase
    x:Class="Bili.App.Pages.Xbox.RecommendPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
    xmlns:app="using:Bili.App.Controls.App"
    xmlns:base="using:Bili.App.Pages.Base"
    xmlns:behaviors="using:Bili.App.Behaviors"
    xmlns:controls="using:Bili.App.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:loc="using:Bili.App.Resources.Extension"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:pgc="using:Bili.ViewModels.Interfaces.Pgc"
    xmlns:pgc1="using:Bili.App.Controls.Pgc"
    xmlns:selector="using:Bili.App.Resources.Selector"
    xmlns:video="using:Bili.ViewModels.Interfaces.Video"
    xmlns:videos="using:Bili.App.Controls.Videos"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    IsTabStop="False"
    mc:Ignorable="d">

    <base:RecommendPageBase.Resources>
        <DataTemplate x:Key="VideoTemplate" x:DataType="video:IVideoItemViewModel">
            <videos:VideoItem
                Style="{StaticResource XboxVerticalVideoItemStyle}"
                IsCustom="True"
                ViewModel="{x:Bind}" />
        </DataTemplate>

        <DataTemplate x:Key="EpisodeTemplate" x:DataType="pgc:IEpisodeItemViewModel">
            <pgc1:EpisodeItem ViewModel="{x:Bind}" />
        </DataTemplate>

        <selector:RecommendDataTemplateSelector
            x:Key="Selector"
            EpisodeTemplate="{StaticResource EpisodeTemplate}"
            VideoTemplate="{StaticResource VideoTemplate}" />
    </base:RecommendPageBase.Resources>

    <Grid>
        <Grid RowSpacing="12">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <app:PageHeader
                Title="{loc:Locale Name=Recommend}"
                IsShowLogo="True"
                IsTabStop="False" />
            <ScrollViewer
                x:Name="ContentScrollViewer"
                Grid.Row="1"
                Padding="{x:Bind CoreViewModel.PageHorizontalPadding, Converter={StaticResource HorizontalThicknessConverter}, Mode=OneWay}"
                HorizontalScrollMode="Disabled"
                IsTabStop="False"
                VerticalScrollBarVisibility="Auto"
                Visibility="{x:Bind ViewModel.IsReloading, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
                <controls:VerticalRepeaterView
                    x:Name="VideoView"
                    Margin="0,0,0,12"
                    HeaderVisibility="Collapsed"
                    IsTabStop="False"
                    ItemTemplate="{StaticResource Selector}"
                    ItemsSource="{x:Bind ViewModel.Items}"
                    MinWideItemHeight="220">
                    <Interactivity:Interaction.Behaviors>
                        <behaviors:InitializeBehavior />
                        <behaviors:IncrementalBehavior />
                    </Interactivity:Interaction.Behaviors>
                </controls:VerticalRepeaterView>
            </ScrollViewer>
        </Grid>

        <controls:OverlayLoadingPanel IsBarActive="{x:Bind ViewModel.IsIncrementalLoading, Mode=OneWay}" IsRingActive="{x:Bind ViewModel.IsReloading, Mode=OneWay}" />

        <controls:ErrorPanel
            x:Name="ErrorPanel"
            ActionContent="{loc:Locale Name=Refresh}"
            Text="{x:Bind ViewModel.ErrorText, Mode=OneWay}"
            Visibility="{x:Bind ViewModel.IsError, Mode=OneWay}">
            <Interactivity:Interaction.Behaviors>
                <behaviors:ReloadBehavior />
            </Interactivity:Interaction.Behaviors>
        </controls:ErrorPanel>
    </Grid>
</base:RecommendPageBase>
