<?xml version="1.0" encoding="utf-8" ?>
<local:PopularPageBase
    x:Class="Bili.Workspace.Pages.PopularPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:app="using:Bili.Workspace.Controls.App"
    xmlns:core="using:Bili.ViewModels.Interfaces.Video"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ext="using:Bili.Workspace.Resources.Extension"
    xmlns:local="using:Bili.Workspace.Pages"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <app:PageHeader Title="{ext:Locale Name=Popular}" RefreshCommand="{x:Bind ViewModel.ReloadCommand}" />
            <ScrollViewer
                x:Name="ContentScrollViewer"
                Grid.Row="1"
                HorizontalScrollMode="Disabled"
                VerticalScrollBarVisibility="Auto"
                Visibility="{x:Bind ViewModel.IsReloading, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
                <app:VerticalRepeaterView
                    x:Name="VideoView"
                    Margin="20,0,20,16"
                    HeaderVisibility="Collapsed"
                    ItemsSource="{x:Bind ViewModel.Items}"
                    RequestLoadMore="OnVideoViewRequestLoadMore">
                    <app:VerticalRepeaterView.ItemTemplate>
                        <DataTemplate x:DataType="core:IVideoItemViewModel">
                            <app:VideoItem ViewModel="{x:Bind}" />
                        </DataTemplate>
                    </app:VerticalRepeaterView.ItemTemplate>
                </app:VerticalRepeaterView>
            </ScrollViewer>
        </Grid>

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

        <app:ErrorPanel
            x:Name="ErrorPanel"
            ActionButtonClick="OnErrorPanelButtonClick"
            ActionContent="{ext:Locale Name=Refresh}"
            Text="{x:Bind ViewModel.ErrorText, Mode=OneWay}"
            Visibility="{x:Bind ViewModel.IsError, Mode=OneWay}" />
    </Grid>
</local:PopularPageBase>
