<v:ChromelessWindow 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"
                    xmlns:v="using:SourceGit.Views"
                    mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
                    x:Class="SourceGit.Views.ConventionalCommitMessageBuilder"
                    x:DataType="vm:ConventionalCommitMessageBuilder"
                    x:Name="ThisControl"
                    Icon="/App.ico"
                    Title="{DynamicResource Text.ConventionalCommit}"
                    Width="600"
                    SizeToContent="Height"
                    CanResize="False"
                    WindowStartupLocation="CenterOwner">
  <Grid RowDefinitions="Auto,Auto,Auto">
    <!-- TitleBar -->
    <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
      <Border Background="{DynamicResource Brush.TitleBar}"
              BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
              PointerPressed="BeginMoveWindow"/>

      <Path Width="14" Height="14"
            Margin="10,0,0,0"
            HorizontalAlignment="Left"
            Data="{StaticResource Icons.CommitMessageGenerator}"
            IsVisible="{OnPlatform True, macOS=False}"/>

      <TextBlock Classes="bold"
                 Text="{DynamicResource Text.ConventionalCommit}"
                 HorizontalAlignment="Center" VerticalAlignment="Center"
                 IsHitTestVisible="False"/>

      <v:CaptionButtons HorizontalAlignment="Right"
                        IsCloseButtonOnly="True"
                        IsVisible="{OnPlatform True, macOS=False}"/>
    </Grid>

    <!-- Body -->
    <Grid Grid.Row="1" Margin="16,8" RowDefinitions="32,32,32,100,100,32" ColumnDefinitions="Auto,*">
      <TextBlock Grid.Row="0" Grid.Column="0"
                 HorizontalAlignment="Right" VerticalAlignment="Top"
                 Margin="0,6,8,0"
                 Text="{DynamicResource Text.ConventionalCommit.Type}"/>
      <ComboBox Grid.Row="0" Grid.Column="1"
                Height="28" Padding="8,0"
                VerticalAlignment="Center" HorizontalAlignment="Stretch"
                ItemsSource="{Binding Types, Mode=OneWay}"
                SelectedItem="{Binding SelectedType, Mode=TwoWay}"
                Grid.IsSharedSizeScope="True">
        <ComboBox.SelectionBoxItemTemplate>
          <DataTemplate DataType="m:ConventionalCommitType">
            <StackPanel Orientation="Horizontal">
              <TextBlock Text="{Binding Name}" Margin="0,0,8,0"/>
              <Border Height="16" CornerRadius="8" Padding="8,0" VerticalAlignment="Center" Background="Green">
                <TextBlock Text="{Binding Type}" VerticalAlignment="Center" FontSize="11" Foreground="White"/>
              </Border>
            </StackPanel>
          </DataTemplate>
        </ComboBox.SelectionBoxItemTemplate>

        <ComboBox.ItemTemplate>
          <DataTemplate DataType="m:ConventionalCommitType">
            <Grid Height="22">
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" SharedSizeGroup="NameColumn"/>
                <ColumnDefinition Width="Auto" SharedSizeGroup="TypeColumn"/>
                <ColumnDefinition Width="Auto" SharedSizeGroup="DescriptionColumn"/>
              </Grid.ColumnDefinitions>

              <TextBlock Grid.Column="0" Text="{Binding Name}"/>
              <Border Grid.Column="1" Height="16" CornerRadius="8" Padding="8,0" Margin="8,0,16,0" HorizontalAlignment="Left" VerticalAlignment="Center" Background="Green">
                <TextBlock Text="{Binding Type}" VerticalAlignment="Center" FontSize="11" Foreground="White"/>
              </Border>
              <TextBlock Grid.Column="2" Text="{Binding Description}" Foreground="{DynamicResource Brush.FG2}"/>
            </Grid>
          </DataTemplate>
        </ComboBox.ItemTemplate>
      </ComboBox>

      <TextBlock Grid.Row="1" Grid.Column="0"
                 HorizontalAlignment="Right" VerticalAlignment="Top"
                 Margin="0,6,8,0"
                 Text="{DynamicResource Text.ConventionalCommit.Scope}"/>
      <TextBox Grid.Row="1" Grid.Column="1"
               Height="26"
               VerticalAlignment="Center"
               CornerRadius="2"
               Watermark="{DynamicResource Text.Optional}"
               Text="{Binding Scope, Mode=TwoWay}"/>

      <TextBlock Grid.Row="2" Grid.Column="0"
                 HorizontalAlignment="Right" VerticalAlignment="Top"
                 Margin="0,6,8,0"
                 Text="{DynamicResource Text.ConventionalCommit.ShortDescription}"/>
      <TextBox Grid.Row="2" Grid.Column="1"
               Height="26"
               VerticalAlignment="Center"
               CornerRadius="2"
               Text="{Binding Description, Mode=TwoWay}"/>

      <TextBlock Grid.Row="3" Grid.Column="0"
                 HorizontalAlignment="Right" VerticalAlignment="Top"
                 Margin="0,6,8,0"
                 Text="{DynamicResource Text.ConventionalCommit.Detail}"/>
      <TextBox Grid.Row="3" Grid.Column="1"
               Height="96"
               AcceptsReturn="True"
               AcceptsTab="True"
               TextWrapping="Wrap"
               ScrollViewer.HorizontalScrollBarVisibility="Disabled"
               ScrollViewer.VerticalScrollBarVisibility="Auto"
               VerticalAlignment="Center"
               VerticalContentAlignment="Top"
               CornerRadius="2"
               Watermark="{DynamicResource Text.Optional}"
               Text="{Binding Detail, Mode=TwoWay}"/>

      <TextBlock Grid.Row="4" Grid.Column="0"
                 HorizontalAlignment="Right" VerticalAlignment="Top"
                 Margin="0,6,8,0"
                 Text="{DynamicResource Text.ConventionalCommit.BreakingChanges}"/>
      <TextBox Grid.Row="4" Grid.Column="1"
               Height="96"
               AcceptsReturn="True"
               AcceptsTab="True"
               TextWrapping="Wrap"
               ScrollViewer.HorizontalScrollBarVisibility="Disabled"
               ScrollViewer.VerticalScrollBarVisibility="Auto"
               VerticalAlignment="Center"
               VerticalContentAlignment="Top"
               CornerRadius="2"
               Watermark="{DynamicResource Text.Optional}"
               Text="{Binding BreakingChanges, Mode=TwoWay}"/>

      <TextBlock Grid.Row="5" Grid.Column="0"
                 HorizontalAlignment="Right" VerticalAlignment="Top"
                 Margin="0,6,8,0"
                 Text="{DynamicResource Text.ConventionalCommit.ClosedIssue}"/>
      <TextBox Grid.Row="5" Grid.Column="1"
               Height="26"
               VerticalAlignment="Center"
               CornerRadius="2"
               Watermark="{DynamicResource Text.Optional}"
               Text="{Binding ClosedIssue, Mode=TwoWay}"/>
    </Grid>

    <!-- Apply Button -->
    <Button Grid.Row="2"
            Classes="flat primary"
            Height="32" Width="80"
            Margin="0,0,0,8"
            HorizontalAlignment="Center"
            Content="{DynamicResource Text.Sure}"
            Click="OnApplyClicked"
            HotKey="{OnPlatform Ctrl+Enter, macOS=⌘+Enter}"
            ToolTip.Tip="{OnPlatform Ctrl+Enter, macOS=⌘+Enter}"
            ToolTip.Placement="Top"
            ToolTip.VerticalOffset="0"/>
  </Grid>
</v:ChromelessWindow>
