refactor(ui): migrate DiffModal to ModalShell and use dynamic resources
Replace manual titlebar/drag handler with ModalShell, move Merge button to footer, convert StaticResource token attrs to DynamicResource, snap font sizes to tokens, use MonoFont DynamicResource, and fold tint color literals to RunningTintBrush/ErrorTintBrush. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
<Window xmlns="https://github.com/avaloniaui"
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:vm="using:ClaudeDo.Ui.ViewModels.Modals"
|
xmlns:vm="using:ClaudeDo.Ui.ViewModels.Modals"
|
||||||
|
xmlns:ctl="using:ClaudeDo.Ui.Views.Controls"
|
||||||
x:Class="ClaudeDo.Ui.Views.Modals.DiffModalView"
|
x:Class="ClaudeDo.Ui.Views.Modals.DiffModalView"
|
||||||
x:DataType="vm:DiffModalViewModel"
|
x:DataType="vm:DiffModalViewModel"
|
||||||
Title="Diff"
|
Title="Diff"
|
||||||
@@ -8,7 +9,7 @@
|
|||||||
WindowDecorations="None"
|
WindowDecorations="None"
|
||||||
ExtendClientAreaToDecorationsHint="True"
|
ExtendClientAreaToDecorationsHint="True"
|
||||||
WindowStartupLocation="CenterOwner"
|
WindowStartupLocation="CenterOwner"
|
||||||
Background="{StaticResource SurfaceBrush}">
|
Background="{DynamicResource SurfaceBrush}">
|
||||||
|
|
||||||
<Window.KeyBindings>
|
<Window.KeyBindings>
|
||||||
<KeyBinding Gesture="Escape" Command="{Binding CloseCommand}"/>
|
<KeyBinding Gesture="Escape" Command="{Binding CloseCommand}"/>
|
||||||
@@ -17,10 +18,10 @@
|
|||||||
<Window.Styles>
|
<Window.Styles>
|
||||||
<!-- diff line row tints via Tag selector (compiled-binding-friendly) -->
|
<!-- diff line row tints via Tag selector (compiled-binding-friendly) -->
|
||||||
<Style Selector="Border.diff-line[Tag=add]">
|
<Style Selector="Border.diff-line[Tag=add]">
|
||||||
<Setter Property="Background" Value="#1A4A6B4A"/>
|
<Setter Property="Background" Value="{StaticResource RunningTintBrush}"/>
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="Border.diff-line[Tag=del]">
|
<Style Selector="Border.diff-line[Tag=del]">
|
||||||
<Setter Property="Background" Value="#1AC87060"/>
|
<Setter Property="Background" Value="{StaticResource ErrorTintBrush}"/>
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="Border.diff-line[Tag=ctx]">
|
<Style Selector="Border.diff-line[Tag=ctx]">
|
||||||
<Setter Property="Background" Value="Transparent"/>
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
@@ -45,136 +46,114 @@
|
|||||||
</Style>
|
</Style>
|
||||||
</Window.Styles>
|
</Window.Styles>
|
||||||
|
|
||||||
<!-- Outer container — rectangular so the OS window rectangle stays filled (no black corners) -->
|
<ctl:ModalShell Title="DIFF" CloseCommand="{Binding CloseCommand}">
|
||||||
<Border Background="{StaticResource SurfaceBrush}"
|
<ctl:ModalShell.Footer>
|
||||||
BorderBrush="{StaticResource LineBrush}"
|
<StackPanel Orientation="Horizontal" Spacing="8"
|
||||||
BorderThickness="1">
|
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||||
<Grid RowDefinitions="36,*">
|
Margin="16,0">
|
||||||
|
<Button Content="Merge…" Command="{Binding MergeCommand}"/>
|
||||||
|
</StackPanel>
|
||||||
|
</ctl:ModalShell.Footer>
|
||||||
|
|
||||||
<!-- Title bar / drag handle -->
|
<!-- Body: sidebar + diff content -->
|
||||||
<Border Grid.Row="0"
|
<Grid ColumnDefinitions="240,*">
|
||||||
x:Name="TitleBar"
|
|
||||||
Background="{StaticResource Surface2Brush}"
|
<!-- File sidebar -->
|
||||||
BorderBrush="{StaticResource LineBrush}"
|
<Border Grid.Column="0"
|
||||||
BorderThickness="0,0,0,1"
|
BorderBrush="{DynamicResource LineBrush}"
|
||||||
PointerPressed="TitleBar_PointerPressed">
|
BorderThickness="0,0,1,0"
|
||||||
<Grid ColumnDefinitions="*,Auto" Margin="14,0">
|
Background="{DynamicResource DeepBrush}">
|
||||||
<TextBlock Text="Diff" VerticalAlignment="Center"
|
<ListBox ItemsSource="{Binding Files}"
|
||||||
FontFamily="{StaticResource MonoFamily}"
|
SelectedItem="{Binding SelectedFile, Mode=TwoWay}"
|
||||||
FontSize="12"
|
Background="Transparent"
|
||||||
Foreground="{StaticResource TextDimBrush}"/>
|
BorderThickness="0"
|
||||||
<StackPanel Grid.Column="1" Orientation="Horizontal" Spacing="4" VerticalAlignment="Center">
|
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
|
||||||
<Button Content="Merge…"
|
<ListBox.ItemTemplate>
|
||||||
Command="{Binding MergeCommand}"
|
<DataTemplate x:DataType="vm:DiffFileViewModel">
|
||||||
Margin="0,0,4,0" />
|
<Border Padding="10,8" Background="Transparent">
|
||||||
<Button Classes="icon-btn"
|
<StackPanel Spacing="4">
|
||||||
Content="✕"
|
<TextBlock Text="{Binding Path}"
|
||||||
FontSize="12"
|
FontFamily="{DynamicResource MonoFont}"
|
||||||
Command="{Binding CloseCommand}" />
|
FontSize="{StaticResource FontSizeMono}"
|
||||||
</StackPanel>
|
Foreground="{DynamicResource TextDimBrush}"
|
||||||
</Grid>
|
TextTrimming="PrefixCharacterEllipsis"/>
|
||||||
|
<StackPanel Orientation="Horizontal" Spacing="6">
|
||||||
|
<Border Classes="chip" Padding="5,2">
|
||||||
|
<TextBlock Foreground="{DynamicResource MossBrightBrush}"
|
||||||
|
FontFamily="{DynamicResource MonoFont}"
|
||||||
|
FontSize="{StaticResource FontSizeEyebrow}"
|
||||||
|
Text="{Binding Additions, StringFormat='+{0}'}"/>
|
||||||
|
</Border>
|
||||||
|
<Border Classes="chip" Padding="5,2">
|
||||||
|
<TextBlock Foreground="{DynamicResource BloodBrush}"
|
||||||
|
FontFamily="{DynamicResource MonoFont}"
|
||||||
|
FontSize="{StaticResource FontSizeEyebrow}"
|
||||||
|
Text="{Binding Deletions, StringFormat='−{0}'}"/>
|
||||||
|
</Border>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<!-- Body: sidebar + diff content -->
|
<!-- Diff content -->
|
||||||
<Grid Grid.Row="1" ColumnDefinitions="240,*">
|
<Grid Grid.Column="1" Background="{DynamicResource VoidBrush}">
|
||||||
|
<TextBlock Text="{Binding StatusMessage}"
|
||||||
<!-- File sidebar -->
|
IsVisible="{Binding StatusMessage, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
|
||||||
<Border Grid.Column="0"
|
HorizontalAlignment="Center"
|
||||||
BorderBrush="{StaticResource LineBrush}"
|
VerticalAlignment="Center"
|
||||||
BorderThickness="0,0,1,0"
|
Foreground="{DynamicResource TextDimBrush}"
|
||||||
Background="{StaticResource DeepBrush}">
|
FontFamily="{DynamicResource MonoFont}"
|
||||||
<ListBox ItemsSource="{Binding Files}"
|
FontSize="{StaticResource FontSizeBody}"/>
|
||||||
SelectedItem="{Binding SelectedFile, Mode=TwoWay}"
|
<ScrollViewer HorizontalScrollBarVisibility="Auto"
|
||||||
Background="Transparent"
|
VerticalScrollBarVisibility="Auto">
|
||||||
BorderThickness="0"
|
<ItemsControl ItemsSource="{Binding SelectedFile.Lines}">
|
||||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
|
<ItemsControl.ItemTemplate>
|
||||||
<ListBox.ItemTemplate>
|
<DataTemplate x:DataType="vm:DiffLineViewModel">
|
||||||
<DataTemplate x:DataType="vm:DiffFileViewModel">
|
<Border Classes="diff-line"
|
||||||
<Border Padding="10,8" Background="Transparent">
|
Tag="{Binding ClassName}"
|
||||||
<StackPanel Spacing="4">
|
Padding="4,1">
|
||||||
<TextBlock Text="{Binding Path}"
|
<Grid ColumnDefinitions="48,48,16,*">
|
||||||
FontFamily="{StaticResource MonoFamily}"
|
<!-- Old line number -->
|
||||||
FontSize="11"
|
<TextBlock Grid.Column="0"
|
||||||
Foreground="{StaticResource TextDimBrush}"
|
Text="{Binding OldNo}"
|
||||||
TextTrimming="PrefixCharacterEllipsis"/>
|
Classes="diff-lineno"
|
||||||
<StackPanel Orientation="Horizontal" Spacing="6">
|
FontFamily="{DynamicResource MonoFont}"
|
||||||
<Border Classes="chip" Padding="5,2">
|
FontSize="{StaticResource FontSizeMono}"
|
||||||
<TextBlock Foreground="{StaticResource MossBrightBrush}"
|
Foreground="{DynamicResource TextFaintBrush}"
|
||||||
FontFamily="{StaticResource MonoFamily}"
|
HorizontalAlignment="Right"
|
||||||
FontSize="10"
|
Margin="0,0,8,0"/>
|
||||||
Text="{Binding Additions, StringFormat='+{0}'}"/>
|
<!-- New line number -->
|
||||||
</Border>
|
<TextBlock Grid.Column="1"
|
||||||
<Border Classes="chip" Padding="5,2">
|
Text="{Binding NewNo}"
|
||||||
<TextBlock Foreground="{StaticResource BloodBrush}"
|
Classes="diff-lineno"
|
||||||
FontFamily="{StaticResource MonoFamily}"
|
FontFamily="{DynamicResource MonoFont}"
|
||||||
FontSize="10"
|
FontSize="{StaticResource FontSizeMono}"
|
||||||
Text="{Binding Deletions, StringFormat='\u2212{0}'}"/>
|
Foreground="{DynamicResource TextFaintBrush}"
|
||||||
</Border>
|
HorizontalAlignment="Right"
|
||||||
</StackPanel>
|
Margin="0,0,8,0"/>
|
||||||
</StackPanel>
|
<!-- Sign -->
|
||||||
</Border>
|
<TextBlock Grid.Column="2"
|
||||||
</DataTemplate>
|
Classes="diff-sign"
|
||||||
</ListBox.ItemTemplate>
|
Text="{Binding Sign}"
|
||||||
</ListBox>
|
FontFamily="{DynamicResource MonoFont}"
|
||||||
</Border>
|
FontSize="{StaticResource FontSizeMono}"/>
|
||||||
|
<!-- Line text -->
|
||||||
<!-- Diff content -->
|
<TextBlock Grid.Column="3"
|
||||||
<Grid Grid.Column="1" Background="{StaticResource VoidBrush}">
|
Classes="diff-text"
|
||||||
<TextBlock Text="{Binding StatusMessage}"
|
Text="{Binding Text}"
|
||||||
IsVisible="{Binding StatusMessage, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
|
FontFamily="{DynamicResource MonoFont}"
|
||||||
HorizontalAlignment="Center"
|
FontSize="{StaticResource FontSizeMono}"
|
||||||
VerticalAlignment="Center"
|
TextWrapping="NoWrap"/>
|
||||||
Foreground="{StaticResource TextDimBrush}"
|
</Grid>
|
||||||
FontFamily="{StaticResource MonoFamily}"
|
</Border>
|
||||||
FontSize="12"/>
|
</DataTemplate>
|
||||||
<ScrollViewer HorizontalScrollBarVisibility="Auto"
|
</ItemsControl.ItemTemplate>
|
||||||
VerticalScrollBarVisibility="Auto">
|
</ItemsControl>
|
||||||
<ItemsControl ItemsSource="{Binding SelectedFile.Lines}">
|
</ScrollViewer>
|
||||||
<ItemsControl.ItemTemplate>
|
|
||||||
<DataTemplate x:DataType="vm:DiffLineViewModel">
|
|
||||||
<Border Classes="diff-line"
|
|
||||||
Tag="{Binding ClassName}"
|
|
||||||
Padding="4,1">
|
|
||||||
<Grid ColumnDefinitions="48,48,16,*">
|
|
||||||
<!-- Old line number -->
|
|
||||||
<TextBlock Grid.Column="0"
|
|
||||||
Text="{Binding OldNo}"
|
|
||||||
Classes="diff-lineno"
|
|
||||||
FontFamily="{StaticResource MonoFamily}"
|
|
||||||
FontSize="11"
|
|
||||||
Foreground="{StaticResource TextFaintBrush}"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
Margin="0,0,8,0"/>
|
|
||||||
<!-- New line number -->
|
|
||||||
<TextBlock Grid.Column="1"
|
|
||||||
Text="{Binding NewNo}"
|
|
||||||
Classes="diff-lineno"
|
|
||||||
FontFamily="{StaticResource MonoFamily}"
|
|
||||||
FontSize="11"
|
|
||||||
Foreground="{StaticResource TextFaintBrush}"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
Margin="0,0,8,0"/>
|
|
||||||
<!-- Sign -->
|
|
||||||
<TextBlock Grid.Column="2"
|
|
||||||
Classes="diff-sign"
|
|
||||||
Text="{Binding Sign}"
|
|
||||||
FontFamily="{StaticResource MonoFamily}"
|
|
||||||
FontSize="11"/>
|
|
||||||
<!-- Line text -->
|
|
||||||
<TextBlock Grid.Column="3"
|
|
||||||
Classes="diff-text"
|
|
||||||
Text="{Binding Text}"
|
|
||||||
FontFamily="{StaticResource MonoFamily}"
|
|
||||||
FontSize="11"
|
|
||||||
TextWrapping="NoWrap"/>
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
</DataTemplate>
|
|
||||||
</ItemsControl.ItemTemplate>
|
|
||||||
</ItemsControl>
|
|
||||||
</ScrollViewer>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</ctl:ModalShell>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using Avalonia;
|
|||||||
using Avalonia.Animation;
|
using Avalonia.Animation;
|
||||||
using Avalonia.Animation.Easings;
|
using Avalonia.Animation.Easings;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Input;
|
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
using Avalonia.Styling;
|
using Avalonia.Styling;
|
||||||
using ClaudeDo.Ui.ViewModels.Modals;
|
using ClaudeDo.Ui.ViewModels.Modals;
|
||||||
@@ -43,10 +42,4 @@ public partial class DiffModalView : Window
|
|||||||
Opacity = 1;
|
Opacity = 1;
|
||||||
RenderTransform = new ScaleTransform(1.0, 1.0);
|
RenderTransform = new ScaleTransform(1.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TitleBar_PointerPressed(object? sender, PointerPressedEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
|
|
||||||
BeginMoveDrag(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user