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.
44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
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);
|
|
}
|
|
}
|