feat(sprint-3): apply Survey Teal field UI

This commit is contained in:
Brent Perteet
2026-08-20 22:00:31 -05:00
parent f9fb9f59f4
commit 5e87d81bb6
16 changed files with 954 additions and 562 deletions

View File

@@ -0,0 +1,38 @@
namespace FieldLogger.Resources.Styles;
public enum UlThemeMode
{
Default,
Sunlight,
}
/// <summary>Applies generated semantic colors. Call on the UI thread after app resources initialize.</summary>
public static class ThemeManager
{
private static readonly string[] SemanticColors =
[
"Canvas", "Surface", "SurfaceRaised", "SurfaceStrong", "Text", "TextMuted",
"Primary", "PrimaryPressed", "Accent", "Border", "Focus", "Map", "Success",
"Warning", "Error", "Neutral", "Disabled", "OnStrong", "OnPrimary", "OnAccent",
];
public static UlThemeMode Current { get; private set; } = UlThemeMode.Default;
public static void Apply(UlThemeMode mode)
{
var resources = Application.Current?.Resources
?? throw new InvalidOperationException("Application resources are not initialized.");
var prefix = mode == UlThemeMode.Sunlight ? "UlSunlightColor" : "UlDefaultColor";
foreach (var name in SemanticColors)
{
if (!resources.TryGetValue($"{prefix}{name}", out var value) || value is not Color color)
{
throw new InvalidOperationException($"Generated theme token {prefix}{name} is missing.");
}
resources[$"UlColor{name}"] = color;
resources[$"UlBrush{name}"] = new SolidColorBrush(color);
}
Current = mode;
}
}