feat(ui): accent color presets in Settings → General
Adds Moss / Peat / Sea preset swatches to the General settings tab. Selecting a preset mutates the live SolidColorBrush objects in the Application resource dictionary so all StaticResource consumers update instantly; the choice is persisted to ui.config.json and re-applied at startup. Missing or unknown saved value falls back to Moss.
This commit is contained in:
@@ -3,6 +3,7 @@ using Avalonia;
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
using ClaudeDo.Ui;
|
||||||
using ClaudeDo.Ui.Services;
|
using ClaudeDo.Ui.Services;
|
||||||
using ClaudeDo.Ui.ViewModels;
|
using ClaudeDo.Ui.ViewModels;
|
||||||
using ClaudeDo.Ui.Views;
|
using ClaudeDo.Ui.Views;
|
||||||
@@ -22,6 +23,8 @@ public partial class App : Application
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
AvaloniaXamlLoader.Load(this);
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
if (_services?.GetService<AppSettings>() is { } settings)
|
||||||
|
AccentPresetService.Apply(AccentPresets.Find(settings.AccentPreset));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnFrameworkInitializationCompleted()
|
public override void OnFrameworkInitializationCompleted()
|
||||||
|
|||||||
@@ -31,7 +31,11 @@
|
|||||||
"weekdayFriday": "Freitag",
|
"weekdayFriday": "Freitag",
|
||||||
"weekdaySaturday": "Samstag",
|
"weekdaySaturday": "Samstag",
|
||||||
"sessionSkills": "Session-Skills",
|
"sessionSkills": "Session-Skills",
|
||||||
"sessionSkillsHint": "Gilt für jede Aufgabe. Kombiniert sich mit Listen- und Aufgaben-Auswahl."
|
"sessionSkillsHint": "Gilt für jede Aufgabe. Kombiniert sich mit Listen- und Aufgaben-Auswahl.",
|
||||||
|
"accentPreset": "Akzentfarbe",
|
||||||
|
"accentPresetMoss": "Moos",
|
||||||
|
"accentPresetPeat": "Torf",
|
||||||
|
"accentPresetSea": "Meer"
|
||||||
},
|
},
|
||||||
"worktrees": {
|
"worktrees": {
|
||||||
"strategy": "Strategie",
|
"strategy": "Strategie",
|
||||||
|
|||||||
@@ -31,7 +31,11 @@
|
|||||||
"weekdayFriday": "Friday",
|
"weekdayFriday": "Friday",
|
||||||
"weekdaySaturday": "Saturday",
|
"weekdaySaturday": "Saturday",
|
||||||
"sessionSkills": "Session skills",
|
"sessionSkills": "Session skills",
|
||||||
"sessionSkillsHint": "Applied to every task. Combines with list- and task-level selections."
|
"sessionSkillsHint": "Applied to every task. Combines with list- and task-level selections.",
|
||||||
|
"accentPreset": "Accent color",
|
||||||
|
"accentPresetMoss": "Moss",
|
||||||
|
"accentPresetPeat": "Peat",
|
||||||
|
"accentPresetSea": "Sea"
|
||||||
},
|
},
|
||||||
"worktrees": {
|
"worktrees": {
|
||||||
"strategy": "Strategy",
|
"strategy": "Strategy",
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
using Avalonia.Media;
|
||||||
|
using ClaudeDo.Ui.Localization;
|
||||||
|
using ClaudeDo.Ui.ViewModels;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
|
||||||
|
namespace ClaudeDo.Ui;
|
||||||
|
|
||||||
|
public sealed record AccentPreset(string Name, string Accent, string Dim, string Soft, string Glow);
|
||||||
|
|
||||||
|
public static class AccentPresets
|
||||||
|
{
|
||||||
|
// Hue 88 — moss/sage green (original)
|
||||||
|
public static readonly AccentPreset Moss = new("moss", "#FF7C9166", "#FF64785A", "#FF3E4B39", "#387C9166");
|
||||||
|
// Hue ~40 — warm earthy brown/terra
|
||||||
|
public static readonly AccentPreset Peat = new("peat", "#FF9A7B5C", "#FF7F6449", "#FF4D3C2C", "#389A7B5C");
|
||||||
|
// Hue ~180 — cool teal/sea-green
|
||||||
|
public static readonly AccentPreset Sea = new("sea", "#FF5B8F8C", "#FF4A7573", "#FF263D3C", "#385B8F8C");
|
||||||
|
|
||||||
|
public static readonly IReadOnlyList<AccentPreset> All = [Moss, Peat, Sea];
|
||||||
|
public static AccentPreset Default => Moss;
|
||||||
|
|
||||||
|
public static AccentPreset Find(string? name) =>
|
||||||
|
All.FirstOrDefault(p => p.Name == name) ?? Default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed partial class AccentPresetSwatchViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
public AccentPreset Preset { get; }
|
||||||
|
|
||||||
|
[ObservableProperty] private bool _isSelected;
|
||||||
|
|
||||||
|
public Color DisplayColor { get; }
|
||||||
|
|
||||||
|
public string DisplayName =>
|
||||||
|
Loc.T($"settings.general.accentPreset{char.ToUpperInvariant(Preset.Name[0])}{Preset.Name.Substring(1)}");
|
||||||
|
|
||||||
|
public AccentPresetSwatchViewModel(AccentPreset preset, bool selected)
|
||||||
|
{
|
||||||
|
Preset = preset;
|
||||||
|
_isSelected = selected;
|
||||||
|
DisplayColor = Color.Parse(preset.Accent);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ public sealed class AppSettings
|
|||||||
public string DbPath { get; set; } = "~/.todo-app/todo.db";
|
public string DbPath { get; set; } = "~/.todo-app/todo.db";
|
||||||
public string SignalRUrl { get; set; } = "http://127.0.0.1:47821/hub";
|
public string SignalRUrl { get; set; } = "http://127.0.0.1:47821/hub";
|
||||||
public string Language { get; set; } = "";
|
public string Language { get; set; } = "";
|
||||||
|
public string AccentPreset { get; set; } = "";
|
||||||
|
|
||||||
private static readonly string ConfigPath = Paths.Expand("~/.todo-app/ui.config.json");
|
private static readonly string ConfigPath = Paths.Expand("~/.todo-app/ui.config.json");
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Media;
|
||||||
|
|
||||||
|
namespace ClaudeDo.Ui.Services;
|
||||||
|
|
||||||
|
public static class AccentPresetService
|
||||||
|
{
|
||||||
|
public static void Apply(AccentPreset preset)
|
||||||
|
{
|
||||||
|
if (Application.Current is not { } app) return;
|
||||||
|
|
||||||
|
SetBrushColor(app, "AccentBrush", preset.Accent);
|
||||||
|
SetBrushColor(app, "AccentDimBrush", preset.Dim);
|
||||||
|
SetBrushColor(app, "AccentSoftBrush", preset.Soft);
|
||||||
|
SetBrushColor(app, "AccentGlowBrush", preset.Glow);
|
||||||
|
SetBrushColor(app, "MossBrush", preset.Accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetBrushColor(Application app, string key, string hex)
|
||||||
|
{
|
||||||
|
if (app.TryGetResource(key, null, out var value) && value is SolidColorBrush brush)
|
||||||
|
brush.Color = Color.Parse(hex);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ using ClaudeDo.Localization;
|
|||||||
using ClaudeDo.Ui.Services;
|
using ClaudeDo.Ui.Services;
|
||||||
using ClaudeDo.Ui.ViewModels.Agent;
|
using ClaudeDo.Ui.ViewModels.Agent;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
|
||||||
namespace ClaudeDo.Ui.ViewModels.Modals.Settings;
|
namespace ClaudeDo.Ui.ViewModels.Modals.Settings;
|
||||||
|
|
||||||
@@ -27,6 +28,27 @@ public sealed partial class GeneralSettingsTabViewModel : ViewModelBase
|
|||||||
|
|
||||||
public ObservableCollection<SelectableSkillViewModel> SessionSkills { get; } = new();
|
public ObservableCollection<SelectableSkillViewModel> SessionSkills { get; } = new();
|
||||||
|
|
||||||
|
public ObservableCollection<AccentPresetSwatchViewModel> AccentPresetSwatches { get; } = new();
|
||||||
|
private Action<string>? _persistAccent;
|
||||||
|
|
||||||
|
public void InitAccentPresets(string saved, Action<string> persist)
|
||||||
|
{
|
||||||
|
_persistAccent = persist;
|
||||||
|
var current = AccentPresets.Find(saved);
|
||||||
|
AccentPresetSwatches.Clear();
|
||||||
|
foreach (var p in AccentPresets.All)
|
||||||
|
AccentPresetSwatches.Add(new AccentPresetSwatchViewModel(p, p.Name == current.Name));
|
||||||
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private void SelectAccentPreset(AccentPreset preset)
|
||||||
|
{
|
||||||
|
foreach (var s in AccentPresetSwatches)
|
||||||
|
s.IsSelected = s.Preset.Name == preset.Name;
|
||||||
|
AccentPresetService.Apply(preset);
|
||||||
|
_persistAccent?.Invoke(preset.Name);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>One editable row per model alias: the effort and turn budget a run gets under that
|
/// <summary>One editable row per model alias: the effort and turn budget a run gets under that
|
||||||
/// model. Supplies the global defaults; list- and task-level max-turns overrides still win.</summary>
|
/// model. Supplies the global defaults; list- and task-level max-turns overrides still win.</summary>
|
||||||
public ObservableCollection<ModelPresetRowViewModel> ModelPresets { get; } = new();
|
public ObservableCollection<ModelPresetRowViewModel> ModelPresets { get; } = new();
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ public sealed partial class SettingsModalViewModel : ViewModelBase
|
|||||||
appSettings.Language = code;
|
appSettings.Language = code;
|
||||||
appSettings.Save();
|
appSettings.Save();
|
||||||
});
|
});
|
||||||
|
General.InitAccentPresets(appSettings.AccentPreset, preset =>
|
||||||
|
{
|
||||||
|
appSettings.AccentPreset = preset;
|
||||||
|
appSettings.Save();
|
||||||
|
});
|
||||||
Worktrees = new WorktreesSettingsTabViewModel(worker);
|
Worktrees = new WorktreesSettingsTabViewModel(worker);
|
||||||
Files = new FilesSettingsTabViewModel(worker);
|
Files = new FilesSettingsTabViewModel(worker);
|
||||||
Prime = prime;
|
Prime = prime;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
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:settings="using:ClaudeDo.Ui.ViewModels.Modals.Settings"
|
xmlns:settings="using:ClaudeDo.Ui.ViewModels.Modals.Settings"
|
||||||
|
xmlns:ui="using:ClaudeDo.Ui"
|
||||||
xmlns:agent="using:ClaudeDo.Ui.ViewModels.Agent"
|
xmlns:agent="using:ClaudeDo.Ui.ViewModels.Agent"
|
||||||
xmlns:services="using:ClaudeDo.Ui.Services"
|
xmlns:services="using:ClaudeDo.Ui.Services"
|
||||||
xmlns:ctl="using:ClaudeDo.Ui.Views.Controls"
|
xmlns:ctl="using:ClaudeDo.Ui.Views.Controls"
|
||||||
@@ -61,6 +62,39 @@
|
|||||||
</ComboBox.ItemTemplate>
|
</ComboBox.ItemTemplate>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<StackPanel Spacing="4">
|
||||||
|
<TextBlock Classes="field-label" Text="{loc:Tr settings.general.accentPreset}"/>
|
||||||
|
<ItemsControl ItemsSource="{Binding General.AccentPresetSwatches}">
|
||||||
|
<ItemsControl.ItemsPanel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<StackPanel Orientation="Horizontal" Spacing="8"/>
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</ItemsControl.ItemsPanel>
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate x:DataType="ui:AccentPresetSwatchViewModel">
|
||||||
|
<Button Padding="6,4"
|
||||||
|
Command="{Binding $parent[ItemsControl].((vm:SettingsModalViewModel)DataContext).General.SelectAccentPresetCommand}"
|
||||||
|
CommandParameter="{Binding Preset}">
|
||||||
|
<StackPanel Spacing="4">
|
||||||
|
<Grid Width="32" Height="32">
|
||||||
|
<Border Width="32" Height="32" CornerRadius="16"
|
||||||
|
BorderBrush="{DynamicResource AccentBrush}" BorderThickness="2"
|
||||||
|
IsVisible="{Binding IsSelected}"/>
|
||||||
|
<Ellipse Width="22" Height="22"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||||
|
<Ellipse.Fill>
|
||||||
|
<SolidColorBrush Color="{Binding DisplayColor}"/>
|
||||||
|
</Ellipse.Fill>
|
||||||
|
</Ellipse>
|
||||||
|
</Grid>
|
||||||
|
<TextBlock Text="{Binding DisplayName}"
|
||||||
|
HorizontalAlignment="Center" FontSize="11"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
|
</StackPanel>
|
||||||
<StackPanel Spacing="4">
|
<StackPanel Spacing="4">
|
||||||
<TextBlock Classes="field-label" Text="{loc:Tr settings.general.defaultInstructions}"/>
|
<TextBlock Classes="field-label" Text="{loc:Tr settings.general.defaultInstructions}"/>
|
||||||
<TextBox AcceptsReturn="True" TextWrapping="Wrap" Height="110"
|
<TextBox AcceptsReturn="True" TextWrapping="Wrap" Height="110"
|
||||||
|
|||||||
Reference in New Issue
Block a user