<UserControl x:Class="GitHub.VisualStudio.Views.GitHubPane.PullRequestUserReviewsView"
             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:local="clr-namespace:GitHub.VisualStudio.Views.GitHubPane"
             xmlns:markdig="clr-namespace:Markdig.Wpf;assembly=Markdig.Wpf"
             xmlns:uic="clr-namespace:GitHub.VisualStudio.UI.Controls"
             Background="{DynamicResource GitHubVsToolWindowBackground}"
             Foreground="{DynamicResource GitHubVsWindowText}"
             mc:Ignorable="d" d:DesignHeight="500" d:DesignWidth="300">

    <d:DesignData.DataContext>
        <ghfvs:PullRequestUserReviewsViewModelDesigner/>
    </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" />
                <ghfvs:SharedDictionaryManager Source="pack://application:,,,/GitHub.UI.Reactive;component/SharedDictionary.xaml" />
                <ghfvs:SharedDictionaryManager Source="pack://application:,,,/GitHub.VisualStudio.UI;component/Styles/Markdown.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Control.Resources>

    <ScrollViewer VerticalScrollBarVisibility="Auto">
        <StackPanel>
            <StackPanel DockPanel.Dock="Top" Margin="8 0" Orientation="Vertical">
                <TextBlock FontSize="16" VerticalAlignment="Center">
                        <Run>Reviews by</Run>
                        <Run FontWeight="SemiBold" Text="{Binding User.Login, Mode=OneWay}"/>
                        <Run>for</Run>
                        <Hyperlink Command="{Binding NavigateToPullRequest}">
                            <Run>#</Run><Run Text="{Binding PullRequestNumber, Mode=OneWay}"/>
                        </Hyperlink>
                </TextBlock>

                <TextBlock Foreground="{DynamicResource GitHubVsGrayText}"
                           Margin="0"
                           Text="{Binding PullRequestTitle}"
                           TextWrapping="Wrap"/>
                <StackPanel Orientation="Horizontal" Margin="0 4">
                    <uic:AccountAvatar Account="{Binding User}" Margin="0 0 4 0" Width="16" Height="16"/>
                    <TextBlock Text="{Binding Reviews.Count, StringFormat={}{0} reviews}"
                               VerticalAlignment="Center"/>
                </StackPanel>
            </StackPanel>
            <ItemsControl ItemsSource="{Binding Reviews}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <Rectangle Fill="{DynamicResource GitHubHeaderSeparatorBrush}" Height="1" Margin="0 4"/>

                            <Expander Margin="0 0 4 0"
                                      Foreground="{DynamicResource GitHubVsToolWindowText}"
                                      IsExpanded="{Binding IsExpanded, Mode=OneTime}"
                                      IsEnabled="{Binding HasDetails}">
                                <Expander.Header>
                                    <StackPanel Orientation="Horizontal">
                                        <ghfvs:OcticonImage Icon="check" Foreground="#2cbe4e" Visibility="{Binding Model.State, Converter={ghfvs:EqualsToVisibilityConverter Approved}}"/>
                                        <ghfvs:OcticonImage Icon="x" Foreground="#cb2431" Visibility="{Binding Model.State, Converter={ghfvs:EqualsToVisibilityConverter ChangesRequested}}"/>
                                        <ghfvs:OcticonImage Icon="comment" Visibility="{Binding Model.State, Converter={ghfvs:EqualsToVisibilityConverter Commented}}"/>
                                        <ghfvs:OcticonImage Icon="comment" Visibility="{Binding Model.State, Converter={ghfvs:EqualsToVisibilityConverter Dismissed}}"/>

                                        <TextBlock FontWeight="SemiBold" Margin="2 0">
                                            <Run Text="{Binding Model.User.Login, Mode=OneWay}"/>
                                            <Run Text="{Binding StateDisplay, Mode=OneWay}"/>
                                            <Run FontWeight="Normal" Text="{Binding Model.SubmittedAt, Mode=OneWay, Converter={ghfvs:DurationToStringConverter}}"/>
                                        </TextBlock>
                                    </StackPanel>
                                </Expander.Header>
                                <StackPanel Margin="21 4 0 4"
                                            Visibility="{Binding HasDetails, Converter={ghfvs:BooleanToVisibilityConverter}}">
                                    <Expander Foreground="{DynamicResource GitHubVsToolWindowText}"
                                              IsExpanded="True"
                                              Margin="0 4"
                                              Visibility="{Binding Body, Converter={ghfvs:NullToVisibilityConverter}}">
                                        <Expander.Header>
                                            <TextBlock FontWeight="SemiBold" Text="{x:Static ghfvs:Resources.Description}"/>
                                        </Expander.Header>
                                        <markdig:MarkdownViewer Margin="22 4 0 0" Markdown="{Binding Body}"/>
                                    </Expander>
                                    <Expander IsExpanded="True"
                                              Margin="0 4"
                                              Visibility="{Binding FileComments.Count, Converter={ghfvs:CountToVisibilityConverter}}">
                                        <Expander.Header>
                                            <TextBlock FontWeight="SemiBold" Text="{x:Static ghfvs:Resources.Comments}"/>
                                        </Expander.Header>
                                        <local:PullRequestFileCommentsView DataContext="{Binding FileComments}" 
                                                                           Margin="22 4 0 0"/>
                                    </Expander>
                                    <Expander Margin="0 4"
                                              Visibility="{Binding OutdatedFileComments.Count, Converter={ghfvs:CountToVisibilityConverter}}">
                                        <Expander.Header>
                                            <TextBlock FontWeight="SemiBold" Text="{x:Static ghfvs:Resources.OutdatedComments}"/>
                                        </Expander.Header>
                                        <local:PullRequestFileCommentsView DataContext="{Binding OutdatedFileComments}"
                                                                           Margin="22 4 0 0"/>
                                    </Expander>
                                </StackPanel>
                            </Expander>
                        </StackPanel>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </StackPanel>
    </ScrollViewer>
</UserControl>
