sourcegit/src/Views/Histories.axaml

248 lines
12 KiB
Text
Raw Normal View History

<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"
xmlns:v="using:SourceGit.Views"
xmlns:c="using:SourceGit.Converters"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.Histories"
x:DataType="vm:Histories">
<v:LayoutableGrid RowDefinitions="*,3,*" ColumnDefinitions="*,3,*"
UseHorizontal="{Binding Source={x:Static vm:Preference.Instance}, Path=UseTwoColumnsLayoutInHistories}">
<Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3">
2024-07-14 00:55:15 -07:00
<DataGrid x:Name="CommitDataGrid"
Background="{DynamicResource Brush.Contents}"
ItemsSource="{Binding Commits}"
SelectionMode="Extended"
SelectedItem="{Binding AutoSelectedCommit, Mode=OneWay}"
CanUserReorderColumns="False"
CanUserResizeColumns="True"
CanUserSortColumns="False"
IsReadOnly="True"
HeadersVisibility="Column"
Focusable="False"
RowHeight="28"
ColumnHeaderHeight="24"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto"
LayoutUpdated="OnCommitDataGridLayoutUpdated"
SelectionChanged="OnCommitDataGridSelectionChanged"
ContextRequested="OnCommitDataGridContextRequested">
<DataGrid.Styles>
<Style Selector="DataGridColumnHeader">
<Setter Property="MinHeight" Value="24"/>
<Setter Property="Template">
<ControlTemplate>
<Border Background="{DynamicResource Brush.Window}"
BorderBrush="{DynamicResource Brush.Border0}"
BorderThickness="0,0,0,1">
<Grid ColumnDefinitions="*,1">
<ContentControl x:Name="PART_ContentPresenter"
Grid.Column="0"
Margin="4,0"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
HorizontalContentAlignment="Center"/>
<Rectangle Name="VerticalSeparator"
Grid.Column="1"
Width="1"
VerticalAlignment="Stretch"
Fill="{DynamicResource Brush.Border0}"
IsVisible="{TemplateBinding AreSeparatorsVisible}" />
</Grid>
</Border>
</ControlTemplate>
</Setter>
</Style>
</DataGrid.Styles>
<DataGrid.Columns>
<DataGridTemplateColumn Width="*" CanUserResize="True">
<DataGridTemplateColumn.Header>
<TextBlock Classes="table_header" Text="{DynamicResource Text.Histories.Header.GraphAndSubject}"/>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate x:DataType="{x:Type m:Commit}">
<Border Margin="{Binding Margin}">
<StackPanel Orientation="Horizontal" Margin="2,0,0,0">
<ItemsControl ItemsSource="{Binding Decorators}" IsVisible="{Binding HasDecorators}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" VerticalAlignment="Center"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type m:Decorator}">
<Border Height="16" Margin="0,0,4,0" CornerRadius="2" ClipToBounds="True">
<StackPanel Orientation="Horizontal">
<Border Background="{DynamicResource Brush.DecoratorIconBG}" Width="16">
2024-03-24 19:27:07 -07:00
<Path Width="8" Height="8"
Stretch="Uniform"
Data="{Binding Type, Converter={x:Static c:DecoratorTypeConverters.ToIcon}}"
Fill="{DynamicResource Brush.DecoratorIcon}"
VerticalAlignment="Center"/>
</Border>
<Border Background="{Binding Type, Converter={x:Static c:DecoratorTypeConverters.ToBackground}}">
<TextBlock Classes="monospace"
Text="{Binding Name}"
FontSize="10"
Margin="4,0"
Foreground="{DynamicResource Brush.DecoratorFG}"
FontWeight="{Binding Type, Converter={x:Static c:DecoratorTypeConverters.ToFontWeight}}"/>
</Border>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Ellipse Width="5" Height="5"
Margin="0,0,4,0"
Fill="{DynamicResource Brush.Accent}"
IsVisible="{Binding CanPushToUpstream}"/>
<Ellipse Width="5" Height="5"
Margin="0,0,4,0"
Fill="{DynamicResource Brush.FG1}"
IsVisible="{Binding CanPullFromUpstream}"/>
<TextBlock Classes="monospace"
Text="{Binding Subject}"
Opacity="{Binding Opacity}"
FontWeight="{Binding FontWeight}"/>
</StackPanel>
</Border>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn CanUserResize="True" Width="120">
<DataGridTemplateColumn.Header>
<TextBlock Classes="table_header" Text="{DynamicResource Text.Histories.Header.Author}"/>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate x:DataType="{x:Type m:Commit}">
<Grid ColumnDefinitions="Auto,*" Margin="8,0">
<v:Avatar Grid.Column="0"
Width="16" Height="16"
VerticalAlignment="Center"
IsHitTestVisible="False"
User="{Binding Author}"
Opacity="{Binding Opacity}"/>
<TextBlock Grid.Column="1"
Classes="monospace"
Text="{Binding Author.Name}"
Margin="8,0,0,0"
Opacity="{Binding Opacity}"
FontWeight="{Binding FontWeight}"/>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn CanUserResize="False" MinWidth="96">
<DataGridTemplateColumn.Header>
<TextBlock Classes="table_header" Text="{DynamicResource Text.Histories.Header.SHA}"/>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate x:DataType="{x:Type m:Commit}">
<TextBlock Classes="monospace"
Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
Margin="8,0"
HorizontalAlignment="Center"
Opacity="{Binding Opacity}"
FontWeight="{Binding FontWeight}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn CanUserResize="False" MinWidth="156">
<DataGridTemplateColumn.Header>
<StackPanel Orientation="Horizontal">
<ToggleButton Classes="time_display_mode"
Width="10" Height="10"
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=DisplayTimeAsPeriodInHistories, Mode=TwoWay}"/>
<TextBlock Classes="table_header" Margin="4,0,0,0" Text="{DynamicResource Text.Histories.Header.Time}"/>
</StackPanel>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate x:DataType="{x:Type m:Commit}">
<v:CommitTimeTextBlock Classes="monospace"
Margin="8,0"
HorizontalAlignment="Center"
Opacity="{Binding Opacity}"
FontWeight="{Binding FontWeight}"
Timestamp="{Binding CommitterTime}"
ShowAsDateTime="{Binding Source={x:Static vm:Preference.Instance}, Path=!DisplayTimeAsPeriodInHistories}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
2024-07-14 00:55:15 -07:00
<v:CommitGraph x:Name="CommitGraph"
Graph="{Binding Graph}"
DotBrush="{DynamicResource Brush.Contents}"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
IsHitTestVisible="False"
ClipToBounds="True"/>
2024-05-30 01:12:28 -07:00
<!-- Fix memory leak -->
<v:LoadingIcon Width="48" Height="48" HorizontalAlignment="Center" VerticalAlignment="Center" IsVisible="{Binding IsLoading}"/>
</Grid>
<GridSplitter Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3"
MinWidth="1" MinHeight="1"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Background="{DynamicResource Brush.Window}"
BorderBrush="{DynamicResource Brush.Border0}"/>
<Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3">
<Border Background="{DynamicResource Brush.Window}">
<Path Width="128" Height="128"
Data="{StaticResource Icons.Detail}"
HorizontalAlignment="Center"
Fill="{DynamicResource Brush.FG2}"/>
</Border>
<ContentControl Content="{Binding DetailContext}">
<ContentControl.DataTemplates>
<DataTemplate DataType="vm:CommitDetail">
<v:CommitDetail/>
</DataTemplate>
<DataTemplate DataType="vm:RevisionCompare">
<v:RevisionCompare/>
</DataTemplate>
<DataTemplate DataType="vm:CountSelectedCommits">
<Grid Background="{DynamicResource Brush.Window}">
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<Path Width="128" Height="128"
Data="{StaticResource Icons.Detail}"
HorizontalAlignment="Center"
Fill="{DynamicResource Brush.FG2}"/>
<TextBlock HorizontalAlignment="Center"
Margin="0,16"
FontSize="24" FontWeight="Bold"
Foreground="{DynamicResource Brush.FG2}"
Text="{Binding Count, Converter={x:Static c:StringConverters.FormatByResourceKey}, ConverterParameter='Histories.Selected'}"/>
</StackPanel>
</Grid>
</DataTemplate>
</ContentControl.DataTemplates>
</ContentControl>
</Grid>
</v:LayoutableGrid>
</UserControl>