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"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:ClaudeDo.Ui.ViewModels.Modals"
|
||||
xmlns:ctl="using:ClaudeDo.Ui.Views.Controls"
|
||||
x:Class="ClaudeDo.Ui.Views.Modals.DiffModalView"
|
||||
x:DataType="vm:DiffModalViewModel"
|
||||
Title="Diff"
|
||||
@@ -8,7 +9,7 @@
|
||||
WindowDecorations="None"
|
||||
ExtendClientAreaToDecorationsHint="True"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Background="{StaticResource SurfaceBrush}">
|
||||
Background="{DynamicResource SurfaceBrush}">
|
||||
|
||||
<Window.KeyBindings>
|
||||
<KeyBinding Gesture="Escape" Command="{Binding CloseCommand}"/>
|
||||
@@ -17,10 +18,10 @@
|
||||
<Window.Styles>
|
||||
<!-- diff line row tints via Tag selector (compiled-binding-friendly) -->
|
||||
<Style Selector="Border.diff-line[Tag=add]">
|
||||
<Setter Property="Background" Value="#1A4A6B4A"/>
|
||||
<Setter Property="Background" Value="{StaticResource RunningTintBrush}"/>
|
||||
</Style>
|
||||
<Style Selector="Border.diff-line[Tag=del]">
|
||||
<Setter Property="Background" Value="#1AC87060"/>
|
||||
<Setter Property="Background" Value="{StaticResource ErrorTintBrush}"/>
|
||||
</Style>
|
||||
<Style Selector="Border.diff-line[Tag=ctx]">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
@@ -45,44 +46,23 @@
|
||||
</Style>
|
||||
</Window.Styles>
|
||||
|
||||
<!-- Outer container — rectangular so the OS window rectangle stays filled (no black corners) -->
|
||||
<Border Background="{StaticResource SurfaceBrush}"
|
||||
BorderBrush="{StaticResource LineBrush}"
|
||||
BorderThickness="1">
|
||||
<Grid RowDefinitions="36,*">
|
||||
|
||||
<!-- Title bar / drag handle -->
|
||||
<Border Grid.Row="0"
|
||||
x:Name="TitleBar"
|
||||
Background="{StaticResource Surface2Brush}"
|
||||
BorderBrush="{StaticResource LineBrush}"
|
||||
BorderThickness="0,0,0,1"
|
||||
PointerPressed="TitleBar_PointerPressed">
|
||||
<Grid ColumnDefinitions="*,Auto" Margin="14,0">
|
||||
<TextBlock Text="Diff" VerticalAlignment="Center"
|
||||
FontFamily="{StaticResource MonoFamily}"
|
||||
FontSize="12"
|
||||
Foreground="{StaticResource TextDimBrush}"/>
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal" Spacing="4" VerticalAlignment="Center">
|
||||
<Button Content="Merge…"
|
||||
Command="{Binding MergeCommand}"
|
||||
Margin="0,0,4,0" />
|
||||
<Button Classes="icon-btn"
|
||||
Content="✕"
|
||||
FontSize="12"
|
||||
Command="{Binding CloseCommand}" />
|
||||
<ctl:ModalShell Title="DIFF" CloseCommand="{Binding CloseCommand}">
|
||||
<ctl:ModalShell.Footer>
|
||||
<StackPanel Orientation="Horizontal" Spacing="8"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="16,0">
|
||||
<Button Content="Merge…" Command="{Binding MergeCommand}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ctl:ModalShell.Footer>
|
||||
|
||||
<!-- Body: sidebar + diff content -->
|
||||
<Grid Grid.Row="1" ColumnDefinitions="240,*">
|
||||
<Grid ColumnDefinitions="240,*">
|
||||
|
||||
<!-- File sidebar -->
|
||||
<Border Grid.Column="0"
|
||||
BorderBrush="{StaticResource LineBrush}"
|
||||
BorderBrush="{DynamicResource LineBrush}"
|
||||
BorderThickness="0,0,1,0"
|
||||
Background="{StaticResource DeepBrush}">
|
||||
Background="{DynamicResource DeepBrush}">
|
||||
<ListBox ItemsSource="{Binding Files}"
|
||||
SelectedItem="{Binding SelectedFile, Mode=TwoWay}"
|
||||
Background="Transparent"
|
||||
@@ -93,22 +73,22 @@
|
||||
<Border Padding="10,8" Background="Transparent">
|
||||
<StackPanel Spacing="4">
|
||||
<TextBlock Text="{Binding Path}"
|
||||
FontFamily="{StaticResource MonoFamily}"
|
||||
FontSize="11"
|
||||
Foreground="{StaticResource TextDimBrush}"
|
||||
FontFamily="{DynamicResource MonoFont}"
|
||||
FontSize="{StaticResource FontSizeMono}"
|
||||
Foreground="{DynamicResource TextDimBrush}"
|
||||
TextTrimming="PrefixCharacterEllipsis"/>
|
||||
<StackPanel Orientation="Horizontal" Spacing="6">
|
||||
<Border Classes="chip" Padding="5,2">
|
||||
<TextBlock Foreground="{StaticResource MossBrightBrush}"
|
||||
FontFamily="{StaticResource MonoFamily}"
|
||||
FontSize="10"
|
||||
<TextBlock Foreground="{DynamicResource MossBrightBrush}"
|
||||
FontFamily="{DynamicResource MonoFont}"
|
||||
FontSize="{StaticResource FontSizeEyebrow}"
|
||||
Text="{Binding Additions, StringFormat='+{0}'}"/>
|
||||
</Border>
|
||||
<Border Classes="chip" Padding="5,2">
|
||||
<TextBlock Foreground="{StaticResource BloodBrush}"
|
||||
FontFamily="{StaticResource MonoFamily}"
|
||||
FontSize="10"
|
||||
Text="{Binding Deletions, StringFormat='\u2212{0}'}"/>
|
||||
<TextBlock Foreground="{DynamicResource BloodBrush}"
|
||||
FontFamily="{DynamicResource MonoFont}"
|
||||
FontSize="{StaticResource FontSizeEyebrow}"
|
||||
Text="{Binding Deletions, StringFormat='−{0}'}"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
@@ -119,14 +99,14 @@
|
||||
</Border>
|
||||
|
||||
<!-- Diff content -->
|
||||
<Grid Grid.Column="1" Background="{StaticResource VoidBrush}">
|
||||
<Grid Grid.Column="1" Background="{DynamicResource VoidBrush}">
|
||||
<TextBlock Text="{Binding StatusMessage}"
|
||||
IsVisible="{Binding StatusMessage, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{StaticResource TextDimBrush}"
|
||||
FontFamily="{StaticResource MonoFamily}"
|
||||
FontSize="12"/>
|
||||
Foreground="{DynamicResource TextDimBrush}"
|
||||
FontFamily="{DynamicResource MonoFont}"
|
||||
FontSize="{StaticResource FontSizeBody}"/>
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<ItemsControl ItemsSource="{Binding SelectedFile.Lines}">
|
||||
@@ -140,32 +120,32 @@
|
||||
<TextBlock Grid.Column="0"
|
||||
Text="{Binding OldNo}"
|
||||
Classes="diff-lineno"
|
||||
FontFamily="{StaticResource MonoFamily}"
|
||||
FontSize="11"
|
||||
Foreground="{StaticResource TextFaintBrush}"
|
||||
FontFamily="{DynamicResource MonoFont}"
|
||||
FontSize="{StaticResource FontSizeMono}"
|
||||
Foreground="{DynamicResource 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}"
|
||||
FontFamily="{DynamicResource MonoFont}"
|
||||
FontSize="{StaticResource FontSizeMono}"
|
||||
Foreground="{DynamicResource TextFaintBrush}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<!-- Sign -->
|
||||
<TextBlock Grid.Column="2"
|
||||
Classes="diff-sign"
|
||||
Text="{Binding Sign}"
|
||||
FontFamily="{StaticResource MonoFamily}"
|
||||
FontSize="11"/>
|
||||
FontFamily="{DynamicResource MonoFont}"
|
||||
FontSize="{StaticResource FontSizeMono}"/>
|
||||
<!-- Line text -->
|
||||
<TextBlock Grid.Column="3"
|
||||
Classes="diff-text"
|
||||
Text="{Binding Text}"
|
||||
FontFamily="{StaticResource MonoFamily}"
|
||||
FontSize="11"
|
||||
FontFamily="{DynamicResource MonoFont}"
|
||||
FontSize="{StaticResource FontSizeMono}"
|
||||
TextWrapping="NoWrap"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
@@ -175,6 +155,5 @@
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ctl:ModalShell>
|
||||
</Window>
|
||||
|
||||
@@ -2,7 +2,6 @@ using Avalonia;
|
||||
using Avalonia.Animation;
|
||||
using Avalonia.Animation.Easings;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Styling;
|
||||
using ClaudeDo.Ui.ViewModels.Modals;
|
||||
@@ -43,10 +42,4 @@ public partial class DiffModalView : Window
|
||||
Opacity = 1;
|
||||
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