<?xml version="1.0" encoding="utf-8" ?>
<local:PopularPageControlBase
    x:Class="BiliCopilot.UI.Controls.Popular.PopularSideBody"
    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:components="using:BiliCopilot.UI.Controls.Components"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:extensions="using:BiliCopilot.UI.Extensions"
    xmlns:items="using:BiliCopilot.UI.ViewModels.Items"
    xmlns:local="using:BiliCopilot.UI.Controls.Popular"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <UserControl.Resources>
        <DataTemplate x:Key="SectionTemplate" x:DataType="items:PopularSectionItemViewModel">
            <local:PopularSectionItemControl ViewModel="{x:Bind}" />
        </DataTemplate>
        <DataTemplate x:Key="PartitionTemplate" x:DataType="items:PopularRankPartitionViewModel">
            <local:PopularRankParitionItemControl ViewModel="{x:Bind}" />
        </DataTemplate>
        <extensions:PopularSectionTemplateSelector
            x:Key="SectionSelector"
            PartitionTemplate="{StaticResource PartitionTemplate}"
            SectionTemplate="{StaticResource SectionTemplate}" />
    </UserControl.Resources>

    <Grid>
        <ItemsView
            x:Name="SectionView"
            Padding="2,8,8,8"
            ItemsSource="{x:Bind ViewModel.Sections}"
            ScrollViewer.HorizontalScrollMode="Disabled"
            ScrollViewer.VerticalScrollBarVisibility="Auto"
            SelectionMode="Single">
            <ItemsView.ItemTemplate>
                <DataTemplate x:DataType="items:IPopularSectionItemViewModel">
                    <ItemContainer
                        Height="40"
                        Margin="8,0"
                        Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
                        Style="{StaticResource AppItemContainerStyle}">
                        <ContentControl
                            Padding="12,0"
                            VerticalAlignment="Center"
                            Content="{x:Bind}"
                            ContentTemplateSelector="{StaticResource SectionSelector}" />
                    </ItemContainer>
                </DataTemplate>
            </ItemsView.ItemTemplate>
            <ItemsView.Layout>
                <StackLayout Spacing="8" />
            </ItemsView.Layout>
        </ItemsView>
        <components:SideBottomLoadingWidget
            VerticalAlignment="Bottom"
            Text="{extensions:Locale Name=GettingPartitions}"
            Visibility="{x:Bind ViewModel.IsPartitionLoading, Mode=OneWay}" />
        <animations:Implicit.ShowAnimations>
            <animations:TranslationAnimation
                From="-20,0"
                To="0,0"
                Duration="0:0:0.24" />
            <animations:OpacityAnimation
                From="0.0"
                To="1.0"
                Duration="0:0:0.2" />
        </animations:Implicit.ShowAnimations>
        <animations:Implicit.HideAnimations>
            <animations:TranslationAnimation
                From="0,0"
                To="-20,0"
                Duration="0:0:0.24" />
            <animations:OpacityAnimation
                From="1.0"
                To="0.0"
                Duration="0:0:0.2" />
        </animations:Implicit.HideAnimations>
    </Grid>
</local:PopularPageControlBase>
