<UserControl x:Class="GitHub.VisualStudio.Views.GitHubPane.PullRequestListItemView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:ghfvs="https://github.com/github/VisualStudio"
             xmlns:views="clr-namespace:GitHub.VisualStudio.Views"
             xmlns:controls="clr-namespace:GitHub.VisualStudio.UI.Controls"
             mc:Ignorable="d" d:DesignWidth="300"
             Padding="0 4">
    <d:DesignData.DataContext>
        <ghfvs:PullRequestListItemViewModelDesigner Number="399"
                                                    Title="Let's try doing this differently"
                                                    CommentCount="4"
                                                    IsCurrent="True"
                                                    UpdatedAt="2018-01-29"
                                                    ChecksSummary="Success">
            <ghfvs:PullRequestListItemViewModelDesigner.Author>
                <ghfvs:ActorViewModelDesigner Login="shana"/>
            </ghfvs:PullRequestListItemViewModelDesigner.Author>
        </ghfvs:PullRequestListItemViewModelDesigner>
    </d:DesignData.DataContext>

    <Control.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ghfvs:SharedDictionaryManager Source="pack://application:,,,/GitHub.VisualStudio.UI;component/SharedDictionary.xaml"/>
                <ghfvs:SharedDictionaryManager Source="pack://application:,,,/GitHub.UI;component/SharedDictionary.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Control.Resources>

    <Grid>
        <Image HorizontalAlignment="Left"
           Stretch="None"
           Opacity="0.2"
           Visibility="{Binding Converter={ghfvs:EqualsToVisibilityConverter {x:Null}}}">
            <Image.Source>
                <DrawingImage>
                    <DrawingImage.Drawing>
                        <GeometryDrawing Brush="{DynamicResource GitHubVsGrayText}">
                            <GeometryDrawing.Geometry>
                                <GeometryGroup>
                                    <RectangleGeometry Rect="0, 6, 30, 30" RadiusX="3" RadiusY="3"/>
                                    <RectangleGeometry Rect="40, 8, 140, 10" RadiusX="3" RadiusY="3"/>
                                    <RectangleGeometry Rect="40, 27, 100, 10" RadiusX="3" RadiusY="3"/>
                                </GeometryGroup>
                            </GeometryDrawing.Geometry>
                        </GeometryDrawing>
                    </DrawingImage.Drawing>
                </DrawingImage>
            </Image.Source>
        </Image>

        <Grid Visibility="{Binding Converter={ghfvs:NullToVisibilityConverter}}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" MinWidth="40"/>
            </Grid.ColumnDefinitions>
            <views:ActorAvatarView
                               Grid.Column="0"
                               ViewModel="{Binding Author}"
                               Margin="0,1,4,0"
                               Width="32"
                               Height="32"
                               VerticalAlignment="Top"/>

            <StackPanel Grid.Column="1" Margin="2 0 0 0">
                <TextBlock DockPanel.Dock="Left"
                           TextTrimming="CharacterEllipsis"
                           Text="{Binding Title}">
                    <TextBlock.Style>
                        <Style TargetType="TextBlock">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsCurrent}" Value="True">
                                    <Setter Property="FontWeight" Value="Bold"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </TextBlock.Style>
                </TextBlock>

                <StackPanel Orientation="Horizontal">
                    <TextBlock Opacity="0.5" Margin="0 0 4 0">
                        <Run Text="{Binding Number, Mode=OneWay, StringFormat=#{0}}"/>
                    </TextBlock>

                    <TextBlock Opacity="0.5" TextTrimming="CharacterEllipsis">
                        <Run Text="updated"/>
                        <Run Text="{Binding UpdatedAt, Converter={ghfvs:DurationToStringConverter}, Mode=OneWay}"/>
                        by
                        <Run Text="{Binding Author.Login, Mode=OneWay}"/>
                    </TextBlock>
                </StackPanel>
            </StackPanel>

            <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="8 0">
                <TextBlock Opacity="0.5" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0 0 4 0" Visibility="{Binding CommentCount, Converter={ghfvs:CountToVisibilityConverter}}"> <ghfvs:OcticonImage Icon="comment" Width="12" Height="12" Margin="0 0 0 -2"/>
                    <Run Text="{Binding CommentCount, Mode=OneWay}" BaselineAlignment="Bottom"/>
                </TextBlock>
                <ghfvs:OcticonImage Icon="check" Foreground="#2cbe4e" Visibility="{Binding ChecksSummary, Converter={ghfvs:EqualsToVisibilityConverter Success}}"/>
                <ghfvs:OcticonImage Icon="x" Foreground="#cb2431" Visibility="{Binding ChecksSummary, Converter={ghfvs:EqualsToVisibilityConverter Failure}}"/>
                <ghfvs:OcticonImage Icon="primitive_dot" Foreground="#f1c647" Visibility="{Binding ChecksSummary, Converter={ghfvs:EqualsToVisibilityConverter Pending}}"/>
                <controls:PullRequestStatusCircle 
                    Height="18" Width="18"
                    Radius="8" InnerRadius="5"
                    Visibility="{Binding ChecksSummary, Converter={ghfvs:EqualsToVisibilityConverter Mixed}}"
                    PendingCount="{Binding ChecksPendingCount}"
                    PendingColor="#f1c647"
                    ErrorCount="{Binding ChecksErrorCount}"
                    ErrorColor="#cb2431"
                    SuccessCount="{Binding ChecksSuccessCount}"
                    SuccessColor="#2cbe4e"
                    />
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
