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.
25 lines
766 B
C#
25 lines
766 B
C#
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);
|
|
}
|
|
}
|