Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
feat(theme): add Material You pastel palette engine, monochrome preset, and donut opacity control
gtxPrimea5afb3e5f2f4
diff --git a/src/Filee.App/Controls/DonutMenu.Progress.cs b/src/Filee.App/Controls/DonutMenu.Progress.csindex fb0fd851..af04c94a 100644--- a/src/Filee.App/Controls/DonutMenu.Progress.cs+++ b/src/Filee.App/Controls/DonutMenu.Progress.cs@@ -319,10 +319,11 @@ public sealed partial class DonutMenuusing var _ = context.PushTransform(ringTransform);using var __ = context.PushOpacity(opacity);- var plateRadius = RingRadius + RingStroke + 2;+ var stroke = IsMaterialYou ? 10.0 : RingStroke;+ var plateRadius = RingRadius + stroke + 2;DrawPlateShadow(context, center, plateRadius);context.DrawEllipse(CenterBrush, BorderPen(), center, plateRadius, plateRadius);- context.DrawEllipse(null, new Pen(WithOpacity(SecondaryForeground, 0.22), RingStroke), center, RingRadius, RingRadius);+ context.DrawEllipse(null, new Pen(WithOpacity(SecondaryForeground, IsMaterialYou ? 0.16 : 0.22), stroke), center, RingRadius, RingRadius);var arcBrush = _outcome switch{@@ -331,7 +332,7 @@ public sealed partial class DonutMenu_ => AccentBrush,};var sweep = _outcome == DonutProgressOutcome.Failed ? Math.Max(_shownProgress, 0.02) : _shownProgress;- DrawArc(context, center, RingRadius, sweep, new Pen(arcBrush, RingStroke, lineCap: PenLineCap.Round));+ DrawArc(context, center, RingRadius, sweep, new Pen(arcBrush, stroke, lineCap: PenLineCap.Round));var badge = _outcome is null ? 0 : Math.Max(0, _badge.Value);if (badge < 0.98)diff --git a/src/Filee.App/Controls/DonutMenu.cs b/src/Filee.App/Controls/DonutMenu.csindex 29ef8627..bcc84dcb 100644--- a/src/Filee.App/Controls/DonutMenu.cs+++ b/src/Filee.App/Controls/DonutMenu.cs@@ -89,6 +89,10 @@ public sealed partial class DonutMenu : Controlpublic static readonly StyledProperty<IBrush?> DangerBrushProperty =AvaloniaProperty.Register<DonutMenu, IBrush?>(nameof(DangerBrush), Brushes.IndianRed);+ /// <summary>Material You (Material Design 3) styling and expressive motion.</summary>+ public static readonly StyledProperty<bool> IsMaterialYouProperty =+ AvaloniaProperty.Register<DonutMenu, bool>(nameof(IsMaterialYou));+/// <summary>Gap between slices in pixels (keeps the donut "full" while separating slices).</summary>private const double GapPixels = 3;private const double PopOut = 7;@@ -131,7 +135,8 @@ public sealed partial class DonutMenu : ControlAffectsMeasure<DonutMenu>(OuterRadiusProperty, ReserveSubRingProperty);AffectsRender<DonutMenu>(HoleRatioProperty, SliceOpacityProperty, CenterTitleProperty, CenterSubtitleProperty,IsEditModeProperty, SliceBrushProperty, SliceBorderBrushProperty, CenterBrushProperty, AccentBrushProperty,- OnAccentBrushProperty, ForegroundProperty, SecondaryForegroundProperty, SuccessBrushProperty, CornerRadiusProperty);+ OnAccentBrushProperty, ForegroundProperty, SecondaryForegroundProperty, SuccessBrushProperty, CornerRadiusProperty,+ IsMaterialYouProperty);ItemsProperty.Changed.AddClassHandler<DonutMenu>((d, _) => d.OnItemsChanged());}@@ -170,6 +175,7 @@ public sealed partial class DonutMenu : Controlpublic IBrush? Foreground { get => GetValue(ForegroundProperty); set => SetValue(ForegroundProperty, value); }public IBrush? SecondaryForeground { get => GetValue(SecondaryForegroundProperty); set => SetValue(SecondaryForegroundProperty, value); }public IBrush? DangerBrush { get => GetValue(DangerBrushProperty); set => SetValue(DangerBrushProperty, value); }+ public bool IsMaterialYou { get => GetValue(IsMaterialYouProperty); set => SetValue(IsMaterialYouProperty, value); }/// <summary>True while an external drag hovers the hole (drop = cancel).</summary>public bool IsCenterHot => _externalCenterHot;@@ -735,10 +741,11 @@ public sealed partial class DonutMenu : Control// Popping out bounces; letting go settles without a bounce: one below zero would make the faded accent// flash once more on its way back.for (var i = 0; i < _hover.Length; i++)- active |= i == ActiveIndex ? _hover[i].Step(1, dt) : _hover[i].Step(0, dt, 320, CriticalDamping);- active |= _centerPulse.Step(0, dt, 260, 12);- // A soft bounce opening, like the slices popping out; folding away settles without one. The bounce grows the- // ring by about a pixel, well inside the room kept for it (SubRingSpace).+ active |= i == ActiveIndex+ ? _hover[i].Step(1, dt, IsMaterialYou ? 380 : 280, IsMaterialYou ? 24 : 18)+ : _hover[i].Step(0, dt, 320, CriticalDamping);+ active |= _centerPulse.Step(0, dt, IsMaterialYou ? 280 : 260, IsMaterialYou ? 14 : 12);+ // A soft bounce opening, like the slices popping out; folding away settles without one.active |= _expanded >= 0 ? _expand.Step(1, dt, 320, 24) : _expand.Step(0, dt, 320, CriticalDamping);if (_expanded < 0 && _expand.Value <= 0.001)_shownExpanded = -1;@@ -779,10 +786,10 @@ public sealed partial class DonutMenu : Controlcallback?.Invoke();}- private static double EaseOutBack(double t)+ private double EaseOutBack(double t){- const double c1 = 1.55;- const double c3 = c1 + 1;+ double c1 = IsMaterialYou ? 1.75 : 1.55;+ double c3 = c1 + 1;return 1 + c3 * Math.Pow(t - 1, 3) + c1 * Math.Pow(t - 1, 2);}@@ -828,27 +835,39 @@ public sealed partial class DonutMenu : Controlvar span = previewing ? _span[i].Value : DonutGeometry.Span(n);if (span < 0.01)continue;- var offset = DonutGeometry.PointAt(new Point(0, 0), hover * PopOut, mid);+ var pop = IsMaterialYou ? PopOut * 1.4 : PopOut;+ var offset = DonutGeometry.PointAt(new Point(0, 0), hover * pop, mid);// Open animation: scale up from the centre with a small twist.var scale = 0.55 + 0.45 * open;- var rotate = (1 - Math.Min(open, 1)) * -0.35;+ var rotate = (1 - Math.Min(open, 1)) * (IsMaterialYou ? -0.22 : -0.35);+ var hoverScale = IsMaterialYou ? 1 + hover * 0.045 : 1 + hover * 0.025;var transform =Matrix.CreateTranslation(-center.X, -center.Y) *Matrix.CreateRotation(rotate) *- Matrix.CreateScale(scale * (1 + hover * 0.025), scale * (1 + hover * 0.025)) *+ Matrix.CreateScale(scale * hoverScale, scale * hoverScale) *Matrix.CreateTranslation(center.X + offset.X, center.Y + offset.Y);using (context.PushTransform(transform))using (context.PushOpacity(Math.Clamp(open, 0, 1) * (i == _dimmedIndex ? 0.3 : 1))){- var wedge = CreateWedge(center, r1, r2, mid, span);+ var corner = IsMaterialYou ? Math.Max(12, SliceCornerRadius * 1.4) : SliceCornerRadius;+ var gap = IsMaterialYou ? 4.5 : GapPixels;+ var wedge = CreateWedge(center, r1, r2, mid, span, corner, gap);++ if (IsMaterialYou && hover > 0.02)+ {+ // Ambient glow / elevation for active floating slice in Material You+ var glowPen = new Pen(WithOpacity(AccentBrush, 0.28 * Math.Clamp(hover, 0, 1)), 4);+ context.DrawGeometry(null, glowPen, wedge);+ }+context.DrawGeometry(WithOpacity(SliceBrush, SliceOpacity * (item.IsEnabled ? 1 : 0.55)), BorderPen(), wedge);// The accent fades in and out with the highlight (no floor: a floor made it vanish with a jump).var emphasis = i == _dropTargetIndex ? 1.0 : hover;if (emphasis > 0.01 && item.IsEnabled)- context.DrawGeometry(WithOpacity(AccentBrush, 0.82 * Math.Clamp(emphasis, 0, 1)), null, wedge);+ context.DrawGeometry(WithOpacity(AccentBrush, (IsMaterialYou ? 0.95 : 0.82) * Math.Clamp(emphasis, 0, 1)), null, wedge);var hot = (i == ActiveIndex || i == _dropTargetIndex) && item.IsEnabled;DrawLabel(context, item, center, (r1 + r2) / 2, mid, span * (r1 + r2) / 2 - 10,@@ -892,21 +911,59 @@ public sealed partial class DonutMenu : Controlprivate void DrawCenter(DrawingContext context, Point center, double r1, Typeface bold, Typeface regular){- var pulse = 1 + _centerPulse.Value * 0.06;+ var pulse = 1 + _centerPulse.Value * (IsMaterialYou ? 0.08 : 0.06);var radius = (r1 - 6) * pulse;var cancelHot = _externalCenterHot;++ if (IsMaterialYou)+ DrawCenterShadow(context, center, radius);+context.DrawEllipse(CenterBrush, BorderPen(), center, radius, radius);if (cancelHot)- context.DrawEllipse(WithOpacity(DangerBrush, 0.18), null, center, radius, radius);+ context.DrawEllipse(WithOpacity(DangerBrush, IsMaterialYou ? 0.32 : 0.18), null, center, radius, radius);var maxWidth = radius * 1.6;- var title = MakeText(CenterTitle ?? "", bold, 14, Foreground, maxWidth, maxLines: 2);- var subtitle = MakeText(CenterSubtitle ?? "", regular, 11.5, cancelHot ? DangerBrush : SecondaryForeground, maxWidth, maxLines: 2);- var total = title.Height + (string.IsNullOrEmpty(CenterSubtitle) ? 0 : subtitle.Height + 2);+ var title = MakeText(CenterTitle ?? "", bold, IsMaterialYou ? 14.5 : 14, Foreground, maxWidth, maxLines: 2);+ var subtitle = MakeText(CenterSubtitle ?? "", regular, IsMaterialYou ? 10.5 : 11.5, cancelHot ? DangerBrush : SecondaryForeground, maxWidth, maxLines: 2);+ var hasSubtitle = !string.IsNullOrEmpty(CenterSubtitle);+ var total = title.Height + (hasSubtitle ? subtitle.Height + (IsMaterialYou ? 4 : 2) : 0);var y = center.Y - total / 2;DrawCentered(context, title, center.X, y);- if (!string.IsNullOrEmpty(CenterSubtitle))- DrawCentered(context, subtitle, center.X, y + title.Height + 2);++ if (hasSubtitle)+ {+ var subY = y + title.Height + (IsMaterialYou ? 3 : 2);+ if (IsMaterialYou)+ {+ var padX = 7.0;+ var padY = 2.0;+ var badgeW = Math.Min(maxWidth, subtitle.Width + padX * 2);+ var badgeH = subtitle.Height + padY * 2;+ var badgeRect = new RoundedRect(new Rect(center.X - badgeW / 2, subY, badgeW, badgeH), badgeH / 2);+ context.DrawRectangle(WithOpacity(AccentBrush, 0.18), null, badgeRect);+ DrawCentered(context, MakeText(CenterSubtitle!, regular, 10, Foreground, badgeW), center.X, subY + padY);+ }+ else+ {+ DrawCentered(context, subtitle, center.X, subY);+ }+ }+ }++ private static void DrawCenterShadow(DrawingContext context, Point center, double radius)+ {+ var shadowRadius = radius + 9;+ var brush = new RadialGradientBrush+ {+ GradientStops =+ {+ new GradientStop(Color.FromArgb(0, 0, 0, 0), 0),+ new GradientStop(Color.FromArgb(0, 0, 0, 0), (radius - 4) / shadowRadius),+ new GradientStop(Color.FromArgb(42, 0, 0, 0), (radius + 1) / shadowRadius),+ new GradientStop(Color.FromArgb(0, 0, 0, 0), 1),+ },+ };+ context.DrawEllipse(brush, null, new Point(center.X, center.Y + 2), shadowRadius, shadowRadius);}private void DrawLabel(DrawingContext context, DonutItem item, Point center, double radius, double angle,@@ -998,31 +1055,31 @@ public sealed partial class DonutMenu : Control/// <summary>A rounded slice of <paramref name="span"/> radians centred on <paramref name="mid"/> (a ring when it is all of it).</summary>private StreamGeometry CreateWedge(Point c, double r1, double r2, double mid, double span) =>- CreateWedge(c, r1, r2, mid, span, SliceCornerRadius);+ CreateWedge(c, r1, r2, mid, span, IsMaterialYou ? Math.Max(12, SliceCornerRadius * 1.4) : SliceCornerRadius, IsMaterialYou ? 4.5 : GapPixels);// Slices are drawn every frame while the donut animates, but their shapes only change with the size, the layout// or the softness: the shapes are kept and reused. Animations move them with transforms; only the edit mode's// sliding slices make new ones, and the cache starts over when it fills up.- private readonly Dictionary<(Point C, double R1, double R2, double Mid, double Span, double Corner), StreamGeometry> _wedges = new();+ private readonly Dictionary<(Point C, double R1, double R2, double Mid, double Span, double Corner, double Gap), StreamGeometry> _wedges = new();private const int MaxCachedWedges = 256;- private StreamGeometry CreateWedge(Point c, double r1, double r2, double mid, double span, double cornerRadius)+ private StreamGeometry CreateWedge(Point c, double r1, double r2, double mid, double span, double cornerRadius, double gap = GapPixels){- var key = (c, r1, r2, mid, span, cornerRadius);+ var key = (c, r1, r2, mid, span, cornerRadius, gap);if (_wedges.TryGetValue(key, out var cached))return cached;if (_wedges.Count >= MaxCachedWedges)_wedges.Clear();- return _wedges[key] = BuildWedge(c, r1, r2, mid, span, cornerRadius);+ return _wedges[key] = BuildWedge(c, r1, r2, mid, span, cornerRadius, gap);}/// <summary>A slice with a constant-width gap to its neighbours and corners rounded by <paramref name="cornerRadius"/>.</summary>- private static StreamGeometry BuildWedge(Point c, double r1, double r2, double mid, double span, double cornerRadius)+ private static StreamGeometry BuildWedge(Point c, double r1, double r2, double mid, double span, double cornerRadius, double gap = GapPixels){if (span >= 2 * Math.PI - 0.001)return CreateRing(c, r1, r2);- var outline = DonutGeometry.Wedge(c, r1, r2, mid, span, GapPixels, cornerRadius);+ var outline = DonutGeometry.Wedge(c, r1, r2, mid, span, gap, cornerRadius);var geometry = new StreamGeometry();using var ctx = geometry.Open();ctx.BeginFigure(outline.Start, true);diff --git a/src/Filee.App/Services/MaterialYouPalette.cs b/src/Filee.App/Services/MaterialYouPalette.csnew file mode 100644index 00000000..a386a5c8--- /dev/null+++ b/src/Filee.App/Services/MaterialYouPalette.cs@@ -0,0 +1,604 @@+// Material You (Material Design 3) dynamic tonal palette generator.+// Generates tonal color roles (Primary, PrimaryContainer, SecondaryContainer, SurfaceContainer, etc.)+// from a seed color for Light and Dark variants.++using System.Globalization;+using Avalonia;+using Avalonia.Media;++namespace Filee.App.Services;++/// <summary>Resolved Material Design 3 tonal color tokens.</summary>+public sealed class MaterialYouPalette+{+ public required Color Primary { get; init; }+ public required Color OnPrimary { get; init; }+ public required Color PrimaryContainer { get; init; }+ public required Color OnPrimaryContainer { get; init; }++ public required Color Secondary { get; init; }+ public required Color OnSecondary { get; init; }+ public required Color SecondaryContainer { get; init; }+ public required Color OnSecondaryContainer { get; init; }++ public required Color Surface { get; init; }+ public required Color SurfaceDim { get; init; }+ public required Color SurfaceBright { get; init; }+ public required Color SurfaceContainerLowest { get; init; }+ public required Color SurfaceContainerLow { get; init; }+ public required Color SurfaceContainer { get; init; }+ public required Color SurfaceContainerHigh { get; init; }+ public required Color SurfaceContainerHighest { get; init; }++ public required Color OnSurface { get; init; }+ public required Color OnSurfaceVariant { get; init; }++ public required Color Outline { get; init; }+ public required Color OutlineVariant { get; init; }++ public required Color Danger { get; init; }+ public required Color Success { get; init; }+ public required Color Warning { get; init; }++ public required BoxShadows CardShadow { get; init; }++ /// <summary>Calculates standard sRGB relative luminance.</summary>+ public static double Luminance(Color c)+ {+ static double Channel(byte v)+ {+ double s = v / 255.0;+ return s <= 0.03928 ? s / 12.92 : Math.Pow((s + 0.055) / 1.055, 2.4);+ }+ return 0.2126 * Channel(c.R) + 0.7152 * Channel(c.G) + 0.0722 * Channel(c.B);+ }++ /// <summary>Calculates dynamic text contrast (dark charcoal vs crisp white) based on background luminance.</summary>+ public static Color TextOn(Color bg)+ {+ return Luminance(bg) > 0.42 ? Color.Parse("#141E11") : Colors.White;+ }++ /// <summary>Alpha-blends a foreground color over a background color (matching Inkora theme engine).</summary>+ public static Color AlphaBlend(Color foreground, Color background)+ {+ double fA = foreground.A / 255.0;+ double bA = background.A / 255.0;+ double rA = fA + bA * (1.0 - fA);+ if (rA <= 1e-5) return Colors.Transparent;+ byte r = (byte)Math.Clamp(Math.Round((foreground.R * fA + background.R * bA * (1.0 - fA)) / rA), 0, 255);+ byte g = (byte)Math.Clamp(Math.Round((foreground.G * fA + background.G * bA * (1.0 - fA)) / rA), 0, 255);+ byte b = (byte)Math.Clamp(Math.Round((foreground.B * fA + background.B * bA * (1.0 - fA)) / rA), 0, 255);+ byte a = (byte)Math.Clamp(Math.Round(rA * 255.0), 0, 255);+ return Color.FromArgb(a, r, g, b);+ }++ /// <summary>Generates the complete Material 3 tonal color system from a seed accent color, with Inkora pastel presets.</summary>+ public static MaterialYouPalette Generate(Color seed, bool isDark)+ {+ // Check for matching Inkora curated pastel presets first+ if (TryGetInkoraPreset(seed, isDark, out var presetPalette))+ return presetPalette;++ var (h, s, l) = RgbToHsl(seed);+ var baseSat = Math.Clamp(s, 0.25, 0.85);++ if (!isDark)+ {+ // ── Light Mode (Inkora alpha blend tinted paper surfaces) ──+ var primary = seed;+ var onPrimary = TextOn(primary);+ var primaryContainer = HslToRgb(h, Math.Min(baseSat * 0.65, 0.50), 0.92);+ var onPrimaryContainer = TextOn(primaryContainer);++ var secondary = HslToRgb(h, Math.Min(baseSat * 0.45, 0.38), 0.45);+ var onSecondary = TextOn(secondary);+ var secondaryContainer = HslToRgb(h, Math.Min(baseSat * 0.35, 0.28), 0.94);+ var onSecondaryContainer = TextOn(secondaryContainer);++ // Inkora light tinted surface stack+ var surface = AlphaBlend(Color.FromArgb((byte)(0.03 * 255), seed.R, seed.G, seed.B), Color.Parse("#FAF9FC"));+ var surfaceDim = AlphaBlend(Color.FromArgb((byte)(0.05 * 255), seed.R, seed.G, seed.B), Color.Parse("#F5F3F9"));+ var surfaceBright = Colors.White;+ var surfaceContainerLowest = Colors.White;+ var surfaceContainerLow = AlphaBlend(Color.FromArgb((byte)(0.06 * 255), seed.R, seed.G, seed.B), Color.Parse("#F3F1F7"));+ var surfaceContainer = AlphaBlend(Color.FromArgb((byte)(0.09 * 255), seed.R, seed.G, seed.B), Color.Parse("#EBE8F2"));+ var surfaceContainerHigh = AlphaBlend(Color.FromArgb((byte)(0.13 * 255), seed.R, seed.G, seed.B), Color.Parse("#E3DFEC"));+ var surfaceContainerHighest = AlphaBlend(Color.FromArgb((byte)(0.17 * 255), seed.R, seed.G, seed.B), Color.Parse("#DCD7E7"));++ var onSurface = Color.Parse("#1E1B22");+ var onSurfaceVariant = Color.Parse("#534F5C");++ var outline = AlphaBlend(Color.FromArgb((byte)(0.30 * 255), seed.R, seed.G, seed.B), Color.Parse("#8E889B"));+ var outlineVariant = AlphaBlend(Color.FromArgb((byte)(0.18 * 255), seed.R, seed.G, seed.B), Color.Parse("#D5CFE3"));++ return new MaterialYouPalette+ {+ Primary = primary,+ OnPrimary = onPrimary,+ PrimaryContainer = primaryContainer,+ OnPrimaryContainer = onPrimaryContainer,+ Secondary = secondary,+ OnSecondary = onSecondary,+ SecondaryContainer = secondaryContainer,+ OnSecondaryContainer = onSecondaryContainer,+ Surface = surface,+ SurfaceDim = surfaceDim,+ SurfaceBright = surfaceBright,+ SurfaceContainerLowest = surfaceContainerLowest,+ SurfaceContainerLow = surfaceContainerLow,+ SurfaceContainer = surfaceContainer,+ SurfaceContainerHigh = surfaceContainerHigh,+ SurfaceContainerHighest = surfaceContainerHighest,+ OnSurface = onSurface,+ OnSurfaceVariant = onSurfaceVariant,+ Outline = outline,+ OutlineVariant = outlineVariant,+ Danger = Color.Parse("#BA1A1A"),+ Success = Color.Parse("#1B6D24"),+ Warning = Color.Parse("#825500"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #12000000, 0 4 12 1 #0D000000"),+ };+ }+ else+ {+ // ── Dark Mode (Inkora alpha blend tinted deep charcoal surfaces) ──+ var primary = seed;+ var onPrimary = TextOn(primary);+ var primaryContainer = HslToRgb(h, Math.Min(baseSat * 0.60, 0.42), 0.28);+ var onPrimaryContainer = TextOn(primaryContainer);++ var secondary = HslToRgb(h, Math.Min(baseSat * 0.40, 0.32), 0.72);+ var onSecondary = TextOn(secondary);+ var secondaryContainer = HslToRgb(h, Math.Min(baseSat * 0.30, 0.25), 0.24);+ var onSecondaryContainer = TextOn(secondaryContainer);++ // Inkora dark tinted surface stack+ var surface = AlphaBlend(Color.FromArgb((byte)(0.08 * 255), seed.R, seed.G, seed.B), Color.Parse("#16151B"));+ var surfaceDim = Color.Parse("#110F15");+ var surfaceBright = AlphaBlend(Color.FromArgb((byte)(0.22 * 255), seed.R, seed.G, seed.B), Color.Parse("#322E3F"));+ var surfaceContainerLowest = Color.Parse("#110F15");+ var surfaceContainerLow = AlphaBlend(Color.FromArgb((byte)(0.12 * 255), seed.R, seed.G, seed.B), Color.Parse("#1D1B24"));+ var surfaceContainer = AlphaBlend(Color.FromArgb((byte)(0.16 * 255), seed.R, seed.G, seed.B), Color.Parse("#24222E"));+ var surfaceContainerHigh = AlphaBlend(Color.FromArgb((byte)(0.20 * 255), seed.R, seed.G, seed.B), Color.Parse("#2E2B3A"));+ var surfaceContainerHighest = AlphaBlend(Color.FromArgb((byte)(0.24 * 255), seed.R, seed.G, seed.B), Color.Parse("#383547"));++ var onSurface = Color.Parse("#EDE8F4");+ var onSurfaceVariant = Color.Parse("#C5BFCF");++ var outline = AlphaBlend(Color.FromArgb((byte)(0.35 * 255), seed.R, seed.G, seed.B), Color.Parse("#686477"));+ var outlineVariant = AlphaBlend(Color.FromArgb((byte)(0.20 * 255), seed.R, seed.G, seed.B), Color.Parse("#403C4D"));++ return new MaterialYouPalette+ {+ Primary = primary,+ OnPrimary = onPrimary,+ PrimaryContainer = primaryContainer,+ OnPrimaryContainer = onPrimaryContainer,+ Secondary = secondary,+ OnSecondary = onSecondary,+ SecondaryContainer = secondaryContainer,+ OnSecondaryContainer = onSecondaryContainer,+ Surface = surface,+ SurfaceDim = surfaceDim,+ SurfaceBright = surfaceBright,+ SurfaceContainerLowest = surfaceContainerLowest,+ SurfaceContainerLow = surfaceContainerLow,+ SurfaceContainer = surfaceContainer,+ SurfaceContainerHigh = surfaceContainerHigh,+ SurfaceContainerHighest = surfaceContainerHighest,+ OnSurface = onSurface,+ OnSurfaceVariant = onSurfaceVariant,+ Outline = outline,+ OutlineVariant = outlineVariant,+ Danger = Color.Parse("#FFB4AB"),+ Success = Color.Parse("#8CD692"),+ Warning = Color.Parse("#FFBA2F"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #35000000, 0 8 20 0 #20000000"),+ };+ }+ }++ private static bool ColorMatches(Color a, Color b) =>+ Math.Abs(a.R - b.R) <= 3 && Math.Abs(a.G - b.G) <= 3 && Math.Abs(a.B - b.B) <= 3;++ private static bool TryGetInkoraPreset(Color seed, bool isDark, out MaterialYouPalette palette)+ {+ // 0. Monochrome (Pure Black & White)+ if (ColorMatches(seed, Color.Parse("#111111")) || ColorMatches(seed, Color.Parse("#000000")) ||+ ColorMatches(seed, Colors.White) || ColorMatches(seed, Color.Parse("#F5F5F5")))+ {+ palette = isDark ? new MaterialYouPalette+ {+ Primary = Color.Parse("#F5F5F5"),+ OnPrimary = Color.Parse("#111111"),+ PrimaryContainer = Color.Parse("#282828"),+ OnPrimaryContainer = Color.Parse("#F5F5F5"),+ Secondary = Color.Parse("#D4D4D4"),+ OnSecondary = Color.Parse("#111111"),+ SecondaryContainer = Color.Parse("#202020"),+ OnSecondaryContainer = Color.Parse("#E0E0E0"),+ Surface = Color.Parse("#0D0D0D"),+ SurfaceDim = Color.Parse("#060606"),+ SurfaceBright = Color.Parse("#1E1E1E"),+ SurfaceContainerLowest = Color.Parse("#050505"),+ SurfaceContainerLow = Color.Parse("#141414"),+ SurfaceContainer = Color.Parse("#1B1B1B"),+ SurfaceContainerHigh = Color.Parse("#242424"),+ SurfaceContainerHighest = Color.Parse("#2E2E2E"),+ OnSurface = Color.Parse("#F5F5F5"),+ OnSurfaceVariant = Color.Parse("#B5B5B5"),+ Outline = Color.Parse("#4C4C4C"),+ OutlineVariant = Color.Parse("#2E2E2E"),+ Danger = Color.Parse("#FF6B6B"),+ Success = Color.Parse("#69DB7C"),+ Warning = Color.Parse("#FFD43B"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #60000000, 0 8 20 0 #40000000"),+ } : new MaterialYouPalette+ {+ Primary = Color.Parse("#111111"),+ OnPrimary = Colors.White,+ PrimaryContainer = Color.Parse("#EAEAEA"),+ OnPrimaryContainer = Color.Parse("#111111"),+ Secondary = Color.Parse("#333333"),+ OnSecondary = Colors.White,+ SecondaryContainer = Color.Parse("#F0F0F0"),+ OnSecondaryContainer = Color.Parse("#111111"),+ Surface = Colors.White,+ SurfaceDim = Color.Parse("#F5F5F5"),+ SurfaceBright = Colors.White,+ SurfaceContainerLowest = Colors.White,+ SurfaceContainerLow = Color.Parse("#F8F8F8"),+ SurfaceContainer = Color.Parse("#F0F0F0"),+ SurfaceContainerHigh = Color.Parse("#E8E8E8"),+ SurfaceContainerHighest = Color.Parse("#DFDFDF"),+ OnSurface = Color.Parse("#111111"),+ OnSurfaceVariant = Color.Parse("#4A4A4A"),+ Outline = Color.Parse("#B0B0B0"),+ OutlineVariant = Color.Parse("#E0E0E0"),+ Danger = Color.Parse("#BA1A1A"),+ Success = Color.Parse("#1B6D24"),+ Warning = Color.Parse("#825500"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #18000000, 0 4 12 1 #10000000"),+ };+ return true;+ }++ // 1. Blush & Peach (Light: #E07A70, Dark: #F29B91)+ if (ColorMatches(seed, Color.Parse("#E07A70")) || ColorMatches(seed, Color.Parse("#F29B91")))+ {+ palette = isDark ? new MaterialYouPalette+ {+ Primary = Color.Parse("#F29B91"), OnPrimary = Color.Parse("#441814"),+ PrimaryContainer = Color.Parse("#5D2D27"), OnPrimaryContainer = Color.Parse("#FDE8E5"),+ Secondary = Color.Parse("#9EC4B5"), OnSecondary = Color.Parse("#13362B"),+ SecondaryContainer = Color.Parse("#26443A"), OnSecondaryContainer = Color.Parse("#DBEDE6"),+ Surface = Color.Parse("#1D1413"), SurfaceDim = Color.Parse("#140E0D"), SurfaceBright = Color.Parse("#382725"),+ SurfaceContainerLowest = Color.Parse("#140E0D"), SurfaceContainerLow = Color.Parse("#231A18"),+ SurfaceContainer = Color.Parse("#2A201E"), SurfaceContainerHigh = Color.Parse("#352927"),+ SurfaceContainerHighest = Color.Parse("#413331"),+ OnSurface = Color.Parse("#F8ECE9"), OnSurfaceVariant = Color.Parse("#CBB0AB"),+ Outline = Color.Parse("#7D6561"), OutlineVariant = Color.Parse("#51403D"),+ Danger = Color.Parse("#FFB4AB"), Success = Color.Parse("#8CD692"), Warning = Color.Parse("#FFBA2F"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #35000000, 0 8 20 0 #20000000")+ } : new MaterialYouPalette+ {+ Primary = Color.Parse("#E07A70"), OnPrimary = Colors.White,+ PrimaryContainer = Color.Parse("#FDECE8"), OnPrimaryContainer = Color.Parse("#4A2825"),+ Secondary = Color.Parse("#7FA898"), OnSecondary = Colors.White,+ SecondaryContainer = Color.Parse("#E4F0EC"), OnSecondaryContainer = Color.Parse("#22362F"),+ Surface = Color.Parse("#FDF9F7"), SurfaceDim = Color.Parse("#F5EDE9"), SurfaceBright = Colors.White,+ SurfaceContainerLowest = Colors.White, SurfaceContainerLow = Color.Parse("#FAF2EF"),+ SurfaceContainer = Color.Parse("#F6EAE6"), SurfaceContainerHigh = Color.Parse("#F0DFDA"),+ SurfaceContainerHighest = Color.Parse("#EAD5CF"),+ OnSurface = Color.Parse("#2D2423"), OnSurfaceVariant = Color.Parse("#6B5854"),+ Outline = Color.Parse("#B39893"), OutlineVariant = Color.Parse("#E8D5D0"),+ Danger = Color.Parse("#BA1A1A"), Success = Color.Parse("#1B6D24"), Warning = Color.Parse("#825500"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #12000000, 0 4 12 1 #0D000000")+ };+ return true;+ }++ // 2. Strawberry Milk (Light: #E86483, Dark: #F79BB0)+ if (ColorMatches(seed, Color.Parse("#E86483")) || ColorMatches(seed, Color.Parse("#F79BB0")))+ {+ palette = isDark ? new MaterialYouPalette+ {+ Primary = Color.Parse("#F79BB0"), OnPrimary = Color.Parse("#471320"),+ PrimaryContainer = Color.Parse("#632434"), OnPrimaryContainer = Color.Parse("#FEDFE6"),+ Secondary = Color.Parse("#98C4B0"), OnSecondary = Color.Parse("#163829"),+ SecondaryContainer = Color.Parse("#284839"), OnSecondaryContainer = Color.Parse("#DBEFE6"),+ Surface = Color.Parse("#1D1517"), SurfaceDim = Color.Parse("#140E10"), SurfaceBright = Color.Parse("#38272C"),+ SurfaceContainerLowest = Color.Parse("#140E10"), SurfaceContainerLow = Color.Parse("#23191C"),+ SurfaceContainer = Color.Parse("#2A1E22"), SurfaceContainerHigh = Color.Parse("#35272B"),+ SurfaceContainerHighest = Color.Parse("#413136"),+ OnSurface = Color.Parse("#F7ECEE"), OnSurfaceVariant = Color.Parse("#C9B0B7"),+ Outline = Color.Parse("#7C646B"), OutlineVariant = Color.Parse("#503E44"),+ Danger = Color.Parse("#FFB4AB"), Success = Color.Parse("#8CD692"), Warning = Color.Parse("#FFBA2F"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #35000000, 0 8 20 0 #20000000")+ } : new MaterialYouPalette+ {+ Primary = Color.Parse("#E86483"), OnPrimary = Colors.White,+ PrimaryContainer = Color.Parse("#FFECF0"), OnPrimaryContainer = Color.Parse("#4A1824"),+ Secondary = Color.Parse("#76A893"), OnSecondary = Colors.White,+ SecondaryContainer = Color.Parse("#E2F0EA"), OnSecondaryContainer = Color.Parse("#1E382E"),+ Surface = Color.Parse("#FFF8F9"), SurfaceDim = Color.Parse("#F7ECF0"), SurfaceBright = Colors.White,+ SurfaceContainerLowest = Colors.White, SurfaceContainerLow = Color.Parse("#FDF1F4"),+ SurfaceContainer = Color.Parse("#F9E8EC"), SurfaceContainerHigh = Color.Parse("#F3DDE3"),+ SurfaceContainerHighest = Color.Parse("#EBCFD6"),+ OnSurface = Color.Parse("#2E2225"), OnSurfaceVariant = Color.Parse("#6B5359"),+ Outline = Color.Parse("#B8939C"), OutlineVariant = Color.Parse("#EBD2D9"),+ Danger = Color.Parse("#BA1A1A"), Success = Color.Parse("#1B6D24"), Warning = Color.Parse("#825500"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #12000000, 0 4 12 1 #0D000000")+ };+ return true;+ }++ // 3. Matcha Latte (Light: #5A8E51, Dark: #8DC983)+ if (ColorMatches(seed, Color.Parse("#5A8E51")) || ColorMatches(seed, Color.Parse("#8DC983")))+ {+ palette = isDark ? new MaterialYouPalette+ {+ Primary = Color.Parse("#8DC983"), OnPrimary = Color.Parse("#143710"),+ PrimaryContainer = Color.Parse("#26521F"), OnPrimaryContainer = Color.Parse("#DFF5DA"),+ Secondary = Color.Parse("#F1B782"), OnSecondary = Color.Parse("#3F240A"),+ SecondaryContainer = Color.Parse("#563515"), OnSecondaryContainer = Color.Parse("#FEEDD8"),+ Surface = Color.Parse("#141712"), SurfaceDim = Color.Parse("#0E110D"), SurfaceBright = Color.Parse("#2E372A"),+ SurfaceContainerLowest = Color.Parse("#0E110D"), SurfaceContainerLow = Color.Parse("#1A1F18"),+ SurfaceContainer = Color.Parse("#1F251D"), SurfaceContainerHigh = Color.Parse("#293126"),+ SurfaceContainerHighest = Color.Parse("#343E31"),+ OnSurface = Color.Parse("#ECF0E7"), OnSurfaceVariant = Color.Parse("#BCC4B6"),+ Outline = Color.Parse("#6B7565"), OutlineVariant = Color.Parse("#3F483A"),+ Danger = Color.Parse("#FFB4AB"), Success = Color.Parse("#8CD692"), Warning = Color.Parse("#FFBA2F"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #35000000, 0 8 20 0 #20000000")+ } : new MaterialYouPalette+ {+ Primary = Color.Parse("#5A8E51"), OnPrimary = Colors.White,+ PrimaryContainer = Color.Parse("#E7F3E3"), OnPrimaryContainer = Color.Parse("#193714"),+ Secondary = Color.Parse("#CC8749"), OnSecondary = Colors.White,+ SecondaryContainer = Color.Parse("#FAEEDB"), OnSecondaryContainer = Color.Parse("#3E2611"),+ Surface = Color.Parse("#F9FAF5"), SurfaceDim = Color.Parse("#F0F2EB"), SurfaceBright = Colors.White,+ SurfaceContainerLowest = Colors.White, SurfaceContainerLow = Color.Parse("#F3F5EE"),+ SurfaceContainer = Color.Parse("#ECF0E5"), SurfaceContainerHigh = Color.Parse("#E2E7DA"),+ SurfaceContainerHighest = Color.Parse("#D7DDCE"),+ OnSurface = Color.Parse("#242721"), OnSurfaceVariant = Color.Parse("#555B4F"),+ Outline = Color.Parse("#8D9686"), OutlineVariant = Color.Parse("#D4DCCE"),+ Danger = Color.Parse("#BA1A1A"), Success = Color.Parse("#1B6D24"), Warning = Color.Parse("#825500"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #12000000, 0 4 12 1 #0D000000")+ };+ return true;+ }++ // 4. Lavender Mist (Light: #8B7AB8, Dark: #BCAEE5)+ if (ColorMatches(seed, Color.Parse("#8B7AB8")) || ColorMatches(seed, Color.Parse("#BCAEE5")) || ColorMatches(seed, Color.Parse("#C5B4E3")))+ {+ palette = isDark ? new MaterialYouPalette+ {+ Primary = Color.Parse("#BCAEE5"), OnPrimary = Color.Parse("#291E47"),+ PrimaryContainer = Color.Parse("#3F3260"), OnPrimaryContainer = Color.Parse("#EFEBF9"),+ Secondary = Color.Parse("#91CFC0"), OnSecondary = Color.Parse("#123B32"),+ SecondaryContainer = Color.Parse("#224940"), OnSecondaryContainer = Color.Parse("#DBF2EC"),+ Surface = Color.Parse("#181520"), SurfaceDim = Color.Parse("#110F17"), SurfaceBright = Color.Parse("#332D42"),+ SurfaceContainerLowest = Color.Parse("#110F17"), SurfaceContainerLow = Color.Parse("#1E1A27"),+ SurfaceContainer = Color.Parse("#252030"), SurfaceContainerHigh = Color.Parse("#302A3D"),+ SurfaceContainerHighest = Color.Parse("#3C354B"),+ OnSurface = Color.Parse("#F1EEF7"), OnSurfaceVariant = Color.Parse("#C4BED0"),+ Outline = Color.Parse("#777183"), OutlineVariant = Color.Parse("#4A4456"),+ Danger = Color.Parse("#FFB4AB"), Success = Color.Parse("#8CD692"), Warning = Color.Parse("#FFBA2F"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #35000000, 0 8 20 0 #20000000")+ } : new MaterialYouPalette+ {+ Primary = Color.Parse("#8B7AB8"), OnPrimary = Colors.White,+ PrimaryContainer = Color.Parse("#EDE8F7"), OnPrimaryContainer = Color.Parse("#2F2648"),+ Secondary = Color.Parse("#6FA89A"), OnSecondary = Colors.White,+ SecondaryContainer = Color.Parse("#E1F2ED"), OnSecondaryContainer = Color.Parse("#1D3630"),+ Surface = Color.Parse("#FAF8FD"), SurfaceDim = Color.Parse("#F1ECF7"), SurfaceBright = Colors.White,+ SurfaceContainerLowest = Colors.White, SurfaceContainerLow = Color.Parse("#F5F2FA"),+ SurfaceContainer = Color.Parse("#EFEBF7"), SurfaceContainerHigh = Color.Parse("#E8E2F2"),+ SurfaceContainerHighest = Color.Parse("#E0D8EC"),+ OnSurface = Color.Parse("#26232E"), OnSurfaceVariant = Color.Parse("#5D5769"),+ Outline = Color.Parse("#928B9F"), OutlineVariant = Color.Parse("#D8D1E6"),+ Danger = Color.Parse("#BA1A1A"), Success = Color.Parse("#1B6D24"), Warning = Color.Parse("#825500"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #12000000, 0 4 12 1 #0D000000")+ };+ return true;+ }++ // 5. Sage & Mint (Light: #529B7D, Dark: #88D5B1)+ if (ColorMatches(seed, Color.Parse("#529B7D")) || ColorMatches(seed, Color.Parse("#88D5B1")))+ {+ palette = isDark ? new MaterialYouPalette+ {+ Primary = Color.Parse("#88D5B1"), OnPrimary = Color.Parse("#103625"),+ PrimaryContainer = Color.Parse("#22513B"), OnPrimaryContainer = Color.Parse("#DDF5EB"),+ Secondary = Color.Parse("#F4BE77"), OnSecondary = Color.Parse("#412803"),+ SecondaryContainer = Color.Parse("#57390E"), OnSecondaryContainer = Color.Parse("#FCEFD9"),+ Surface = Color.Parse("#121A16"), SurfaceDim = Color.Parse("#0C120F"), SurfaceBright = Color.Parse("#2C3B33"),+ SurfaceContainerLowest = Color.Parse("#0C120F"), SurfaceContainerLow = Color.Parse("#17211C"),+ SurfaceContainer = Color.Parse("#1D2A24"), SurfaceContainerHigh = Color.Parse("#27332C"),+ SurfaceContainerHighest = Color.Parse("#33423A"),+ OnSurface = Color.Parse("#EBF2EE"), OnSurfaceVariant = Color.Parse("#BACCC3"),+ Outline = Color.Parse("#677D72"), OutlineVariant = Color.Parse("#3B4D44"),+ Danger = Color.Parse("#FFB4AB"), Success = Color.Parse("#8CD692"), Warning = Color.Parse("#FFBA2F"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #35000000, 0 8 20 0 #20000000")+ } : new MaterialYouPalette+ {+ Primary = Color.Parse("#529B7D"), OnPrimary = Colors.White,+ PrimaryContainer = Color.Parse("#E2F3EB"), OnPrimaryContainer = Color.Parse("#17382B"),+ Secondary = Color.Parse("#DE9843"), OnSecondary = Colors.White,+ SecondaryContainer = Color.Parse("#FDF0DF"), OnSecondaryContainer = Color.Parse("#40280D"),+ Surface = Color.Parse("#F7FAF8"), SurfaceDim = Color.Parse("#EDF3EF"), SurfaceBright = Colors.White,+ SurfaceContainerLowest = Colors.White, SurfaceContainerLow = Color.Parse("#F0F5F2"),+ SurfaceContainer = Color.Parse("#E8F0EC"), SurfaceContainerHigh = Color.Parse("#DFEAE5"),+ SurfaceContainerHighest = Color.Parse("#D3E1DA"),+ OnSurface = Color.Parse("#222925"), OnSurfaceVariant = Color.Parse("#53605A"),+ Outline = Color.Parse("#889790"), OutlineVariant = Color.Parse("#D1DDD7"),+ Danger = Color.Parse("#BA1A1A"), Success = Color.Parse("#1B6D24"), Warning = Color.Parse("#825500"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #12000000, 0 4 12 1 #0D000000")+ };+ return true;+ }++ // 6. Honey & Amber (Light: #CB852A, Dark: #F0BA6A)+ if (ColorMatches(seed, Color.Parse("#CB852A")) || ColorMatches(seed, Color.Parse("#F0BA6A")))+ {+ palette = isDark ? new MaterialYouPalette+ {+ Primary = Color.Parse("#F0BA6A"), OnPrimary = Color.Parse("#3F2500"),+ PrimaryContainer = Color.Parse("#5C3908"), OnPrimaryContainer = Color.Parse("#FDEDD5"),+ Secondary = Color.Parse("#A5C98E"), OnSecondary = Color.Parse("#1D3510"),+ SecondaryContainer = Color.Parse("#2F4A20"), OnSecondaryContainer = Color.Parse("#E6F2DE"),+ Surface = Color.Parse("#1B1712"), SurfaceDim = Color.Parse("#13100B"), SurfaceBright = Color.Parse("#3B3226"),+ SurfaceContainerLowest = Color.Parse("#13100B"), SurfaceContainerLow = Color.Parse("#211C16"),+ SurfaceContainer = Color.Parse("#27211B"), SurfaceContainerHigh = Color.Parse("#342D24"),+ SurfaceContainerHighest = Color.Parse("#41382E"),+ OnSurface = Color.Parse("#F7F2E9"), OnSurfaceVariant = Color.Parse("#CDC2B3"),+ Outline = Color.Parse("#7A6F60"), OutlineVariant = Color.Parse("#494034"),+ Danger = Color.Parse("#FFB4AB"), Success = Color.Parse("#8CD692"), Warning = Color.Parse("#FFBA2F"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #35000000, 0 8 20 0 #20000000")+ } : new MaterialYouPalette+ {+ Primary = Color.Parse("#CB852A"), OnPrimary = Colors.White,+ PrimaryContainer = Color.Parse("#FBF0DC"), OnPrimaryContainer = Color.Parse("#422806"),+ Secondary = Color.Parse("#75995E"), OnSecondary = Colors.White,+ SecondaryContainer = Color.Parse("#EBF3E5"), OnSecondaryContainer = Color.Parse("#24361A"),+ Surface = Color.Parse("#FDF9F4"), SurfaceDim = Color.Parse("#F3ECE0"), SurfaceBright = Colors.White,+ SurfaceContainerLowest = Colors.White, SurfaceContainerLow = Color.Parse("#FAF3E9"),+ SurfaceContainer = Color.Parse("#F6EBDE"), SurfaceContainerHigh = Color.Parse("#EFE1D0"),+ SurfaceContainerHighest = Color.Parse("#E7D6C0"),+ OnSurface = Color.Parse("#2A251E"), OnSurfaceVariant = Color.Parse("#635B4E"),+ Outline = Color.Parse("#9C9281"), OutlineVariant = Color.Parse("#E3DACB"),+ Danger = Color.Parse("#BA1A1A"), Success = Color.Parse("#1B6D24"), Warning = Color.Parse("#825500"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #12000000, 0 4 12 1 #0D000000")+ };+ return true;+ }++ // 7. Cloud & Sky (Light: #5B8BE3, Dark: #98B8F6)+ if (ColorMatches(seed, Color.Parse("#5B8BE3")) || ColorMatches(seed, Color.Parse("#98B8F6")) || ColorMatches(seed, Color.Parse("#A0D2EB")))+ {+ palette = isDark ? new MaterialYouPalette+ {+ Primary = Color.Parse("#98B8F6"), OnPrimary = Color.Parse("#132B5B"),+ PrimaryContainer = Color.Parse("#223E75"), OnPrimaryContainer = Color.Parse("#E3EDFE"),+ Secondary = Color.Parse("#F5A3AA"), OnSecondary = Color.Parse("#46171B"),+ SecondaryContainer = Color.Parse("#5D2429"), OnSecondaryContainer = Color.Parse("#FDE9EB"),+ Surface = Color.Parse("#131722"), SurfaceDim = Color.Parse("#0D101A"), SurfaceBright = Color.Parse("#2E374E"),+ SurfaceContainerLowest = Color.Parse("#0D101A"), SurfaceContainerLow = Color.Parse("#171C29"),+ SurfaceContainer = Color.Parse("#1D2331"), SurfaceContainerHigh = Color.Parse("#272E40"),+ SurfaceContainerHighest = Color.Parse("#333B50"),+ OnSurface = Color.Parse("#EEF3FA"), OnSurfaceVariant = Color.Parse("#B7C3D8"),+ Outline = Color.Parse("#65748F"), OutlineVariant = Color.Parse("#394357"),+ Danger = Color.Parse("#FFB4AB"), Success = Color.Parse("#8CD692"), Warning = Color.Parse("#FFBA2F"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #35000000, 0 8 20 0 #20000000")+ } : new MaterialYouPalette+ {+ Primary = Color.Parse("#5B8BE3"), OnPrimary = Colors.White,+ PrimaryContainer = Color.Parse("#E7EFFD"), OnPrimaryContainer = Color.Parse("#17294A"),+ Secondary = Color.Parse("#E57E86"), OnSecondary = Colors.White,+ SecondaryContainer = Color.Parse("#FDECEE"), OnSecondaryContainer = Color.Parse("#441C20"),+ Surface = Color.Parse("#F8FAFD"), SurfaceDim = Color.Parse("#ECF0F7"), SurfaceBright = Colors.White,+ SurfaceContainerLowest = Colors.White, SurfaceContainerLow = Color.Parse("#F0F4FA"),+ SurfaceContainer = Color.Parse("#E8EEF7"), SurfaceContainerHigh = Color.Parse("#DFE6F2"),+ SurfaceContainerHighest = Color.Parse("#D3DCED"),+ OnSurface = Color.Parse("#22262E"), OnSurfaceVariant = Color.Parse("#555C6B"),+ Outline = Color.Parse("#8993A6"), OutlineVariant = Color.Parse("#D0D7E5"),+ Danger = Color.Parse("#BA1A1A"), Success = Color.Parse("#1B6D24"), Warning = Color.Parse("#825500"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #12000000, 0 4 12 1 #0D000000")+ };+ return true;+ }++ // 8. Golden Parchment (Light: #8A6B24, Dark: #D4AF37 / #E8C85A)+ if (ColorMatches(seed, Color.Parse("#8A6B24")) || ColorMatches(seed, Color.Parse("#D4AF37")) || ColorMatches(seed, Color.Parse("#D5B572")))+ {+ palette = isDark ? new MaterialYouPalette+ {+ Primary = Color.Parse("#E8C85A"), OnPrimary = Color.Parse("#252219"),+ PrimaryContainer = Color.Parse("#383523"), OnPrimaryContainer = Color.Parse("#FAF6ED"),+ Secondary = Color.Parse("#D4AF37"), OnSecondary = Color.Parse("#252219"),+ SecondaryContainer = Color.Parse("#2F2D1F"), OnSecondaryContainer = Color.Parse("#FAF6ED"),+ Surface = Color.Parse("#252219"), SurfaceDim = Color.Parse("#19180F"), SurfaceBright = Color.Parse("#423B2A"),+ SurfaceContainerLowest = Color.Parse("#19180F"), SurfaceContainerLow = Color.Parse("#1E1D13"),+ SurfaceContainer = Color.Parse("#262519"), SurfaceContainerHigh = Color.Parse("#2E2D1F"),+ SurfaceContainerHighest = Color.Parse("#373525"),+ OnSurface = Color.Parse("#FAF6ED"), OnSurfaceVariant = Color.Parse("#C7C0B0"),+ Outline = Color.Parse("#6B654F"), OutlineVariant = Color.Parse("#3E3C2F"),+ Danger = Color.Parse("#FFB4AB"), Success = Color.Parse("#8CD692"), Warning = Color.Parse("#FFBA2F"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #35000000, 0 8 20 0 #20000000")+ } : new MaterialYouPalette+ {+ Primary = Color.Parse("#8A6B24"), OnPrimary = Color.Parse("#FFFDF7"),+ PrimaryContainer = Color.Parse("#EFE3C7"), OnPrimaryContainer = Color.Parse("#2E2A1A"),+ Secondary = Color.Parse("#9E7E38"), OnSecondary = Color.Parse("#FFFDF7"),+ SecondaryContainer = Color.Parse("#E8DCBA"), OnSecondaryContainer = Color.Parse("#2E2A1A"),+ Surface = Color.Parse("#FAF6ED"), SurfaceDim = Color.Parse("#F2ECE0"), SurfaceBright = Colors.White,+ SurfaceContainerLowest = Colors.White, SurfaceContainerLow = Color.Parse("#F5EFE0"),+ SurfaceContainer = Color.Parse("#EDE4D1"), SurfaceContainerHigh = Color.Parse("#E5D9C2"),+ SurfaceContainerHighest = Color.Parse("#DCCDB0"),+ OnSurface = Color.Parse("#252219"), OnSurfaceVariant = Color.Parse("#5A5445"),+ Outline = Color.Parse("#928974"), OutlineVariant = Color.Parse("#D8CFBC"),+ Danger = Color.Parse("#BA1A1A"), Success = Color.Parse("#1B6D24"), Warning = Color.Parse("#825500"),+ CardShadow = BoxShadows.Parse("0 1 3 0 #12000000, 0 4 12 1 #0D000000")+ };+ return true;+ }++ palette = null!;+ return false;+ }+++ /// <summary>RGB (0..255) to HSL (H: 0..360, S: 0..1, L: 0..1).</summary>+ public static (double H, double S, double L) RgbToHsl(Color c)+ {+ double r = c.R / 255.0, g = c.G / 255.0, b = c.B / 255.0;+ double max = Math.Max(r, Math.Max(g, b));+ double min = Math.Min(r, Math.Min(g, b));+ double h = 0, s = 0, l = (max + min) / 2.0;++ if (Math.Abs(max - min) > 1e-5)+ {+ double d = max - min;+ s = l > 0.5 ? d / (2.0 - max - min) : d / (max + min);+ if (Math.Abs(max - r) < 1e-5)+ h = (g - b) / d + (g < b ? 6 : 0);+ else if (Math.Abs(max - g) < 1e-5)+ h = (b - r) / d + 2;+ else+ h = (r - g) / d + 4;+ h /= 6.0;+ }+ return (h * 360.0, s, l);+ }++ /// <summary>HSL (H: 0..360, S: 0..1, L: 0..1) to RGB Color.</summary>+ public static Color HslToRgb(double h, double s, double l, byte a = 255)+ {+ h = (h % 360 + 360) % 360;+ s = Math.Clamp(s, 0, 1);+ l = Math.Clamp(l, 0, 1);++ if (s <= 1e-5)+ {+ var v = (byte)Math.Round(l * 255);+ return Color.FromArgb(a, v, v, v);+ }++ double q = l < 0.5 ? l * (1 + s) : l + s - l * s;+ double p = 2 * l - q;+ double hk = h / 360.0;++ byte Component(double tc)+ {+ if (tc < 0) tc += 1;+ if (tc > 1) tc -= 1;+ if (tc < 1.0 / 6.0) return (byte)Math.Round((p + (q - p) * 6.0 * tc) * 255);+ if (tc < 1.0 / 2.0) return (byte)Math.Round(q * 255);+ if (tc < 2.0 / 3.0) return (byte)Math.Round((p + (q - p) * (2.0 / 3.0 - tc) * 6.0) * 255);+ return (byte)Math.Round(p * 255);+ }++ return Color.FromArgb(a, Component(hk + 1.0 / 3.0), Component(hk), Component(hk - 1.0 / 3.0));+ }+}diff --git a/src/Filee.App/Services/ThemeService.cs b/src/Filee.App/Services/ThemeService.csindex 30889d3f..7b1a899d 100644--- a/src/Filee.App/Services/ThemeService.cs+++ b/src/Filee.App/Services/ThemeService.cs@@ -1,9 +1,10 @@-// Applies ThemeSettings (light/dark, accent colour, corner radius, font order, reduced motion) and the user's+// Applies ThemeSettings (light/dark, accent colour, corner radius, font order, reduced motion, theme style) and the user's// theme.json colours at runtime by writing resources into Application.Resources. All styles reference these with// DynamicResource.using Avalonia;using Avalonia.Controls;+using Avalonia.Controls.ApplicationLifetimes;using Avalonia.Media;using Avalonia.Styling;using Filee.Core.Platform;@@ -12,11 +13,69 @@ using Filee.Core.Settings;namespace Filee.App.Services;/// <summary>Runtime theming.</summary>-public sealed class ThemeService(IPlatformServices platform)+public sealed class ThemeService{- /// <summary>Accent swatches offered in the Theme page.</summary>+ private readonly IPlatformServices _platform;++ private static readonly List<WeakReference<Window>> s_openWindows = [];++ public ThemeService(IPlatformServices platform)+ {+ _platform = platform;+ Window.WindowOpenedEvent.AddClassHandler<Window>((w, _) =>+ {+ lock (s_openWindows)+ {+ s_openWindows.RemoveAll(r => !r.TryGetTarget(out var target) || target == w);+ s_openWindows.Add(new WeakReference<Window>(w));+ }+ if (IsMaterialYou)+ w.Classes.Set("material-you", true);+ });+ Window.WindowClosedEvent.AddClassHandler<Window>((w, _) =>+ {+ lock (s_openWindows)+ {+ s_openWindows.RemoveAll(r => !r.TryGetTarget(out var target) || target == w);+ }+ });+ }++ /// <summary>Accent swatches offered in the Theme page for Soft theme.</summary>public static readonly IReadOnlyList<string> Swatches =- ["#7F77DD", "#1D9E75", "#D85A30", "#378ADD", "#D4537E", "#BA7517", "#639922", "#5F5E5A"];+ ["#7F77DD", "#1D9E75", "#D85A30", "#378ADD", "#D4537E", "#BA7517", "#639922", "#5F5E5A", "#111111", "#FFFFFF"];++ /// <summary>Curated Material 3 seed swatches for Material You theme.</summary>+ public static readonly IReadOnlyList<string> MaterialYouSwatches =+ ["#6750A4", "#0B57D0", "#006C4C", "#B3261E", "#825500", "#7F77DD", "#006A6A", "#4C616B", "#111111", "#FFFFFF"];++ /// <summary>Inkora pastel preset definition with coordinated light and dark seeds.</summary>+ public sealed record InkoraPastelPreset(string Key, string Name, string LightHex, string DarkHex);++ /// <summary>Curated Inkora pastel and monochrome presets with name and light/dark color mappings.</summary>+ public static readonly IReadOnlyList<InkoraPastelPreset> InkoraPresets =+ [+ new("monochrome", "Black & White", "#111111", "#FFFFFF"),+ new("blushPeach", "Blush & Peach", "#E07A70", "#F29B91"),+ new("strawberryMilk", "Strawberry Milk", "#E86483", "#F79BB0"),+ new("matchaLatte", "Matcha Latte", "#5A8E51", "#8DC983"),+ new("lavenderMist", "Lavender Mist", "#8B7AB8", "#BCAEE5"),+ new("sageMint", "Sage & Mint", "#529B7D", "#88D5B1"),+ new("honeyAmber", "Honey & Amber", "#CB852A", "#F0BA6A"),+ new("cloudSky", "Cloud & Sky", "#5B8BE3", "#98B8F6"),+ new("goldenParchment", "Golden Parchment", "#8A6B24", "#D4AF37"),+ ];++ /// <summary>Curated pastel palette add-on swatches from Inkora for both Material You and System/Soft themes.</summary>+ public static readonly IReadOnlyList<string> PastelSwatches =+ ["#E07A70", "#E86483", "#5A8E51", "#8B7AB8", "#529B7D", "#CB852A", "#5B8BE3", "#8A6B24",+ "#F29B91", "#F79BB0", "#8DC983", "#BCAEE5", "#88D5B1", "#F0BA6A", "#98B8F6", "#D4AF37"];++ /// <summary>Currently active theme style.</summary>+ public ThemeStyle CurrentStyle { get; private set; } = ThemeStyle.Soft;++ /// <summary>True when the Material You theme is currently applied.</summary>+ public bool IsMaterialYou => CurrentStyle == ThemeStyle.MaterialYou;/// <summary>Embedded Noto fonts (see build/fetch-fonts.ps1). Missing files fall back to system fonts.</summary>private const string Latin = "fonts:Filee#Noto Sans";@@ -48,6 +107,10 @@ public sealed class ThemeService(IPlatformServices platform)var app = Application.Current ?? throw new InvalidOperationException("No application.");var res = app.Resources;+ CurrentStyle = theme.Style;+ var isM3 = theme.Style == ThemeStyle.MaterialYou;+ res["IsMaterialYouTheme"] = isM3;+app.RequestedThemeVariant = theme.Mode switch{ThemeMode.Light => ThemeVariant.Light,@@ -56,28 +119,152 @@ public sealed class ThemeService(IPlatformServices platform)};// Accent colour + derived shades. Fluent controls read the System* keys.- var accent = Color.TryParse(theme.Accent, out var parsed) ? parsed : Color.Parse("#7F77DD");- res["AccentColor"] = accent;- res["AccentBrush"] = new SolidColorBrush(accent);- res["AccentSoftBrush"] = new SolidColorBrush(accent, 0.18);- res["AccentFaintBrush"] = new SolidColorBrush(accent, 0.09);- res["AccentStrongBrush"] = new SolidColorBrush(Shade(accent, -0.25));- res["OnAccentBrush"] = new SolidColorBrush(Luminance(accent) > 0.6 ? Color.Parse("#1F1E1D") : Colors.White);- res["SystemAccentColor"] = accent;- res["SystemAccentColorLight1"] = Shade(accent, 0.15);- res["SystemAccentColorLight2"] = Shade(accent, 0.30);- res["SystemAccentColorLight3"] = Shade(accent, 0.45);- res["SystemAccentColorDark1"] = Shade(accent, -0.15);- res["SystemAccentColorDark2"] = Shade(accent, -0.30);- res["SystemAccentColorDark3"] = Shade(accent, -0.45);-- // "Softness": one radius drives every control.- var r = Math.Clamp(theme.CornerRadius, 0, 28);- res["SoftRadius"] = new CornerRadius(r);- res["SoftRadiusSmall"] = new CornerRadius(Math.Round(r * 0.55));- res["SoftRadiusLarge"] = new CornerRadius(Math.Round(r * 1.35));- res["ControlCornerRadius"] = new CornerRadius(Math.Round(r * 0.55));- res["OverlayCornerRadius"] = new CornerRadius(r);+ var accent = Color.TryParse(theme.Accent, out var parsed) ? parsed : Color.Parse(isM3 ? "#6750A4" : "#7F77DD");++ var isDarkVariant = theme.Mode switch+ {+ ThemeMode.Dark => true,+ ThemeMode.Light => false,+ _ => app.ActualThemeVariant == ThemeVariant.Dark+ };++ if (isM3)+ {+ var lightM3 = MaterialYouPalette.Generate(accent, isDark: false);+ var darkM3 = MaterialYouPalette.Generate(accent, isDark: true);+ var activeM3 = isDarkVariant ? darkM3 : lightM3;++ res["AccentColor"] = activeM3.Primary;+ res["AccentBrush"] = new SolidColorBrush(activeM3.Primary);+ res["AccentSoftBrush"] = new SolidColorBrush(activeM3.PrimaryContainer);+ res["AccentFaintBrush"] = new SolidColorBrush(activeM3.SecondaryContainer);+ res["AccentStrongBrush"] = new SolidColorBrush(activeM3.OnPrimaryContainer);+ res["OnAccentBrush"] = new SolidColorBrush(activeM3.OnPrimary);++ res["PrimaryContainerBrush"] = new SolidColorBrush(activeM3.PrimaryContainer);+ res["OnPrimaryContainerBrush"] = new SolidColorBrush(activeM3.OnPrimaryContainer);+ res["SecondaryContainerBrush"] = new SolidColorBrush(activeM3.SecondaryContainer);+ res["OnSecondaryContainerBrush"] = new SolidColorBrush(activeM3.OnSecondaryContainer);+ res["SurfaceBrush"] = new SolidColorBrush(activeM3.SurfaceContainer);+ res["PageBrush"] = new SolidColorBrush(activeM3.SurfaceContainerLowest);+ res["SurfaceAltBrush"] = new SolidColorBrush(activeM3.SurfaceContainerHigh);+ res["SurfaceContainerBrush"] = new SolidColorBrush(activeM3.SurfaceContainer);+ res["SurfaceContainerLowBrush"] = new SolidColorBrush(activeM3.SurfaceContainerLow);+ res["SurfaceContainerHighBrush"] = new SolidColorBrush(activeM3.SurfaceContainerHigh);+ res["SurfaceContainerHighestBrush"] = new SolidColorBrush(activeM3.SurfaceContainerHighest);+ res["SubtleBorderBrush"] = new SolidColorBrush(activeM3.OutlineVariant);+ res["TextPrimaryBrush"] = new SolidColorBrush(activeM3.OnSurface);+ res["TextSecondaryBrush"] = new SolidColorBrush(activeM3.OnSurfaceVariant);+ res["DangerBrush"] = new SolidColorBrush(activeM3.Danger);+ res["SuccessBrush"] = new SolidColorBrush(activeM3.Success);+ res["WarningBrush"] = new SolidColorBrush(activeM3.Warning);+ res["CardShadow"] = activeM3.CardShadow;+ res["DropZoneBackgroundBrush"] = new SolidColorBrush(activeM3.SurfaceContainerLow);+ res["DropZoneBorderBrush"] = new SolidColorBrush(activeM3.OutlineVariant);++ res["SystemAccentColor"] = activeM3.Primary;+ res["SystemAccentColorLight1"] = Shade(activeM3.Primary, 0.15);+ res["SystemAccentColorLight2"] = Shade(activeM3.Primary, 0.30);+ res["SystemAccentColorLight3"] = Shade(activeM3.Primary, 0.45);+ res["SystemAccentColorDark1"] = Shade(activeM3.Primary, -0.15);+ res["SystemAccentColorDark2"] = Shade(activeM3.Primary, -0.30);+ res["SystemAccentColorDark3"] = Shade(activeM3.Primary, -0.45);++ // Fluent control brush keys harmonized with M3 roles+ res["SliderTrackFill"] = new SolidColorBrush(activeM3.Primary);+ res["SliderTrackValueFill"] = new SolidColorBrush(activeM3.Primary);+ res["SliderThumbBackground"] = new SolidColorBrush(activeM3.Primary);+ res["SliderThumbBorderBrush"] = new SolidColorBrush(activeM3.Primary);+ res["SliderTrackBackground"] = new SolidColorBrush(activeM3.SurfaceContainerHighest);+ res["ProgressBarTrackFill"] = new SolidColorBrush(activeM3.Primary);+ res["ProgressBarBackground"] = new SolidColorBrush(activeM3.SurfaceContainerHighest);+ res["ProgressBarProgress"] = new SolidColorBrush(activeM3.Primary);+ res["ToggleSwitchFillOn"] = new SolidColorBrush(activeM3.Primary);+ res["ToggleSwitchFillOff"] = new SolidColorBrush(activeM3.SurfaceContainerHighest);+ res["ToggleSwitchKnobFillOn"] = new SolidColorBrush(activeM3.OnPrimary);+ res["ToggleSwitchKnobFillOff"] = new SolidColorBrush(activeM3.Outline);+ res["ToggleSwitchStrokeOff"] = new SolidColorBrush(activeM3.Outline);+ res["CheckBoxCheckBackgroundFillChecked"] = new SolidColorBrush(activeM3.Primary);+ res["CheckBoxCheckBackgroundStrokeChecked"] = new SolidColorBrush(activeM3.Primary);+ res["CheckBoxCheckGlyphForegroundChecked"] = new SolidColorBrush(activeM3.OnPrimary);+ res["AccentButtonBackground"] = new SolidColorBrush(activeM3.Primary);+ res["AccentButtonForeground"] = new SolidColorBrush(activeM3.OnPrimary);+ res["AccentButtonBackgroundPointerOver"] = new SolidColorBrush(activeM3.Secondary);+ res["AccentButtonForegroundPointerOver"] = new SolidColorBrush(activeM3.OnSecondary);+ res["AccentButtonBackgroundPressed"] = new SolidColorBrush(activeM3.PrimaryContainer);+ res["AccentButtonForegroundPressed"] = new SolidColorBrush(activeM3.OnPrimaryContainer);++ // "Softness": Material You expressive pill and rounded containers+ var r = Math.Clamp(theme.CornerRadius, 0, 28);+ res["SoftRadius"] = new CornerRadius(Math.Max(16, r));+ res["SoftRadiusSmall"] = new CornerRadius(12);+ res["SoftRadiusLarge"] = new CornerRadius(24);+ res["PillRadius"] = new CornerRadius(999);+ res["ControlCornerRadius"] = new CornerRadius(12);+ res["OverlayCornerRadius"] = new CornerRadius(20);++ ApplyMaterialYouTheme(res, ThemeVariant.Light, lightM3, custom?.Light);+ ApplyMaterialYouTheme(res, ThemeVariant.Dark, darkM3, custom?.Dark);+ }+ else+ {+ res["AccentColor"] = accent;+ res["AccentBrush"] = new SolidColorBrush(accent);+ res["AccentSoftBrush"] = new SolidColorBrush(accent, isDarkVariant ? 0.22 : 0.16);+ res["AccentFaintBrush"] = new SolidColorBrush(accent, isDarkVariant ? 0.12 : 0.08);+ res["AccentStrongBrush"] = new SolidColorBrush(isDarkVariant+ ? (MaterialYouPalette.Luminance(accent) > 0.45 ? accent : Shade(accent, 0.35))+ : (MaterialYouPalette.Luminance(accent) < 0.45 ? accent : Shade(accent, -0.35)));+ res["OnAccentBrush"] = new SolidColorBrush(MaterialYouPalette.TextOn(accent));+ res["SystemAccentColor"] = accent;+ res["SystemAccentColorLight1"] = Shade(accent, 0.15);+ res["SystemAccentColorLight2"] = Shade(accent, 0.30);+ res["SystemAccentColorLight3"] = Shade(accent, 0.45);+ res["SystemAccentColorDark1"] = Shade(accent, -0.15);+ res["SystemAccentColorDark2"] = Shade(accent, -0.30);+ res["SystemAccentColorDark3"] = Shade(accent, -0.45);++ res["DropZoneBackgroundBrush"] = isDarkVariant+ ? new SolidColorBrush(Color.Parse("#252523"))+ : new SolidColorBrush(Color.Parse("#F5F3ED"));+ res["DropZoneBorderBrush"] = new SolidColorBrush(accent, 0.25);++ res["AccentButtonBackground"] = res["AccentBrush"];+ res["AccentButtonForeground"] = res["OnAccentBrush"];+ res["AccentButtonBackgroundPointerOver"] = res["AccentStrongBrush"];+ res["AccentButtonForegroundPointerOver"] = res["OnAccentBrush"];+ res["AccentButtonBackgroundPressed"] = res["AccentFaintBrush"];+ res["AccentButtonForegroundPressed"] = res["OnAccentBrush"];++ // Clean up M3 Fluent overrides if present+ res.Remove("SliderTrackFill");+ res.Remove("SliderTrackValueFill");+ res.Remove("SliderThumbBackground");+ res.Remove("SliderThumbBorderBrush");+ res.Remove("SliderTrackBackground");+ res.Remove("ProgressBarTrackFill");+ res.Remove("ProgressBarBackground");+ res.Remove("ProgressBarProgress");+ res.Remove("ToggleSwitchFillOn");+ res.Remove("ToggleSwitchFillOff");+ res.Remove("ToggleSwitchKnobFillOn");+ res.Remove("ToggleSwitchKnobFillOff");+ res.Remove("ToggleSwitchStrokeOff");+ res.Remove("CheckBoxCheckBackgroundFillChecked");+ res.Remove("CheckBoxCheckBackgroundStrokeChecked");+ res.Remove("CheckBoxCheckGlyphForegroundChecked");++ var r = Math.Clamp(theme.CornerRadius, 0, 28);+ res["SoftRadius"] = new CornerRadius(r);+ res["SoftRadiusSmall"] = new CornerRadius(Math.Round(r * 0.55));+ res["SoftRadiusLarge"] = new CornerRadius(Math.Round(r * 1.35));+ res["PillRadius"] = new CornerRadius(999);+ res["ControlCornerRadius"] = new CornerRadius(Math.Round(r * 0.55));+ res["OverlayCornerRadius"] = new CornerRadius(r);++ ApplyCustom(res, ThemeVariant.Light, custom?.Light);+ ApplyCustom(res, ThemeVariant.Dark, custom?.Dark);+ }// Han characters look different in Korean and Chinese fonts: put the UI language's font first.var cjk = language.StartsWith("zh", StringComparison.OrdinalIgnoreCase)@@ -85,11 +272,46 @@ public sealed class ThemeService(IPlatformServices platform): $"{Korean}, {Chinese}";res["AppFontFamily"] = FontFamily.Parse($"{Latin}, {Devanagari}, {cjk}, {SystemFallbacks}");- // Application.Resources is searched before the styles, so these theme dictionaries win over Soft.axaml's.- ApplyCustom(res, ThemeVariant.Light, custom?.Light);- ApplyCustom(res, ThemeVariant.Dark, custom?.Dark);+ // Update all active windows+ lock (s_openWindows)+ {+ s_openWindows.RemoveAll(r => !r.TryGetTarget(out _));+ foreach (var r in s_openWindows)+ if (r.TryGetTarget(out var window))+ window.Classes.Set("material-you", isM3);+ }+ if (app.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)+ {+ foreach (var window in desktop.Windows)+ window.Classes.Set("material-you", isM3);+ }++ Motion.Configure(theme.ReduceMotion, () => _platform.PrefersReducedMotion);+ }++ /// <summary>Applies Material You generated colors to the theme dictionary for one variant.</summary>+ private static void ApplyMaterialYouTheme(IResourceDictionary res, ThemeVariant variant, MaterialYouPalette m3, IReadOnlyDictionary<string, string>? custom)+ {+ var dict = new ResourceDictionary+ {+ ["PageBrush"] = new SolidColorBrush(m3.SurfaceContainerLowest),+ ["SurfaceBrush"] = new SolidColorBrush(m3.Surface),+ ["SurfaceAltBrush"] = new SolidColorBrush(m3.SurfaceContainerHigh),+ ["SubtleBorderBrush"] = new SolidColorBrush(m3.OutlineVariant),+ ["TextPrimaryBrush"] = new SolidColorBrush(m3.OnSurface),+ ["TextSecondaryBrush"] = new SolidColorBrush(m3.OnSurfaceVariant),+ ["DangerBrush"] = new SolidColorBrush(m3.Danger),+ ["SuccessBrush"] = new SolidColorBrush(m3.Success),+ ["WarningBrush"] = new SolidColorBrush(m3.Warning),+ ["CardShadow"] = m3.CardShadow,+ };++ // Custom colours from theme.json take precedence if present+ foreach (var (name, value) in custom ?? new Dictionary<string, string>())+ if (CustomBrushKeys.TryGetValue(name, out var key) && Color.TryParse(value, out var color))+ dict[key] = new SolidColorBrush(color);- Motion.Configure(theme.ReduceMotion, () => platform.PrefersReducedMotion);+ res.ThemeDictionaries[variant] = dict;}/// <summary>Replaces (or, with no colours, removes) the user's colours for one variant.</summary>diff --git a/src/Filee.App/ViewModels/Pages/ThemePageViewModel.cs b/src/Filee.App/ViewModels/Pages/ThemePageViewModel.csindex badc7bc3..2a819f7e 100644--- a/src/Filee.App/ViewModels/Pages/ThemePageViewModel.cs+++ b/src/Filee.App/ViewModels/Pages/ThemePageViewModel.cs@@ -1,6 +1,8 @@-// Theme: light/dark, accent colour, softness (corner radius), reduce animations. Changes apply live.+// Theme: light/dark, style (Soft / Material You), accent colour, softness, reduce animations. Changes apply live.+using Avalonia;using Avalonia.Media;+using Avalonia.Styling;using CommunityToolkit.Mvvm.ComponentModel;using CommunityToolkit.Mvvm.Input;using Filee.App.Controls;@@ -15,18 +17,26 @@ public sealed partial class ThemePageViewModel : ObservableObject{private readonly UserDataStore _store;private readonly bool _loading;+ private MaterialYouPalette? _currentPalette;public ThemePageViewModel(UserDataStore store, ILocalizer loc, IPlatformServices platform){_store = store;_loading = true;var theme = store.Settings.Theme;++ Styles = Enum.GetValues<ThemeStyle>().Select(s => new Choice<ThemeStyle>(s, loc[$"theme.style.{s}"])).ToList();+ Style = Styles.FirstOrDefault(s => s.Value == theme.Style) ?? Styles[0];+Modes = Enum.GetValues<ThemeMode>().Select(m => new Choice<ThemeMode>(m, loc[$"theme.mode.{m}"])).ToList();Mode = Modes.First(m => m.Value == theme.Mode);- Accent = Color.TryParse(theme.Accent, out var c) ? c : Colors.MediumPurple;++ Accent = Color.TryParse(theme.Accent, out var c) ? c : (theme.Style == ThemeStyle.MaterialYou ? Color.Parse("#6750A4") : Colors.MediumPurple);AccentHex = $"#{Accent.R:X2}{Accent.G:X2}{Accent.B:X2}";CornerRadius = theme.CornerRadius;+ DonutOpacity = Math.Clamp(Math.Round(store.Settings.Donut.Opacity * 100), 10, 100);ReduceMotion = theme.ReduceMotion ?? platform.PrefersReducedMotion;+PreviewItems =[new DonutItem { Id = "a", Label = "PNG" },@@ -36,31 +46,94 @@ public sealed partial class ThemePageViewModel : ObservableObjectnew DonutItem { Id = "e", Label = "JPG 70%", Caption = "JPG" },new DonutItem { Id = "f", Label = "TIFF" },];++ UpdateTonalPalette();_loading = false;}+ public IReadOnlyList<Choice<ThemeStyle>> Styles { get; }public IReadOnlyList<Choice<ThemeMode>> Modes { get; }- public IReadOnlyList<Color> Swatches { get; } = ThemeService.Swatches.Select(Color.Parse).ToList();public IReadOnlyList<DonutItem> PreviewItems { get; }+ public sealed record InkoraPresetItem(string Key, string Name, Color LightColor, Color DarkColor, Color ActiveColor);++ public IReadOnlyList<InkoraPresetItem> InkoraPresets+ {+ get+ {+ var isDark = Mode?.Value == ThemeMode.Dark || (Mode?.Value == ThemeMode.System && Application.Current?.ActualThemeVariant == ThemeVariant.Dark);+ return ThemeService.InkoraPresets.Select(p =>+ {+ var lc = Color.Parse(p.LightHex);+ var dc = Color.Parse(p.DarkHex);+ return new InkoraPresetItem(p.Key, p.Name, lc, dc, isDark ? dc : lc);+ }).ToList();+ }+ }++ public IReadOnlyList<Color> StandardSwatches =>+ (IsMaterialYou ? ThemeService.MaterialYouSwatches : ThemeService.Swatches).Select(Color.Parse).ToList();++ public IReadOnlyList<Color> PastelSwatches =>+ ThemeService.PastelSwatches.Select(Color.Parse).ToList();++ public IReadOnlyList<Color> Swatches => StandardSwatches;++ public bool IsMaterialYou => Style?.Value == ThemeStyle.MaterialYou;++ [ObservableProperty] private Choice<ThemeStyle> _style = null!;[ObservableProperty] private Choice<ThemeMode> _mode = null!;[ObservableProperty, NotifyPropertyChangedFor(nameof(AccentBrush))] private Color _accent;[ObservableProperty] private string _accentHex = "";public IBrush AccentBrush => new SolidColorBrush(Accent);[ObservableProperty] private double _cornerRadius;+ [ObservableProperty, NotifyPropertyChangedFor(nameof(DonutSliceOpacity))] private double _donutOpacity = 96;+ public double DonutSliceOpacity => DonutOpacity / 100.0;[ObservableProperty] private bool _reduceMotion;+ partial void OnDonutOpacityChanged(double value)+ {+ OnPropertyChanged(nameof(DonutSliceOpacity));+ if (!_loading)+ {+ var clamped = Math.Clamp(value, 10, 100);+ _store.Settings.Donut.Opacity = Math.Round(clamped) / 100.0;+ _store.SaveSettings();+ }+ }++ // Material You Tonal Palette preview tokens+ public IBrush TonalPrimary => new SolidColorBrush(_currentPalette?.Primary ?? Accent);+ public IBrush TonalPrimaryContainer => new SolidColorBrush(_currentPalette?.PrimaryContainer ?? Accent);+ public IBrush TonalSecondaryContainer => new SolidColorBrush(_currentPalette?.SecondaryContainer ?? Accent);+ public IBrush TonalSurfaceContainer => new SolidColorBrush(_currentPalette?.SurfaceContainer ?? Colors.Gray);+ public IBrush TonalSurface => new SolidColorBrush(_currentPalette?.Surface ?? Colors.White);++ partial void OnStyleChanged(Choice<ThemeStyle>? oldValue, Choice<ThemeStyle> newValue)+ {+ OnPropertyChanged(nameof(IsMaterialYou));+ OnPropertyChanged(nameof(StandardSwatches));+ OnPropertyChanged(nameof(Swatches));+ UpdateTonalPalette();+ if (!Choices.Restore(oldValue, newValue, v => Style = v))+ Save(t => t.Style = newValue.Value);+ }+partial void OnModeChanged(Choice<ThemeMode>? oldValue, Choice<ThemeMode> newValue){+ OnPropertyChanged(nameof(InkoraPresets));+ UpdateTonalPalette();if (!Choices.Restore(oldValue, newValue, v => Mode = v))Save(t => t.Mode = newValue.Value);}+partial void OnAccentChanged(Color value){var hex = $"#{value.R:X2}{value.G:X2}{value.B:X2}";if (!string.Equals(AccentHex, hex, StringComparison.OrdinalIgnoreCase))AccentHex = hex;+ UpdateTonalPalette();Save(t => t.Accent = hex);}@@ -70,12 +143,36 @@ public sealed partial class ThemePageViewModel : ObservableObjectif (Color.TryParse(value.Trim(), out var color) && color != Accent)Accent = Color.FromRgb(color.R, color.G, color.B);}+partial void OnCornerRadiusChanged(double value) => Save(t => t.CornerRadius = Math.Round(value));partial void OnReduceMotionChanged(bool value) => Save(t => t.ReduceMotion = value);[RelayCommand]private void PickSwatch(Color color) => Accent = color;+ [RelayCommand]+ private void PickInkoraPreset(InkoraPresetItem preset) => Accent = preset.ActiveColor;++ [RelayCommand]+ private void SetStyle(ThemeStyle target)+ {+ var match = Styles.FirstOrDefault(s => s.Value == target);+ if (match != null && Style != match)+ Style = match;+ }++ private void UpdateTonalPalette()+ {+ var isDark = Mode?.Value == ThemeMode.Dark ||+ (Mode?.Value == ThemeMode.System && Application.Current?.ActualThemeVariant == ThemeVariant.Dark);+ _currentPalette = MaterialYouPalette.Generate(Accent, isDark);+ OnPropertyChanged(nameof(TonalPrimary));+ OnPropertyChanged(nameof(TonalPrimaryContainer));+ OnPropertyChanged(nameof(TonalSecondaryContainer));+ OnPropertyChanged(nameof(TonalSurfaceContainer));+ OnPropertyChanged(nameof(TonalSurface));+ }+private void Save(Action<ThemeSettings> change){if (_loading)diff --git a/src/Filee.App/Views/Pages/ThemePage.axaml b/src/Filee.App/Views/Pages/ThemePage.axamlindex 6d96b46b..0099af95 100644--- a/src/Filee.App/Views/Pages/ThemePage.axaml+++ b/src/Filee.App/Views/Pages/ThemePage.axaml@@ -2,12 +2,61 @@xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:vm="using:Filee.App.ViewModels.Pages"xmlns:c="using:Filee.App.Controls"+ xmlns:settings="using:Filee.Core.Settings"x:Class="Filee.App.Views.Pages.ThemePage"x:DataType="vm:ThemePageViewModel">- <Grid ColumnDefinitions="*,20,340" RowDefinitions="Auto,*">+ <Grid ColumnDefinitions="*,24,340" RowDefinitions="Auto,Auto"><TextBlock Grid.ColumnSpan="3" Classes="h1" Text="{DynamicResource theme.title}" Margin="0,0,0,18" /><StackPanel Grid.Row="1" Spacing="16">+ <!-- Theme Style: Filee Soft vs Google Material You (M3) -->+ <Border Classes="card">+ <StackPanel Spacing="12">+ <DockPanel>+ <Border DockPanel.Dock="Right" CornerRadius="999" Background="{DynamicResource AccentSoftBrush}" Padding="8,2"+ IsVisible="{Binding IsMaterialYou}">+ <TextBlock Text="Material 3" FontSize="11" FontWeight="SemiBold" Foreground="{DynamicResource AccentStrongBrush}" />+ </Border>+ <TextBlock Classes="label" Text="{DynamicResource theme.style}" VerticalAlignment="Center" Margin="0" />+ </DockPanel>++ <Grid ColumnDefinitions="*,12,*" RowDefinitions="1*">+ <!-- Filee Soft Choice Card -->+ <Button Classes="choice-card"+ Classes.selected="{Binding !IsMaterialYou}"+ Command="{Binding SetStyleCommand}"+ CommandParameter="{x:Static settings:ThemeStyle.Soft}"+ HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"+ VerticalAlignment="Stretch" VerticalContentAlignment="Stretch">+ <StackPanel Spacing="6" VerticalAlignment="Top">+ <TextBlock Classes="choice-title" Text="{DynamicResource theme.style.Soft}" />+ <TextBlock Classes="choice-desc" Text="{DynamicResource theme.style.soft_hint}" TextWrapping="Wrap" />+ </StackPanel>+ </Button>++ <!-- Material You Choice Card -->+ <Button Grid.Column="2"+ Classes="choice-card"+ Classes.selected="{Binding IsMaterialYou}"+ Command="{Binding SetStyleCommand}"+ CommandParameter="{x:Static settings:ThemeStyle.MaterialYou}"+ HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"+ VerticalAlignment="Stretch" VerticalContentAlignment="Stretch">+ <StackPanel Spacing="6" VerticalAlignment="Top">+ <StackPanel Orientation="Horizontal" Spacing="6" VerticalAlignment="Center">+ <TextBlock Classes="choice-title" Text="{DynamicResource theme.style.MaterialYou}" />+ <Border CornerRadius="999" Background="{DynamicResource AccentBrush}" Padding="6,1">+ <TextBlock Text="M3" FontSize="10" FontWeight="Bold" Foreground="{DynamicResource OnAccentBrush}" />+ </Border>+ </StackPanel>+ <TextBlock Classes="choice-desc" Text="{DynamicResource theme.style.material_you_hint}" TextWrapping="Wrap" />+ </StackPanel>+ </Button>+ </Grid>+ </StackPanel>+ </Border>++ <!-- Appearance Mode: System / Light / Dark --><Border Classes="card"><StackPanel Spacing="8"><TextBlock Classes="label" Text="{DynamicResource theme.mode}" />@@ -15,10 +64,47 @@</StackPanel></Border>+ <!-- Accent Color & Dynamic Tonal Palette --><Border Classes="card">- <StackPanel Spacing="10">+ <StackPanel Spacing="12"><TextBlock Classes="label" Text="{DynamicResource theme.accent}" />- <ItemsControl ItemsSource="{Binding Swatches}">++ <!-- Inkora Curated Pastel Presets -->+ <DockPanel Margin="0,4,0,0">+ <Border DockPanel.Dock="Right" CornerRadius="999" Background="{DynamicResource AccentSoftBrush}" Padding="8,2">+ <TextBlock Text="Inkora Collection" FontSize="11" FontWeight="SemiBold" Foreground="{DynamicResource AccentStrongBrush}" />+ </Border>+ <TextBlock Classes="caption" Text="Curated Pastel Themes" FontWeight="SemiBold" VerticalAlignment="Center" />+ </DockPanel>+ <ItemsControl ItemsSource="{Binding InkoraPresets}">+ <ItemsControl.ItemsPanel>+ <ItemsPanelTemplate>+ <UniformGrid Columns="2" />+ </ItemsPanelTemplate>+ </ItemsControl.ItemsPanel>+ <ItemsControl.ItemTemplate>+ <DataTemplate x:DataType="vm:ThemePageViewModel+InkoraPresetItem">+ <Button Classes="preset-pill" Margin="0,0,6,6"+ Command="{Binding $parent[ItemsControl].((vm:ThemePageViewModel)DataContext).PickInkoraPresetCommand}"+ CommandParameter="{Binding}">+ <DockPanel>+ <Border DockPanel.Dock="Left" Width="18" Height="18" CornerRadius="999" Margin="0,0,8,0"+ BorderBrush="{DynamicResource SubtleBorderBrush}" BorderThickness="1">+ <Border.Background>+ <SolidColorBrush Color="{Binding ActiveColor}" />+ </Border.Background>+ </Border>+ <TextBlock Text="{Binding Name}" VerticalAlignment="Center" FontSize="12" FontWeight="Medium"+ TextTrimming="CharacterEllipsis" />+ </DockPanel>+ </Button>+ </DataTemplate>+ </ItemsControl.ItemTemplate>+ </ItemsControl>++ <!-- Standard / Vibrant Seeds -->+ <TextBlock Classes="caption" Text="Vibrant & Signature Swatches" FontWeight="SemiBold" Margin="0,4,0,0" />+ <ItemsControl ItemsSource="{Binding StandardSwatches}"><ItemsControl.ItemsPanel><ItemsPanelTemplate><WrapPanel />@@ -26,9 +112,9 @@</ItemsControl.ItemsPanel><ItemsControl.ItemTemplate><DataTemplate x:DataType="Color">- <Button Width="34" Height="34" Margin="0,0,8,8" CornerRadius="999" Padding="0"+ <Button Classes="swatch" Margin="0,0,8,8"Command="{Binding $parent[ItemsControl].((vm:ThemePageViewModel)DataContext).PickSwatchCommand}"- CommandParameter="{Binding}">+ CommandParameter="{Binding}" ToolTip.Tip="{Binding}"><Button.Background><SolidColorBrush Color="{Binding}" /></Button.Background>@@ -36,14 +122,29 @@</DataTemplate></ItemsControl.ItemTemplate></ItemsControl>- <StackPanel Orientation="Horizontal" Spacing="10">- <Border Width="34" Height="34" CornerRadius="999" Background="{Binding AccentBrush}" />++ <!-- Custom color row -->+ <StackPanel Orientation="Horizontal" Spacing="10" Margin="0,4,0,0">+ <Border Width="32" Height="32" CornerRadius="999" Background="{Binding AccentBrush}" BorderBrush="{DynamicResource SubtleBorderBrush}" BorderThickness="1" /><TextBlock Classes="label" VerticalAlignment="Center" Text="{DynamicResource theme.custom_color}" Margin="0" /><TextBox Text="{Binding AccentHex}" Width="120" PlaceholderText="#7F77DD" /></StackPanel>++ <!-- Dynamic Tonal Harmony preview for Material You -->+ <StackPanel Spacing="6" Margin="0,6,0,0" IsVisible="{Binding IsMaterialYou}">+ <TextBlock Classes="caption" Text="{DynamicResource theme.tonal_palette}" FontWeight="SemiBold" />+ <Grid ColumnDefinitions="*,4,*,4,*,4,*,4,*">+ <Border Height="28" CornerRadius="8,0,0,8" Background="{Binding TonalPrimary}" ToolTip.Tip="Primary" />+ <Border Grid.Column="2" Height="28" Background="{Binding TonalPrimaryContainer}" ToolTip.Tip="Primary Container" />+ <Border Grid.Column="4" Height="28" Background="{Binding TonalSecondaryContainer}" ToolTip.Tip="Secondary Container" />+ <Border Grid.Column="6" Height="28" Background="{Binding TonalSurfaceContainer}" ToolTip.Tip="Surface Container" />+ <Border Grid.Column="8" Height="28" CornerRadius="0,8,8,0" Background="{Binding TonalSurface}" ToolTip.Tip="Surface" />+ </Grid>+ </StackPanel></StackPanel></Border>+ <!-- Softness / Corner Radius --><Border Classes="card"><StackPanel Spacing="8"><DockPanel>@@ -54,6 +155,18 @@</StackPanel></Border>+ <!-- Donut Toolbar Transparency / Opacity (10% to 100%) -->+ <Border Classes="card">+ <StackPanel Spacing="8">+ <DockPanel>+ <TextBlock DockPanel.Dock="Right" FontWeight="SemiBold" Text="{Binding DonutOpacity, StringFormat={}{0:0}%}" />+ <TextBlock Classes="label" Text="Donut toolbar transparency" />+ </DockPanel>+ <Slider Minimum="10" Maximum="100" Value="{Binding DonutOpacity}" TickFrequency="5" IsSnapToTickEnabled="True" />+ </StackPanel>+ </Border>++ <!-- Motion / Animations --><Border Classes="card"><StackPanel Spacing="4"><CheckBox Content="{DynamicResource theme.reduce_motion}" IsChecked="{Binding ReduceMotion}" FontWeight="SemiBold" />@@ -66,7 +179,14 @@<Border Grid.Row="1" Grid.Column="2" Classes="card" VerticalAlignment="Top"><StackPanel Spacing="14"><TextBlock Classes="label" Text="{DynamicResource theme.preview}" />- <c:DonutMenu x:Name="PreviewDonut" Items="{Binding PreviewItems}" OuterRadius="120" CenterTitle="JPG × 3" HorizontalAlignment="Center" />+ <c:DonutMenu x:Name="PreviewDonut"+ Items="{Binding PreviewItems}"+ OuterRadius="120"+ CenterTitle="JPG × 3"+ CenterSubtitle="3 files"+ SliceOpacity="{Binding DonutSliceOpacity}"+ HorizontalAlignment="Center"+ IsMaterialYou="{Binding IsMaterialYou}" /><StackPanel Orientation="Horizontal" Spacing="8" HorizontalAlignment="Center"><Button Classes="accent" Content="{DynamicResource common.save}" /><Button Content="{DynamicResource common.cancel}" />diff --git a/src/Filee.Core/Settings/AppSettings.cs b/src/Filee.Core/Settings/AppSettings.csindex 432ddcf6..7ab836a1 100644--- a/src/Filee.Core/Settings/AppSettings.cs+++ b/src/Filee.Core/Settings/AppSettings.cs@@ -13,6 +13,16 @@ public enum ThemeModeDark,}+/// <summary>Visual theme style.</summary>+public enum ThemeStyle+{+ /// <summary>Filee classic soft pastel rounded design.</summary>+ Soft,++ /// <summary>Google Material 3 design with dynamic tonal palettes and pill shapes.</summary>+ MaterialYou,+}+/// <summary>What closing the main window does (Settings → General).</summary>public enum CloseAction{@@ -31,6 +41,8 @@ public sealed class ThemeSettings{public ThemeMode Mode { get; set; } = ThemeMode.System;+ public ThemeStyle Style { get; set; } = ThemeStyle.Soft;+/// <summary>Accent colour as <c>#RRGGBB</c>.</summary>public string Accent { get; set; } = "#7F77DD";diff --git a/src/Filee.Core/Settings/FileeJsonContext.cs b/src/Filee.Core/Settings/FileeJsonContext.csindex bb4e4b6b..9b38b679 100644--- a/src/Filee.Core/Settings/FileeJsonContext.cs+++ b/src/Filee.Core/Settings/FileeJsonContext.cs@@ -15,12 +15,13 @@ namespace Filee.Core.Settings;ReadCommentHandling = System.Text.Json.JsonCommentHandling.Skip,AllowTrailingCommas = true)][JsonSerializable(typeof(AppSettings))]+[JsonSerializable(typeof(ThemeStyle))][JsonSerializable(typeof(List<Preset>))][JsonSerializable(typeof(List<ToolbarProfile>))][JsonSerializable(typeof(PresetBundle))][JsonSerializable(typeof(List<HistoryEntry>))][JsonSerializable(typeof(CustomTheme))]-internal sealed partial class FileeJsonContext : JsonSerializerContext;+public sealed partial class FileeJsonContext : JsonSerializerContext;/// <summary>File format used to import / export presets and profiles.</summary>public sealed class PresetBundlediff --git a/tests/Filee.App.Tests/MaterialYouThemeTests.cs b/tests/Filee.App.Tests/MaterialYouThemeTests.csnew file mode 100644index 00000000..c4553cc2--- /dev/null+++ b/tests/Filee.App.Tests/MaterialYouThemeTests.cs@@ -0,0 +1,114 @@+// Tests for Material You theme: dynamic tonal palette generation, theme application, window styling, and localization.++using System.Text.Json;+using Avalonia;+using Avalonia.Controls;+using Avalonia.Headless.XUnit;+using Avalonia.Media;+using Filee.App.Controls;+using Filee.App.Services;+using Filee.Core.Settings;++namespace Filee.App.Tests;++public class MaterialYouThemeTests+{+ [Fact]+ public void ThemeSettings_persists_ThemeStyle()+ {+ var settings = new AppSettings+ {+ Theme = new ThemeSettings+ {+ Style = ThemeStyle.MaterialYou,+ Accent = "#6750A4",+ },+ };++ var json = JsonSerializer.Serialize(settings, FileeJsonContext.Default.AppSettings);+ Assert.Contains("\"style\": \"MaterialYou\"", json);++ var restored = JsonSerializer.Deserialize(json, FileeJsonContext.Default.AppSettings);+ Assert.NotNull(restored);+ Assert.Equal(ThemeStyle.MaterialYou, restored.Theme.Style);+ Assert.Equal("#6750A4", restored.Theme.Accent);+ }++ [Fact]+ public void Palette_generates_distinct_tonal_roles_for_light_and_dark()+ {+ var seed = Color.Parse("#6750A4");+ var light = MaterialYouPalette.Generate(seed, isDark: false);+ var dark = MaterialYouPalette.Generate(seed, isDark: true);++ // Light mode surfaces are bright, containers are soft pastels+ Assert.True(light.Surface.R > 230 && light.Surface.G > 230 && light.Surface.B > 230);+ Assert.True(light.OnSurface.R < 50 && light.OnSurface.G < 50 && light.OnSurface.B < 50);++ // Dark mode surfaces are deep dark, containers are rich dark+ Assert.True(dark.Surface.R < 40 && dark.Surface.G < 40 && dark.Surface.B < 40);+ Assert.True(dark.OnSurface.R > 200 && dark.OnSurface.G > 200 && dark.OnSurface.B > 200);++ // Primary is distinct from primary container+ Assert.NotEqual(light.Primary, light.PrimaryContainer);+ Assert.NotEqual(dark.Primary, dark.PrimaryContainer);+ }++ [AvaloniaFact]+ public void ThemeService_applies_MaterialYou_and_marks_windows()+ {+ TestServices.EnsureInitialized("en");+ var themeService = AppHost.Get<ThemeService>();+ var theme = new ThemeSettings+ {+ Style = ThemeStyle.MaterialYou,+ Accent = "#6750A4",+ };++ var window = new Window();++ try+ {+ themeService.Apply(theme, "en");+ window.Show();++ Assert.Equal(ThemeStyle.MaterialYou, themeService.CurrentStyle);+ Assert.True(themeService.IsMaterialYou);+ Assert.Contains("material-you", window.Classes);++ // Brushes and corner radius are written into Application resources+ var app = Application.Current!;+ Assert.True(app.Resources.ContainsKey("PrimaryContainerBrush"));+ Assert.True(app.Resources.ContainsKey("SecondaryContainerBrush"));+ Assert.True(app.Resources.ContainsKey("SliderTrackFill"));+ Assert.True(app.Resources.ContainsKey("ProgressBarTrackFill"));+ Assert.True(app.Resources.ContainsKey("ToggleSwitchFillOn"));++ var radius = Assert.IsType<CornerRadius>(app.Resources["SoftRadiusSmall"]);+ Assert.Equal(12, radius.TopLeft); // Smooth non-clipping inputs in Material You+ var pill = Assert.IsType<CornerRadius>(app.Resources["PillRadius"]);+ Assert.Equal(999, pill.TopLeft); // Full pill for chips & badges+ }+ finally+ {+ window.Close();+ themeService.Apply(new ThemeSettings(), "en");+ var app = Application.Current!;+ Assert.False(app.Resources.ContainsKey("SliderTrackFill"));+ }+ }++ [AvaloniaFact]+ public void DonutMenu_reflects_IsMaterialYou_property()+ {+ TestServices.EnsureInitialized("en");+ var donut = new DonutMenu+ {+ IsMaterialYou = true,+ };++ Assert.True(donut.IsMaterialYou);+ donut.IsMaterialYou = false;+ Assert.False(donut.IsMaterialYou);+ }+}