fix: use TextTrimming alternative PathConverters

This commit is contained in:
Gadfly 2024-04-13 02:05:26 +08:00
parent f7dd856e49
commit f4e1e0fb6b
No known key found for this signature in database
GPG key ID: 9128145F93CFC69C
2 changed files with 9 additions and 2 deletions

View file

@ -3,6 +3,7 @@ using System.IO;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Avalonia.Threading;
@ -73,6 +74,11 @@ namespace SourceGit.ViewModels
set => SetProperty(ref _fileModeDiff, value);
}
public TextTrimming PathTrimming
{
get => _pathTrimming;
}
public DiffContext(string repo, Models.DiffOption option, DiffContext previous = null)
{
_repo = repo;
@ -193,5 +199,6 @@ namespace SourceGit.ViewModels
private object _content = null;
private Vector _syncScrollOffset = Vector.Zero;
private Models.FileModeDiff _fileModeDiff = null;
private TextTrimming _pathTrimming = new TextLeadingPrefixTrimming("...", 20);
}
}

View file

@ -22,8 +22,8 @@
<DockPanel Grid.Column="1" VerticalAlignment="Center">
<Path DockPanel.Dock="Left" Width="12" Height="12" Data="{StaticResource Icons.File}" Margin="8,0,0,0"/>
<TextBlock Classes="monospace" Margin="4,0,0,0" Text="{Binding FilePath, Converter={x:Static c:PathConverters.TruncateIfTooLong}}"
TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" HorizontalAlignment="Stretch" ToolTip.Tip="{Binding FilePath}" FontSize="11"/>
<TextBlock Classes="monospace" Margin="4,0,0,0" Text="{Binding FilePath}"
TextTrimming="{Binding PathTrimming}" TextWrapping="NoWrap" HorizontalAlignment="Stretch" ToolTip.Tip="{Binding FilePath}" FontSize="11"/>
<Path DockPanel.Dock="Right" Classes="rotating" Width="10" Height="10" Margin="8,0" Data="{StaticResource Icons.Loading}" IsVisible="{Binding IsLoading}"/>
</DockPanel>