<?xml version="1.0" encoding="utf-8" ?>
<local:ArticleReaderPageControlBase
    x:Class="BiliCopilot.UI.Controls.Article.ArticleReaderToolBar"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:base="using:Richasy.WinUIKernel.Share.Base"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ic="using:FluentIcons.WinUI"
    xmlns:local="using:BiliCopilot.UI.Controls.Article"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:media="using:CommunityToolkit.WinUI.Media"
    xmlns:ui="using:CommunityToolkit.WinUI"
    mc:Ignorable="d">

    <UserControl.Resources>
        <media:AttachedCardShadow
            x:Key="CardShadow"
            BlurRadius="12"
            CornerRadius="8"
            InnerContentClipMode="CompositionMaskBrush"
            Opacity="0.08"
            Offset="0,1,2" />
        <Style
            x:Key="IconToggleButtonStyle"
            BasedOn="{StaticResource DefaultToggleButtonStyle}"
            TargetType="ToggleButton">
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="Padding" Value="0" />
            <Setter Property="MinWidth" Value="48" />
            <Setter Property="MinHeight" Value="48" />
        </Style>
    </UserControl.Resources>

    <Grid>
        <Border
            ui:Effects.Shadow="{StaticResource CardShadow}"
            Background="{ThemeResource AcrylicInAppFillColorDefaultBrush}"
            BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
            BorderThickness="1"
            CornerRadius="{StaticResource OverlayCornerRadius}" />
        <StackPanel Padding="12" Spacing="8">
            <Button
                Margin="0,0,0,4"
                Command="{x:Bind ViewModel.ShowUserSpaceCommand, Mode=OneWay}"
                Style="{StaticResource AvatarButtonStyle}">
                <Grid>
                    <PersonPicture
                        Width="48"
                        Height="48"
                        DisplayName="{x:Bind ViewModel.Author, Mode=OneWay}"
                        ProfilePicture="{x:Bind ViewModel.Avatar, Mode=OneWay, Converter={StaticResource BitmapConverter}}"
                        ToolTipService.ToolTip="{x:Bind ViewModel.Author, Mode=OneWay}" />
                    <Image
                        Width="16"
                        HorizontalAlignment="Right"
                        VerticalAlignment="Bottom"
                        Source="ms-appx:///Assets/vip.png"
                        Visibility="{x:Bind ViewModel.IsVip, Mode=OneWay}" />
                </Grid>
            </Button>

            <ToggleButton
                Command="{x:Bind ViewModel.ToggleLikeCommand, Mode=OneWay}"
                IsChecked="{x:Bind ViewModel.IsLiked, Mode=OneWay}"
                Style="{StaticResource IconToggleButtonStyle}">
                <StackPanel Spacing="4">
                    <ic:SymbolIcon
                        HorizontalAlignment="Center"
                        FontSize="14"
                        IconVariant="{x:Bind ViewModel.IsLiked, Mode=OneWay, Converter={StaticResource BoolToIconVariantConverter}}"
                        Symbol="ThumbLike" />
                    <base:TrimTextBlock
                        HorizontalAlignment="Center"
                        FontSize="12"
                        MaxLines="1"
                        Text="{x:Bind ViewModel.LikeCount, Mode=OneWay, Converter={StaticResource CountConverter}}" />
                </StackPanel>
            </ToggleButton>
            <ToggleButton
                Command="{x:Bind ViewModel.ToggleCommentsCommand, Mode=OneWay}"
                IsChecked="{x:Bind ViewModel.IsCommentsOpened, Mode=OneWay}"
                Style="{StaticResource IconToggleButtonStyle}">
                <StackPanel Spacing="4">
                    <ic:SymbolIcon
                        HorizontalAlignment="Center"
                        FontSize="14"
                        IconVariant="{x:Bind ViewModel.IsCommentsOpened, Mode=OneWay, Converter={StaticResource BoolToIconVariantConverter}}"
                        Symbol="ChatEmpty" />
                    <base:TrimTextBlock
                        HorizontalAlignment="Center"
                        FontSize="12"
                        MaxLines="1"
                        Text="{x:Bind ViewModel.CommentCount, Mode=OneWay, Converter={StaticResource CountConverter}}" />
                </StackPanel>
            </ToggleButton>
            <ToggleButton
                Command="{x:Bind ViewModel.ToggleFavoriteCommand, Mode=OneWay}"
                IsChecked="{x:Bind ViewModel.IsFavorited, Mode=OneWay}"
                Style="{StaticResource IconToggleButtonStyle}">
                <StackPanel Spacing="4">
                    <ic:SymbolIcon
                        HorizontalAlignment="Center"
                        FontSize="14"
                        IconVariant="{x:Bind ViewModel.IsFavorited, Mode=OneWay, Converter={StaticResource BoolToIconVariantConverter}}"
                        Symbol="Star" />
                    <base:TrimTextBlock
                        HorizontalAlignment="Center"
                        FontSize="12"
                        MaxLines="1"
                        Text="{x:Bind ViewModel.FavoriteCount, Mode=OneWay, Converter={StaticResource CountConverter}}" />
                </StackPanel>
            </ToggleButton>
            <ToggleButton
                Command="{x:Bind ViewModel.ToggleAIOverlayVisibilityCommand, Mode=OneWay}"
                IsChecked="{x:Bind ViewModel.IsAIOverlayOpened, Mode=OneWay}"
                Style="{StaticResource IconToggleButtonStyle}">
                <StackPanel Spacing="4">
                    <ic:SymbolIcon
                        HorizontalAlignment="Center"
                        FontSize="16"
                        IconVariant="{x:Bind ViewModel.IsAIOverlayOpened, Mode=OneWay, Converter={StaticResource BoolToIconVariantConverter}}"
                        Symbol="Sparkle" />
                    <TextBlock
                        HorizontalAlignment="Center"
                        FontSize="12"
                        Text="AI" />
                </StackPanel>
            </ToggleButton>
        </StackPanel>
    </Grid>
</local:ArticleReaderPageControlBase>
