using Microsoft.Maui.Graphics; namespace cfs_tracker.Helpers; public static class ColorUtility { public static bool IsHexColor(string? value) { if (string.IsNullOrWhiteSpace(value)) return false; try { _ = Color.FromArgb(NormalizeHex(value)); return true; } catch { return false; } } public static Color ParseColor(string? value, string fallbackHex) { try { return Color.FromArgb(NormalizeHex(value)); } catch { return Color.FromArgb(NormalizeHex(fallbackHex)); } } public static string NormalizeHex(string? value) { var text = (value ?? string.Empty).Trim(); if (string.IsNullOrWhiteSpace(text)) return "#000000"; if (!text.StartsWith('#')) text = "#" + text; return text.ToUpperInvariant(); } }