refactor(ui): migrate SettingsModal to ModalShell

This commit is contained in:
mika kuns
2026-05-30 16:40:09 +02:00
parent c20fbe3613
commit 4f5db367a7
2 changed files with 187 additions and 251 deletions

View File

@@ -22,67 +22,26 @@
<conv:TimeSpanToHhmmConverter x:Key="TimeSpanToHhmm"/> <conv:TimeSpanToHhmmConverter x:Key="TimeSpanToHhmm"/>
</Window.Resources> </Window.Resources>
<Window.Styles> <ctl:ModalShell Title="SETTINGS" CloseCommand="{Binding CancelCommand}">
<Style Selector="TextBlock.section-label"> <ctl:ModalShell.Footer>
<Setter Property="FontFamily" Value="{DynamicResource MonoFont}"/> <StackPanel Orientation="Horizontal" Spacing="8"
<Setter Property="FontSize" Value="10"/> HorizontalAlignment="Right" VerticalAlignment="Center"
<Setter Property="LetterSpacing" Value="1.4"/> Margin="16,0">
<Setter Property="Foreground" Value="{DynamicResource TextFaintBrush}"/> <Button Content="Cancel" Command="{Binding CancelCommand}" MinWidth="90"/>
<Setter Property="Margin" Value="4,0,0,6"/> <Button Content="Save" Classes="primary"
</Style> Command="{Binding SaveCommand}"
<Style Selector="TextBlock.field-label"> IsEnabled="{Binding !IsBusy}" MinWidth="90"/>
<Setter Property="FontSize" Value="11"/> </StackPanel>
<Setter Property="Foreground" Value="{DynamicResource TextDimBrush}"/> </ctl:ModalShell.Footer>
<Setter Property="Margin" Value="0,0,0,4"/>
</Style>
<Style Selector="TextBlock.path-mono">
<Setter Property="FontFamily" Value="{DynamicResource MonoFont}"/>
<Setter Property="FontSize" Value="11"/>
<Setter Property="Foreground" Value="{DynamicResource TextDimBrush}"/>
<Setter Property="TextTrimming" Value="CharacterEllipsis"/>
</Style>
<Style Selector="Button.danger">
<Setter Property="Background" Value="{DynamicResource BloodBrush}"/>
<Setter Property="Foreground" Value="White"/>
</Style>
<Style Selector="Button.primary">
<Setter Property="Background" Value="{DynamicResource AccentBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource DeepBrush}"/>
<Setter Property="FontWeight" Value="SemiBold"/>
</Style>
</Window.Styles>
<Border Background="{DynamicResource SurfaceBrush}"
BorderBrush="{DynamicResource LineBrush}"
BorderThickness="1">
<Grid RowDefinitions="36,*,52">
<!-- Title bar -->
<Border Grid.Row="0" x:Name="TitleBar"
Background="{DynamicResource DeepBrush}"
BorderBrush="{DynamicResource LineBrush}"
BorderThickness="0,0,0,1"
PointerPressed="TitleBar_PointerPressed">
<Grid ColumnDefinitions="*,Auto" Margin="14,0">
<TextBlock Text="SETTINGS"
FontFamily="{DynamicResource MonoFont}"
FontSize="11"
LetterSpacing="1.4"
Foreground="{DynamicResource TextBrush}"
VerticalAlignment="Center"/>
<Button Grid.Column="1" Classes="icon-btn" Content="✕" FontSize="12"
Command="{Binding CancelCommand}" VerticalAlignment="Center"/>
</Grid>
</Border>
<!-- Body: tabs + bottom validation/status strip --> <!-- Body: tabs + bottom validation/status strip -->
<DockPanel Grid.Row="1"> <DockPanel>
<StackPanel DockPanel.Dock="Bottom" Margin="20,0,20,8" Spacing="2"> <StackPanel DockPanel.Dock="Bottom" Margin="20,0,20,8" Spacing="2">
<TextBlock Text="{Binding ValidationError}" <TextBlock Text="{Binding ValidationError}"
Foreground="{DynamicResource BloodBrush}" FontSize="11" Foreground="{DynamicResource BloodBrush}" FontSize="{StaticResource FontSizeBody}"
IsVisible="{Binding ValidationError, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/> IsVisible="{Binding ValidationError, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/>
<TextBlock Text="{Binding StatusMessage}" <TextBlock Text="{Binding StatusMessage}"
Foreground="{DynamicResource TextDimBrush}" FontSize="11" Foreground="{DynamicResource TextDimBrush}" FontSize="{StaticResource FontSizeBody}"
IsVisible="{Binding StatusMessage, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/> IsVisible="{Binding StatusMessage, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/>
</StackPanel> </StackPanel>
@@ -171,7 +130,7 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<TextBlock Text="{Binding Worktrees.StatusMessage}" <TextBlock Text="{Binding Worktrees.StatusMessage}"
Foreground="{DynamicResource TextDimBrush}" FontSize="11" Foreground="{DynamicResource TextDimBrush}" FontSize="{StaticResource FontSizeBody}"
IsVisible="{Binding Worktrees.StatusMessage, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/> IsVisible="{Binding Worktrees.StatusMessage, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/>
</StackPanel> </StackPanel>
</ScrollViewer> </ScrollViewer>
@@ -183,7 +142,7 @@
<StackPanel Spacing="6"> <StackPanel Spacing="6">
<TextBlock Classes="section-label" Text="AGENTS"/> <TextBlock Classes="section-label" Text="AGENTS"/>
<TextBlock Text="Restore bundled default agents. Existing files are not overwritten." <TextBlock Text="Restore bundled default agents. Existing files are not overwritten."
FontSize="11" TextWrapping="Wrap" FontSize="{StaticResource FontSizeBody}" TextWrapping="Wrap"
Foreground="{DynamicResource TextDimBrush}"/> Foreground="{DynamicResource TextDimBrush}"/>
<Button Content="Restore default agents" <Button Content="Restore default agents"
Command="{Binding Files.RestoreDefaultAgentsCommand}" Command="{Binding Files.RestoreDefaultAgentsCommand}"
@@ -208,7 +167,7 @@
</Grid> </Grid>
</StackPanel> </StackPanel>
<TextBlock Text="{Binding Files.StatusMessage}" <TextBlock Text="{Binding Files.StatusMessage}"
Foreground="{DynamicResource TextDimBrush}" FontSize="11" Foreground="{DynamicResource TextDimBrush}" FontSize="{StaticResource FontSizeBody}"
IsVisible="{Binding Files.StatusMessage, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/> IsVisible="{Binding Files.StatusMessage, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/>
</StackPanel> </StackPanel>
</ScrollViewer> </ScrollViewer>
@@ -217,7 +176,7 @@
<TabItem Header="Prime Claude"> <TabItem Header="Prime Claude">
<ScrollViewer> <ScrollViewer>
<StackPanel Spacing="12" Margin="0,8,0,0"> <StackPanel Spacing="12" Margin="0,8,0,0">
<TextBlock TextWrapping="Wrap" FontSize="11" <TextBlock TextWrapping="Wrap" FontSize="{StaticResource FontSizeBody}"
Foreground="{DynamicResource TextDimBrush}" Foreground="{DynamicResource TextDimBrush}"
Text="Prime your Claude usage window each morning by firing a single non-interactive ping at a chosen time. Only runs while ClaudeDo is open. If the app starts within 30 minutes of the target time, the ping fires immediately."/> Text="Prime your Claude usage window each morning by firing a single non-interactive ping at a chosen time. Only runs while ClaudeDo is open. If the app starts within 30 minutes of the target time, the ping fires immediately."/>
<ItemsControl ItemsSource="{Binding Prime.Rows}"> <ItemsControl ItemsSource="{Binding Prime.Rows}">
@@ -240,7 +199,7 @@
<CheckBox Grid.Column="3" Content="MonFri" <CheckBox Grid.Column="3" Content="MonFri"
IsChecked="{Binding WorkdaysOnly, Mode=TwoWay}" VerticalAlignment="Center"/> IsChecked="{Binding WorkdaysOnly, Mode=TwoWay}" VerticalAlignment="Center"/>
<TextBlock Grid.Column="4" Text="{Binding LastRunLabel}" VerticalAlignment="Center" <TextBlock Grid.Column="4" Text="{Binding LastRunLabel}" VerticalAlignment="Center"
Foreground="{DynamicResource TextDimBrush}" FontSize="11" Foreground="{DynamicResource TextDimBrush}" FontSize="{StaticResource FontSizeBody}"
MinWidth="80"/> MinWidth="80"/>
<Button Grid.Column="5" Content="✕" <Button Grid.Column="5" Content="✕"
Command="{Binding $parent[ItemsControl].((vm:SettingsModalViewModel)DataContext).Prime.RemoveScheduleCommand}" Command="{Binding $parent[ItemsControl].((vm:SettingsModalViewModel)DataContext).Prime.RemoveScheduleCommand}"
@@ -258,21 +217,5 @@
</TabControl> </TabControl>
</DockPanel> </DockPanel>
<!-- Footer --> </ctl:ModalShell>
<Border Grid.Row="2"
Background="{DynamicResource DeepBrush}"
BorderBrush="{DynamicResource LineBrush}"
BorderThickness="0,1,0,0">
<StackPanel Orientation="Horizontal" Spacing="8"
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="16,0">
<Button Content="Cancel" Command="{Binding CancelCommand}" MinWidth="90"/>
<Button Content="Save" Classes="primary"
Command="{Binding SaveCommand}"
IsEnabled="{Binding !IsBusy}" MinWidth="90"/>
</StackPanel>
</Border>
</Grid>
</Border>
</Window> </Window>

View File

@@ -1,5 +1,4 @@
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input;
using ClaudeDo.Ui.ViewModels.Modals; using ClaudeDo.Ui.ViewModels.Modals;
namespace ClaudeDo.Ui.Views.Modals; namespace ClaudeDo.Ui.Views.Modals;
@@ -17,10 +16,4 @@ public partial class SettingsModalView : Window
if (DataContext is SettingsModalViewModel vm) if (DataContext is SettingsModalViewModel vm)
vm.CloseAction = Close; vm.CloseAction = Close;
} }
private void TitleBar_PointerPressed(object? sender, PointerPressedEventArgs e)
{
if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
BeginMoveDrag(e);
}
} }