refactor: rewrite lfs pointer detection and image loading

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-06-05 21:06:31 +08:00
parent eebadd67a1
commit a023a9259b
No known key found for this signature in database
14 changed files with 286 additions and 199 deletions

View file

@ -224,7 +224,29 @@
<!-- LFS Diff -->
<DataTemplate DataType="m:LFSDiff">
<v:LFSDiffView/>
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
<TextBlock Text="{DynamicResource Text.Diff.LFS}"
Margin="0,0,0,32"
FontSize="18" FontWeight="Bold"
Foreground="{DynamicResource Brush.FG2}"
HorizontalAlignment="Center"/>
<Path Width="64" Height="64" Data="{StaticResource Icons.LFS}" Fill="{DynamicResource Brush.FG2}"/>
<Grid Margin="0,16,0,0" HorizontalAlignment="Center" RowDefinitions="32,32" ColumnDefinitions="Auto,Auto,Auto">
<Border Grid.Row="0" Grid.Column="0" Height="16" Background="{DynamicResource Brush.Badge}" CornerRadius="8" VerticalAlignment="Center">
<TextBlock Classes="primary" Text="{DynamicResource Text.Diff.Binary.Old}" Margin="8,0" FontSize="10" Foreground="{DynamicResource Brush.BadgeFG}"/>
</Border>
<TextBlock Grid.Row="0" Grid.Column="1" Classes="primary" Text="{Binding Old.Size}" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Right" FontSize="16" Margin="8,0"/>
<TextBlock Grid.Row="0" Grid.Column="2" Classes="primary" Text="{DynamicResource Text.Bytes}" Foreground="{DynamicResource Brush.FG2}" FontSize="16"/>
<Border Grid.Row="1" Grid.Column="0" Height="16" Background="Green" CornerRadius="8" VerticalAlignment="Center">
<TextBlock Classes="primary" Text="{DynamicResource Text.Diff.Binary.New}" Margin="8,0" FontSize="10"/>
</Border>
<TextBlock Grid.Row="1" Grid.Column="1" Classes="primary" Text="{Binding New.Size}" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Right" FontSize="16" Margin="8,0"/>
<TextBlock Grid.Row="1" Grid.Column="2" Classes="primary" Text="{DynamicResource Text.Bytes}" Foreground="{DynamicResource Brush.FG2}" FontSize="16"/>
</Grid>
</StackPanel>
</DataTemplate>
<!-- Submodule Diff -->
@ -282,7 +304,7 @@
<!-- LFS Image Diff -->
<DataTemplate DataType="vm:LFSImageDiff">
<TabControl Margin="0,8,0,0" SelectedIndex="{Binding Source={x:Static vm:Preferences.Instance}, Path=LFSImageDiffActiveIdx, Mode=TwoWay}">
<TabControl Margin="0,8,0,0" SelectedIndex="{Binding Source={x:Static vm:Preferences.Instance}, Path=LFSImageActiveIdx, Mode=TwoWay}">
<TabControl.Styles>
<Style Selector="TabControl /template/ ItemsPresenter#PART_ItemsPresenter > WrapPanel">
<Setter Property="HorizontalAlignment" Value="Center"/>
@ -294,13 +316,7 @@
<TextBlock Text="LFS" FontWeight="Bold"/>
</TabItem.Header>
<ContentControl Content="{Binding LFS}">
<ContentControl.DataTemplates>
<DataTemplate DataType="m:LFSDiff">
<v:LFSDiffView/>
</DataTemplate>
</ContentControl.DataTemplates>
</ContentControl>
<ContentControl Content="{Binding LFS}"/>
</TabItem>
<TabItem>
@ -308,13 +324,7 @@
<TextBlock Text="IMAGE" FontWeight="Bold"/>
</TabItem.Header>
<ContentControl Content="{Binding Image}">
<ContentControl.DataTemplates>
<DataTemplate DataType="m:ImageDiff">
<v:ImageDiffView/>
</DataTemplate>
</ContentControl.DataTemplates>
</ContentControl>
<ContentControl Content="{Binding Image}"/>
</TabItem>
</TabControl>
</DataTemplate>