diff --git a/src/Filee.App/Services/ThemeService.cs b/src/Filee.App/Services/ThemeService.cs index 604475a3..55fc9399 100644 --- a/src/Filee.App/Services/ThemeService.cs +++ b/src/Filee.App/Services/ThemeService.cs @@ -171,6 +171,11 @@ private static void ApplyCustomOverrides(IResourceDictionary dictionary, IReadOn foreach (var (name, value) in colors ?? new Dictionary()) if (CustomBrushKeys.TryGetValue(name, out var key) && Color.TryParse(value, out var color)) dictionary[key] = new SolidColorBrush(color); + // Plain buttons are the surface they sit on (#524): also under Material You and a theme.json's own surface. + if (dictionary.TryGetValue("SurfaceBrush", out var surface)) + dictionary["ButtonBackground"] = surface; + if (dictionary.TryGetValue("SurfaceAltBrush", out var surfaceAlt)) + dictionary["ButtonBackgroundPointerOver"] = surfaceAlt; } /// Replaces (or, with no colours, removes) the user's colours for one variant. diff --git a/src/Filee.App/Styles/Soft.axaml b/src/Filee.App/Styles/Soft.axaml index 5a6269dd..d6b28b2c 100644 --- a/src/Filee.App/Styles/Soft.axaml +++ b/src/Filee.App/Styles/Soft.axaml @@ -27,6 +27,15 @@ + + + + + + + + @@ -44,6 +53,12 @@ + + + + + + diff --git a/tests/Filee.App.Tests/MaterialYouThemeTests.cs b/tests/Filee.App.Tests/MaterialYouThemeTests.cs index 75a75c93..22aba023 100644 --- a/tests/Filee.App.Tests/MaterialYouThemeTests.cs +++ b/tests/Filee.App.Tests/MaterialYouThemeTests.cs @@ -198,6 +198,35 @@ public void ThemeService_respects_custom_theme_json_overrides() var darkSurface = Assert.IsType(darkDict["SurfaceBrush"]); Assert.Equal(Color.Parse("#654321"), darkSurface.Color); + + // Plain buttons follow the theme's surface (#524), not the Soft look's white. + Assert.Same(lightSurface, lightDict["ButtonBackground"]); + Assert.Same(darkSurface, darkDict["ButtonBackground"]); + Assert.Same(lightDict["SurfaceAltBrush"], lightDict["ButtonBackgroundPointerOver"]); + } + finally + { + themeService.Apply(new ThemeSettings(), "en"); + } + } + + [AvaloniaFact] + public void Plain_buttons_are_the_surface_with_a_border_unlike_a_disabled_box() + { + TestServices.EnsureInitialized("en"); + var themeService = AppHost.Get(); + try + { + foreach (var style in new[] { ThemeStyle.Soft, ThemeStyle.MaterialYou }) + { + themeService.Apply(new ThemeSettings { Style = style }, "en"); + foreach (var variant in new[] { ThemeVariant.Light, ThemeVariant.Dark }) + { + Assert.Equal(ResolveBrush("SurfaceBrush", variant).Color, ResolveBrush("ButtonBackground", variant).Color); + Assert.Equal(ResolveBrush("SurfaceAltBrush", variant).Color, ResolveBrush("ButtonBackgroundPointerOver", variant).Color); + Assert.True(ResolveBrush("ButtonBorderBrush", variant).Color.A > 0); + } + } } finally {