Merge pull request #100 from gadfly3173/fix/base-info

fix: Fixed the issue when the email address is too long and exceeds the scope of the StackPanel
This commit is contained in:
leo 2024-05-03 11:20:06 +08:00 committed by GitHub
commit 9b10a867cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 24 deletions

View file

@ -1,4 +1,5 @@
using Avalonia.Data.Converters; using Avalonia.Controls;
using Avalonia.Data.Converters;
using Avalonia.Media; using Avalonia.Media;
namespace SourceGit.Converters namespace SourceGit.Converters
@ -10,5 +11,8 @@ namespace SourceGit.Converters
public static readonly FuncValueConverter<bool, FontWeight> BoldIfTrue = public static readonly FuncValueConverter<bool, FontWeight> BoldIfTrue =
new FuncValueConverter<bool, FontWeight>(x => x ? FontWeight.Bold : FontWeight.Regular); new FuncValueConverter<bool, FontWeight>(x => x ? FontWeight.Bold : FontWeight.Regular);
public static readonly FuncValueConverter<bool, GridLength> BoolToStarOrAutoGridLength =
new(value => value ? new GridLength(1, GridUnitType.Star) : new GridLength(1, GridUnitType.Auto));
} }
} }

View file

@ -12,35 +12,43 @@
<DataTemplate DataType="m:Commit"> <DataTemplate DataType="m:Commit">
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<!-- Author & Committer --> <!-- Author & Committer -->
<Grid ColumnDefinitions="96,*,96,*" Margin="0,8"> <Grid Margin="0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding IsCommitterVisible, Converter={x:Static c:BoolConverters.BoolToStarOrAutoGridLength}}"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Author --> <!-- Author -->
<Grid Grid.Column="0" ColumnDefinitions="96,*">
<v:Avatar Grid.Column="0" Width="64" Height="64" HorizontalAlignment="Right" User="{Binding Author}"/> <v:Avatar Grid.Column="0" Width="64" Height="64" HorizontalAlignment="Right" User="{Binding Author}"/>
<StackPanel Grid.Column="1" Margin="16,0,8,0" Orientation="Vertical"> <StackPanel Grid.Column="1" Margin="16,0,8,0" Orientation="Vertical">
<TextBlock Classes="group_header_label" Margin="0" Text="{DynamicResource Text.CommitDetail.Info.Author}"/> <TextBlock Classes="group_header_label" Margin="0" Text="{DynamicResource Text.CommitDetail.Info.Author}"/>
<StackPanel Orientation="Horizontal" Margin="0,10,0,8"> <DockPanel Margin="0,10,0,8" ClipToBounds="True">
<SelectableTextBlock Text="{Binding Author.Name}" Margin="2,0,8,0"/> <SelectableTextBlock Text="{Binding Author.Name}" Margin="2,0,8,0"/>
<SelectableTextBlock Text="{Binding Author.Email}" Foreground="{DynamicResource Brush.FG2}"/> <SelectableTextBlock Text="{Binding Author.Email}" ToolTip.Tip="{Binding Author.Email}" Foreground="{DynamicResource Brush.FG2}" TextTrimming="CharacterEllipsis"/>
</StackPanel> </DockPanel>
<SelectableTextBlock Text="{Binding AuthorTimeStr}" <SelectableTextBlock Text="{Binding AuthorTimeStr}"
Margin="2,0,0,0" Margin="2,0,0,0"
FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFontSize, Converter={x:Static c:FontSizeModifyConverters.Decrease}}" FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFontSize, Converter={x:Static c:FontSizeModifyConverters.Decrease}}"
Foreground="{DynamicResource Brush.FG2}"/> Foreground="{DynamicResource Brush.FG2}"/>
</StackPanel> </StackPanel>
</Grid>
<!-- Committer --> <!-- Committer -->
<v:Avatar Grid.Column="2" Width="64" Height="64" HorizontalAlignment="Right" User="{Binding Committer}" IsVisible="{Binding IsCommitterVisible}"/> <Grid Grid.Column="1" ColumnDefinitions="96,*" IsVisible="{Binding IsCommitterVisible}">
<StackPanel Grid.Column="3" Margin="16,0,8,0" Orientation="Vertical" IsVisible="{Binding IsCommitterVisible}"> <v:Avatar Grid.Column="0" Width="64" Height="64" HorizontalAlignment="Right" User="{Binding Committer}"/>
<StackPanel Grid.Column="1" Margin="16,0,8,0" Orientation="Vertical">
<TextBlock Classes="group_header_label" Margin="0" Text="{DynamicResource Text.CommitDetail.Info.Committer}"/> <TextBlock Classes="group_header_label" Margin="0" Text="{DynamicResource Text.CommitDetail.Info.Committer}"/>
<StackPanel Orientation="Horizontal" Margin="0,10,0,8"> <DockPanel Margin="0,10,0,8" ClipToBounds="True">
<SelectableTextBlock Text="{Binding Committer.Name}" Margin="2,0,8,0"/> <SelectableTextBlock Text="{Binding Committer.Name}" Margin="2,0,8,0"/>
<SelectableTextBlock Text="{Binding Committer.Email}" Foreground="{DynamicResource Brush.FG2}"/> <SelectableTextBlock Text="{Binding Committer.Email}" ToolTip.Tip="{Binding Committer.Email}" Foreground="{DynamicResource Brush.FG2}" TextTrimming="CharacterEllipsis"/>
</StackPanel> </DockPanel>
<SelectableTextBlock Text="{Binding CommitterTimeStr}" <SelectableTextBlock Text="{Binding CommitterTimeStr}"
Margin="2,0,0,0" Margin="2,0,0,0"
FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFontSize, Converter={x:Static c:FontSizeModifyConverters.Decrease}}" FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFontSize, Converter={x:Static c:FontSizeModifyConverters.Decrease}}"
Foreground="{DynamicResource Brush.FG2}"/> Foreground="{DynamicResource Brush.FG2}"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Grid>
<!-- Line --> <!-- Line -->
<Rectangle Height=".65" Margin="8" Fill="{DynamicResource Brush.Border2}" VerticalAlignment="Center"/> <Rectangle Height=".65" Margin="8" Fill="{DynamicResource Brush.Border2}" VerticalAlignment="Center"/>