refactor: remove duplicate ObjectConverters, remove unused using

This commit is contained in:
Gadfly 2024-04-13 18:54:46 +08:00
parent f4e1e0fb6b
commit 54c9552985
No known key found for this signature in database
GPG key ID: 9128145F93CFC69C
3 changed files with 2 additions and 20 deletions

View file

@ -1,13 +0,0 @@
using Avalonia.Data.Converters;
namespace SourceGit.Converters
{
public static class ObjectConverters
{
public static readonly FuncValueConverter<object, bool> IsNull =
new FuncValueConverter<object, bool>(v => v == null);
public static readonly FuncValueConverter<object, bool> IsNotNull =
new FuncValueConverter<object, bool>(v => v != null);
}
}

View file

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

View file

@ -27,7 +27,7 @@
<Path DockPanel.Dock="Right" Classes="rotating" Width="10" Height="10" Margin="8,0" Data="{StaticResource Icons.Loading}" IsVisible="{Binding IsLoading}"/> <Path DockPanel.Dock="Right" Classes="rotating" Width="10" Height="10" Margin="8,0" Data="{StaticResource Icons.Loading}" IsVisible="{Binding IsLoading}"/>
</DockPanel> </DockPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center" IsVisible="{Binding FileModeDiff, Converter={x:Static c:ObjectConverters.IsNotNull}}"> <StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center" IsVisible="{Binding FileModeDiff, Converter={x:Static ObjectConverters.IsNotNull}}">
<TextBlock Classes="monospace" Margin="8,0,0,0" Text="{DynamicResource Text.Diff.FileModeChanged}" FontSize="11"/> <TextBlock Classes="monospace" Margin="8,0,0,0" Text="{DynamicResource Text.Diff.FileModeChanged}" FontSize="11"/>
<TextBlock Classes="monospace" Text="{Binding FileModeDiff.Old}" FontSize="11"/> <TextBlock Classes="monospace" Text="{Binding FileModeDiff.Old}" FontSize="11"/>
<TextBlock Margin="4,0" Text="→"/> <TextBlock Margin="4,0" Text="→"/>