<?xml version="1.0" encoding="utf-8" ?>
<local:ViewLaterPageControlBase
    x:Class="BiliCopilot.UI.Controls.ViewLater.ViewLaterHeader"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    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.ViewLater"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Padding="16,0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <StackPanel Orientation="Horizontal" Spacing="12">
            <TextBlock
                VerticalAlignment="Center"
                Style="{StaticResource BodyStrongTextBlockStyle}"
                Text="{ext:Locale Name=ViewLater}" />
            <InfoBadge
                VerticalAlignment="Center"
                Style="{StaticResource InformationalValueInfoBadgeStyle}"
                ToolTipService.ToolTip="{ext:Locale Name=Total}"
                Visibility="{x:Bind ViewModel.TotalCount, Mode=OneWay, Converter={StaticResource ObjectToVisibilityConverter}}"
                Value="{x:Bind ViewModel.TotalCount, Mode=OneWay}" />
        </StackPanel>

        <StackPanel
            Grid.Column="2"
            VerticalAlignment="Center"
            Orientation="Horizontal"
            Spacing="8">
            <Button
                VerticalAlignment="Center"
                AutomationProperties.Name="{ext:Locale Name=Refresh}"
                Command="{x:Bind ViewModel.RefreshCommand}"
                IsEnabled="{x:Bind ViewModel.IsLoading, Mode=OneWay, Converter={StaticResource ObjectToBoolReverseConverter}}">
                <StackPanel Orientation="Horizontal" Spacing="8">
                    <ic:SymbolIcon
                        VerticalAlignment="Center"
                        FontSize="12"
                        Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
                        Symbol="ArrowSync" />
                    <TextBlock VerticalAlignment="Center" Text="{ext:Locale Name=Refresh}" />
                </StackPanel>
            </Button>
            <Button
                VerticalAlignment="Center"
                AutomationProperties.Name="{ext:Locale Name=PlayAll}"
                Command="{x:Bind ViewModel.PlayAllCommand}"
                IsEnabled="{x:Bind ViewModel.IsEmpty, Mode=OneWay, Converter={StaticResource ObjectToBoolReverseConverter}}">
                <StackPanel Orientation="Horizontal" Spacing="8">
                    <ic:SymbolIcon
                        VerticalAlignment="Center"
                        FontSize="12"
                        Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
                        Symbol="NavigationPlay" />
                    <TextBlock VerticalAlignment="Center" Text="{ext:Locale Name=PlayAll}" />
                </StackPanel>
            </Button>
            <Button
                x:Name="CleanButton"
                VerticalAlignment="Center"
                AutomationProperties.Name="{ext:Locale Name=ClearViewLater}"
                Click="OnCleanButtonClick"
                IsEnabled="{x:Bind ViewModel.IsEmpty, Mode=OneWay, Converter={StaticResource ObjectToBoolReverseConverter}}">
                <StackPanel Orientation="Horizontal" Spacing="8">
                    <ic:SymbolIcon
                        VerticalAlignment="Center"
                        FontSize="12"
                        Foreground="{ThemeResource SystemFillColorCriticalBrush}"
                        Symbol="DeleteLines" />
                    <TextBlock VerticalAlignment="Center" Text="{ext:Locale Name=ClearViewLater}" />
                </StackPanel>
            </Button>
        </StackPanel>

        <TeachingTip
            x:Name="CleanTip"
            ActionButtonCommand="{x:Bind ViewModel.ClearAllCommand}"
            ActionButtonContent="{ext:Locale Name=Clean}"
            IsLightDismissEnabled="True"
            PreferredPlacement="BottomLeft"
            ShouldConstrainToRootBounds="False"
            Subtitle="{ext:Locale Name=ClearViewLaterWarning}"
            Target="{x:Bind CleanButton}" />
    </Grid>
</local:ViewLaterPageControlBase>
