<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:m="using:SourceGit.Models"
             xmlns:vm="using:SourceGit.ViewModels"
             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
             x:Class="SourceGit.Views.RepositoryToolbar"
             x:DataType="vm:Repository">
  <Grid ColumnDefinitions="*,Auto,0,*">
    <StackPanel Grid.Column="0" Orientation="Horizontal" Margin="4,0,0,0">
      <Button Classes="icon_button" Width="32" Click="OpenWithExternalTools" ToolTip.Tip="{DynamicResource Text.Repository.OpenWithExternalTools}">
        <Path Width="14" Height="14" Data="{StaticResource Icons.OpenWith}"/>
      </Button>

      <Button Classes="icon_button" Width="32" Click="OpenGitLogs" ToolTip.Tip="{DynamicResource Text.Repository.ViewLogs}">
        <Path Width="14" Height="14" Margin="0,1,0,0" Data="{StaticResource Icons.Logs}"/>
      </Button>

      <Button Classes="icon_button" Width="32" Click="OpenStatistics" ToolTip.Tip="{DynamicResource Text.Repository.Statistics}">
        <Path Width="13" Height="13" Data="{StaticResource Icons.Statistics}"/>
      </Button>

      <Button Classes="icon_button" Width="32" Click="OpenConfigure" ToolTip.Tip="{DynamicResource Text.Repository.Configure}">
        <Path Width="14" Height="14" Data="{StaticResource Icons.Settings}"/>
      </Button>
    </StackPanel>

    <StackPanel Grid.Column="1" Orientation="Horizontal">
      <Button Classes="icon_button" Width="32" Tapped="Fetch">
        <ToolTip.Tip>
          <StackPanel Orientation="Vertical">
            <TextBlock Text="{DynamicResource Text.Fetch}"/>
            <TextBlock Classes="small italic" Margin="0,4,0,0" Text="{DynamicResource Text.CtrlClickTip}" Foreground="{DynamicResource Brush.FG2}"/>
          </StackPanel>
        </ToolTip.Tip>

        <Path Width="14" Height="14" Data="{StaticResource Icons.Fetch}"/>
      </Button>

      <Button Classes="icon_button" Width="32" Margin="16,0,0,0" Tapped="Pull" IsVisible="{Binding !IsBare}" IsEnabled="{Binding !IsBare}">
        <ToolTip.Tip>
          <StackPanel Orientation="Vertical">
            <TextBlock Text="{DynamicResource Text.Pull}"/>
            <TextBlock Classes="small italic" Margin="0,4,0,0" Text="{DynamicResource Text.CtrlClickTip}" Foreground="{DynamicResource Brush.FG2}"/>
          </StackPanel>
        </ToolTip.Tip>

        <Path Width="14" Height="14" Data="{StaticResource Icons.Pull}"/>
      </Button>

      <Button Classes="icon_button" Width="32" Margin="16,0,0,0" Tapped="Push">
        <ToolTip.Tip>
          <StackPanel Orientation="Vertical">
            <TextBlock Text="{DynamicResource Text.Push}"/>
            <TextBlock Classes="small italic" Margin="0,4,0,0" Text="{DynamicResource Text.CtrlClickTip}" Foreground="{DynamicResource Brush.FG2}"/>
          </StackPanel>
        </ToolTip.Tip>

        <Path Width="14" Height="14" Data="{StaticResource Icons.Push}"/>
      </Button>

      <Button Classes="icon_button" Width="32" Margin="16,0,0,0" Tapped="StashAll" IsVisible="{Binding !IsBare}">
        <ToolTip.Tip>
          <StackPanel Orientation="Vertical">
            <TextBlock Text="{DynamicResource Text.Stash}"/>
            <TextBlock Classes="small italic" Margin="0,4,0,0" Text="{DynamicResource Text.CtrlClickTip}" Foreground="{DynamicResource Brush.FG2}"/>
          </StackPanel>
        </ToolTip.Tip>

        <Path Width="14" Height="14" Data="{StaticResource Icons.Stashes.Add}"/>
      </Button>

      <Button Classes="icon_button" Width="32" Margin="16,0,0,0" Command="{Binding ApplyPatch}" IsVisible="{Binding !IsBare}" ToolTip.Tip="{DynamicResource Text.Apply}">
        <Path Width="14" Height="14" Data="{StaticResource Icons.Diff}"/>
      </Button>

      <Rectangle Width="1" Height="16"
                 Margin="16,0,0,0"
                 VerticalAlignment="Center"
                 Fill="{DynamicResource Brush.Border2}"/>

      <Button Classes="icon_button" Width="32" Margin="18,0,0,0" Click="OpenGitFlowMenu" IsVisible="{Binding !IsBare}" ToolTip.Tip="{DynamicResource Text.GitFlow}">
        <Path Width="14" Height="14" Data="{StaticResource Icons.GitFlow}"/>
      </Button>

      <Button Classes="icon_button" Width="32" Margin="12,0,0,0" Click="OpenGitLFSMenu" IsVisible="{Binding !IsBare}" ToolTip.Tip="{DynamicResource Text.GitLFS}">
        <Path Width="14" Height="14" Data="{StaticResource Icons.LFS}"/>
      </Button>

      <Button Classes="icon_button" Width="32" Margin="12,0,0,0" Click="StartBisect" IsVisible="{Binding !IsBare}" ToolTip.Tip="{DynamicResource Text.Bisect}">
        <Path Width="14" Height="14" Data="{StaticResource Icons.Bisect}"/>
      </Button>

      <Button Classes="icon_button" Width="32" Margin="12,0,0,0" Click="OpenCustomActionMenu" ToolTip.Tip="{DynamicResource Text.Repository.CustomActions}">
        <Path Width="14" Height="14" Data="{StaticResource Icons.Action}"/>
      </Button>

      <Button Classes="icon_button" Width="32" Margin="12,0,0,0" Click="Cleanup" ToolTip.Tip="{DynamicResource Text.Repository.Clean}">
        <Path Width="14" Height="14" Margin="0,1,0,0" Data="{StaticResource Icons.Clean}"/>
      </Button>
    </StackPanel>

    <StackPanel Grid.Column="2" Orientation="Horizontal">
      <Button Width="0" Height="0" Click="PushDirectlyByHotKey" IsVisible="False" HotKey="{OnPlatform Ctrl+Shift+Up, macOS=⌘+Shift+Up}"/>
      <Button Width="0" Height="0" Click="PullDirectlyByHotKey" IsVisible="False" IsEnabled="{Binding !IsBare}" HotKey="{OnPlatform Ctrl+Shift+Down, macOS=⌘+Shift+Down}"/>
      <Button Width="0" Height="0" Click="FetchDirectlyByHotKey" IsVisible="False" HotKey="{OnPlatform Ctrl+Down, macOS=⌘+Down}"/>
    </StackPanel>

    <StackPanel Grid.Column="3" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,4,0">
      <Path Width="13" Height="13" Fill="{DynamicResource Brush.FG1}" Data="{StaticResource Icons.Branch}"/>

      <ContentControl Margin="6,0,0,0">
        <ContentControl.Content>
          <Binding Path="CurrentBranch">
            <Binding.TargetNullValue>
              <TextBlock Text="--"/>
            </Binding.TargetNullValue>
          </Binding>
        </ContentControl.Content>

        <ContentControl.DataTemplates>
          <DataTemplate DataType="m:Branch">
            <Border Background="Transparent" ToolTip.Tip="{Binding FriendlyName}">
              <TextBlock Text="{Binding FriendlyName}" MaxWidth="250" TextTrimming="CharacterEllipsis"/>
            </Border>
          </DataTemplate>
        </ContentControl.DataTemplates>
      </ContentControl>

      <Button Classes="icon_button" Width="32" Click="NavigateToHead" ToolTip.Tip="{DynamicResource Text.Repository.NavigateToCurrentHead}">
        <Path Width="13" Height="13" Margin="0,2,0,0" Data="{StaticResource Icons.Target}" Fill="{DynamicResource Brush.FG1}"/>
      </Button>
    </StackPanel>
  </Grid>
</UserControl>
