<controls2:EnhancedPage
    x:Class="Pixeval.Pages.WorkInfoPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:CommunityToolkit.WinUI.Controls"
    xmlns:controls2="using:Pixeval.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:fluent="using:FluentIcons.WinUI"
    xmlns:i="using:Microsoft.Xaml.Interactivity"
    xmlns:local="using:Pixeval.Pages"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:model="using:Pixeval.CoreApi.Model"
    xmlns:pixeval="using:Pixeval.AppManagement"
    xmlns:ui="using:CommunityToolkit.WinUI"
    mc:Ignorable="d">
    <controls2:EnhancedPage.Resources>
        <!--  翻译后的TextBlock可以用，暂时没用上  -->
        <Style x:Key="GrayTextBlock" TargetType="TextBlock">
            <Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
        </Style>
    </controls2:EnhancedPage.Resources>
    <ScrollViewer
        HorizontalScrollBarVisibility="Disabled"
        HorizontalScrollMode="Disabled"
        VerticalScrollBarVisibility="Auto">
        <StackPanel Margin="20,15" Spacing="4">
            <controls2:TranslatableTextBlock
                HorizontalAlignment="Left"
                IsCompact="True"
                IsHorizontal="True"
                Text="{x:Bind _viewModel.Entry.Title}"
                TextBlockStyle="{StaticResource TitleTextBlockStyle}"
                TextType="WorkTitle" />
            <controls2:TranslatableTextBlock
                x:Name="WorkCaptionMarkdownTextBlock"
                Margin="{StaticResource StackLayoutEntryPadding}"
                HorizontalButtonAlignment="Left"
                UseMarkdown="True" />
            <StackPanel Orientation="Horizontal" Spacing="5">
                <TextBlock VerticalAlignment="Center" Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}">
                    <Run Text="PID" />
                    <Run Text="{x:Bind _viewModel.Entry.Id}" />
                </TextBlock>
                <Button
                    Padding="2"
                    VerticalAlignment="Center"
                    Content="{ui:SymbolIcon FontSize=12,
                                            Symbol=Copy}"
                    Style="{StaticResource PixevalTransparentButtonStyle}">
                    <i:Interaction.Behaviors>
                        <controls2:ButtonCopyBehavior TargetText="{x:Bind _viewModel.Entry.Id}" />
                    </i:Interaction.Behaviors>
                </Button>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Spacing="20">
                <controls2:IconText Symbol="Eye" Text="{x:Bind _viewModel.Entry.TotalView}" />
                <controls2:IconText Symbol="Heart" Text="{x:Bind _viewModel.Entry.TotalBookmarks}" />
            </StackPanel>
            <controls2:IconText Symbol="Clock" Text="{x:Bind controls2:C.CultureDateTimeOffsetFormatter(_viewModel.Entry.CreateDate, pixeval:AppSettings.CurrentCulture)}" />
            <!--#region Illustrator Info-->
            <Button
                Margin="0,12,0,0"
                Click="IllustratorPersonPicture_OnClicked"
                Style="{StaticResource CardControlButton}">
                <controls:DockPanel HorizontalSpacing="12" LastChildFill="False">
                    <PersonPicture
                        Width="50"
                        Height="50"
                        controls:DockPanel.Dock="Left"
                        ProfilePicture="{x:Bind _viewModel.AvatarSource, Mode=OneWay}" />
                    <TextBlock
                        controls:DockPanel.Dock="Top"
                        Style="{StaticResource SubtitleTextBlockStyle}"
                        TextWrapping="Wrap">
                        <Run Text="{x:Bind _viewModel.Illustrator.Name}" />
                    </TextBlock>
                    <StackPanel
                        controls:DockPanel.Dock="Bottom"
                        Orientation="Horizontal"
                        Spacing="5">
                        <TextBlock
                            VerticalAlignment="Center"
                            Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}"
                            Text="{x:Bind _viewModel.Illustrator.Id}" />
                        <Button
                            Padding="2"
                            VerticalAlignment="Center"
                            Content="{ui:SymbolIcon FontSize=12,
                                                    Symbol=Copy}"
                            Style="{StaticResource PixevalTransparentButtonStyle}">
                            <i:Interaction.Behaviors>
                                <controls2:ButtonCopyBehavior TargetText="{x:Bind _viewModel.Illustrator.Id}" />
                            </i:Interaction.Behaviors>
                        </Button>
                    </StackPanel>

                </controls:DockPanel>
            </Button>
            <!--#endregion-->
            <!--#region Tags-->
            <ItemsRepeater Margin="0,12,0,0" ItemsSource="{x:Bind _viewModel.Entry.Tags}">
                <ItemsRepeater.Layout>
                    <controls:WrapLayout HorizontalSpacing="8" VerticalSpacing="8" />
                </ItemsRepeater.Layout>
                <ItemsRepeater.ItemTemplate>
                    <DataTemplate x:DataType="model:Tag">
                        <Button
                            Click="WorkTagButton_OnClicked"
                            Tag="{x:Bind Name}"
                            ToolTipService.ToolTip="{x:Bind ToolTip}">
                            <Button.Content>
                                <controls:SwitchPresenter Value="{x:Bind controls2:C.IsNull(TranslatedName)}">
                                    <controls:Case>
                                        <controls:Case.Value>
                                            <x:Boolean>True</x:Boolean>
                                        </controls:Case.Value>
                                        <controls2:TranslatableTextBlock
                                            ButtonMargin="-2"
                                            IsCompact="True"
                                            IsHorizontal="True"
                                            Text="{x:Bind Name}"
                                            TextType="WorkTag" />
                                    </controls:Case>
                                    <controls:Case>
                                        <controls:Case.Value>
                                            <x:Boolean>False</x:Boolean>
                                        </controls:Case.Value>
                                        <TextBlock TextWrapping="Wrap">
                                            <Run Text="{x:Bind Name}" />
                                            <Run Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" Text="{x:Bind TranslatedName}" />
                                        </TextBlock>
                                    </controls:Case>
                                </controls:SwitchPresenter>
                            </Button.Content>
                            <Button.ContextFlyout>
                                <MenuFlyout>
                                    <MenuFlyoutItem
                                        x:Uid="/WorkInfoPage/BlockTagMenuItem"
                                        Click="MenuFlyoutItem_OnClick"
                                        Icon="{fluent:SymbolIcon Symbol=TagDismiss}"
                                        Tag="{x:Bind}" />
                                </MenuFlyout>
                            </Button.ContextFlyout>
                        </Button>
                    </DataTemplate>
                </ItemsRepeater.ItemTemplate>
            </ItemsRepeater>
            <!--#endregion-->
        </StackPanel>
    </ScrollViewer>
</controls2:EnhancedPage>
