<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:app="using:Bili.App.Controls.App"
    xmlns:controls="using:Bili.App.Controls"
    xmlns:icons="using:Richasy.FluentIcon.Uwp"
    xmlns:loc="using:Bili.App.Resources.Extension"
    xmlns:local="using:Bili.App.Controls.Community">
    <Style x:Key="DefaultCommentItemStyle" TargetType="local:CommentItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:CommentItem">
                    <controls:CardPanel Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ClickCommand}" IsEnableHoverAnimation="False">
                        <Grid Padding="12" ColumnSpacing="12">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <StackPanel VerticalAlignment="Top">
                                <Grid>
                                    <Border
                                        Width="40"
                                        Height="40"
                                        HorizontalAlignment="Center"
                                        VerticalAlignment="Center"
                                        BorderBrush="{ThemeResource AccentFillColorDefaultBrush}"
                                        BorderThickness="2"
                                        CornerRadius="18"
                                        Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsUserHighlight}" />
                                    <controls:UserAvatar
                                        x:Name="UserAvatar"
                                        Width="32"
                                        Height="32"
                                        HorizontalAlignment="Center"
                                        VerticalAlignment="Center"
                                        Avatar="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Publisher.User.Avatar.Uri}"
                                        Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ShowUserDetailCommand}"
                                        UserName="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Publisher.User.Name}" />
                                </Grid>

                                <Border
                                    x:Name="TopContainer"
                                    Width="32"
                                    Margin="0,12,0,0"
                                    Padding="2"
                                    BorderBrush="{ThemeResource AccentFillColorDefaultBrush}"
                                    BorderThickness="1"
                                    CornerRadius="{StaticResource ControlCornerRadius}"
                                    Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.IsTop}">
                                    <TextBlock
                                        HorizontalAlignment="Center"
                                        FontSize="10"
                                        Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
                                        Text="{loc:Locale Name=Top}" />
                                </Border>
                            </StackPanel>

                            <Grid Grid.Column="1" RowSpacing="8">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Grid ColumnSpacing="8">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <TextBlock
                                        x:Name="UserNameBlock"
                                        Style="{StaticResource BodyTextBlockStyle}"
                                        FontWeight="Bold"
                                        Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Publisher.User.Name}" />
                                    <Image
                                        x:Name="LevelImage"
                                        Grid.Column="1"
                                        Height="8"
                                        HorizontalAlignment="Left"
                                        VerticalAlignment="Center"
                                        Source="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Publisher.Level, Converter={StaticResource UserLevelConverter}}" />
                                    <TextBlock
                                        x:Name="PublishTimeBlock"
                                        Style="{StaticResource CaptionTextBlockStyle}"
                                        Grid.Column="2"
                                        VerticalAlignment="Center"
                                        Foreground="{ThemeResource TextFillColorTertiaryBrush}"
                                        Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.PublishDateText}"
                                        ToolTipService.ToolTip="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.PublishTime}" />
                                </Grid>
                                <Grid Grid.Row="1">
                                    <app:EmoteTextBlock
                                        x:Name="ReplyContentBlock"
                                        HorizontalAlignment="Left"
                                        Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Content}" />
                                </Grid>
                                <Grid Grid.Row="2" ColumnSpacing="12">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <ToggleButton
                                        x:Name="LikeButton"
                                        Style="{StaticResource DefaultToggleButtonStyle}"
                                        VerticalAlignment="Center"
                                        Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ToggleLikeCommand}"
                                        IsChecked="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsLiked}">
                                        <StackPanel Orientation="Horizontal" Spacing="8">
                                            <icons:RegularFluentIcon
                                                VerticalAlignment="Center"
                                                FontSize="12"
                                                Symbol="ThumbLike16" />
                                            <TextBlock
                                                VerticalAlignment="Center"
                                                FontSize="12"
                                                Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.LikeCountText}" />
                                        </StackPanel>
                                    </ToggleButton>
                                    <StackPanel
                                        Grid.Column="1"
                                        HorizontalAlignment="Left"
                                        Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ReplyCountText, Converter={StaticResource ObjectToVisibilityConverter}}">
                                        <HyperlinkButton x:Name="MoreButton" Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ShowCommentDetailCommand}">
                                            <TextBlock FontSize="12" Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.ReplyCountText}" />
                                        </HyperlinkButton>
                                    </StackPanel>
                                </Grid>
                            </Grid>
                        </Grid>
                    </controls:CardPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style BasedOn="{StaticResource DefaultCommentItemStyle}" TargetType="local:CommentItem" />
</ResourceDictionary>
