<?xml version="1.0" encoding="utf-8" ?>
<local:AnimePageControlBase
    x:Class="BiliCopilot.UI.Controls.Pgc.AnimeMainHeader"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:components="using:BiliCopilot.UI.ViewModels.Components"
    xmlns:converters="using:BiliCopilot.UI.Converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ext="using:BiliCopilot.UI.Extensions"
    xmlns:ic="using:FluentIcons.WinUI"
    xmlns:local="using:BiliCopilot.UI.Controls.Pgc"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <UserControl.Resources>
        <converters:PgcSectionTextConverter x:Key="SectionTextConverter" />
        <DataTemplate x:Key="TimelineTemplate" x:DataType="components:AnimeTimelineViewModel">
            <StackPanel Orientation="Horizontal" Spacing="8">
                <TextBlock
                    VerticalAlignment="Center"
                    Style="{StaticResource BodyStrongTextBlockStyle}"
                    Text="{x:Bind SelectedTimeline.DayOfWeek, Mode=OneWay}" />
                <TextBlock
                    VerticalAlignment="Center"
                    Foreground="{ThemeResource TextFillColorTertiaryBrush}"
                    Style="{StaticResource CaptionTextBlockStyle}"
                    Text="{x:Bind SelectedTimeline.Date, Mode=OneWay}" />
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="IndexTemplate" x:DataType="components:EntertainmentIndexViewModel">
            <StackPanel Orientation="Horizontal" Spacing="8">
                <TextBlock
                    VerticalAlignment="Center"
                    Style="{StaticResource BodyStrongTextBlockStyle}"
                    Text="{x:Bind SectionType, Converter={StaticResource SectionTextConverter}}" />
                <TextBlock
                    VerticalAlignment="Center"
                    Foreground="{ThemeResource TextFillColorTertiaryBrush}"
                    Style="{StaticResource CaptionTextBlockStyle}"
                    Text="{ext:Locale Name=Index}" />
            </StackPanel>
        </DataTemplate>
        <ext:AnimePageControlTemplateSelector
            x:Key="HeaderSelector"
            IndexTemplate="{StaticResource IndexTemplate}"
            TimelineTemplate="{StaticResource TimelineTemplate}" />
    </UserControl.Resources>

    <Grid
        Padding="16,0"
        VerticalAlignment="Center"
        ColumnSpacing="8">
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <ContentControl
            HorizontalAlignment="Left"
            VerticalAlignment="Center"
            Content="{x:Bind ViewModel.SelectedSection, Mode=OneWay}"
            ContentTemplateSelector="{StaticResource HeaderSelector}" />
        <Button
            Grid.Column="1"
            Padding="12,8"
            VerticalAlignment="Center"
            AutomationProperties.Name="{ext:Locale Name=MyFavoriteAnime}"
            Command="{x:Bind ViewModel.ShowMyFavoriteAnimeCommand}">
            <StackPanel Orientation="Horizontal" Spacing="8">
                <ic:SymbolIcon
                    VerticalAlignment="Center"
                    FontSize="14"
                    Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
                    Symbol="Dust" />
                <TextBlock
                    VerticalAlignment="Center"
                    Text="{ext:Locale Name=MyFavoriteAnime}"
                    TextLineBounds="Tight" />
            </StackPanel>
        </Button>
        <Button
            Grid.Column="2"
            Padding="12,8"
            VerticalAlignment="Center"
            AutomationProperties.Name="{ext:Locale Name=Refresh}"
            Command="{x:Bind ViewModel.SelectedSection.RefreshCommand, Mode=OneWay}"
            ToolTipService.ToolTip="{ext:Locale Name=Refresh}">
            <ic:SymbolIcon
                FontSize="14"
                Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
                Symbol="ArrowSync" />
        </Button>
    </Grid>
</local:AnimePageControlBase>
