diff --git a/samples/ControlCatalog/Assets/Icon.png b/samples/ControlCatalog/Assets/Icon.png index 41a2a618fb..4e60afcc59 100644 Binary files a/samples/ControlCatalog/Assets/Icon.png and b/samples/ControlCatalog/Assets/Icon.png differ diff --git a/src/Avalonia.Themes.Fluent2/Accents/BaseResources.xaml b/src/Avalonia.Themes.Fluent2/Accents/BaseResources.xaml index efdb72dba6..a4e249de82 100644 --- a/src/Avalonia.Themes.Fluent2/Accents/BaseResources.xaml +++ b/src/Avalonia.Themes.Fluent2/Accents/BaseResources.xaml @@ -99,8 +99,8 @@ Color="{StaticResource SystemChromeMediumLowColor}" /> - - + + @@ -260,8 +260,8 @@ Color="{StaticResource SystemChromeMediumLowColor}" /> - - + + diff --git a/src/Avalonia.Themes.Fluent2/Controls/DrawerPage.xaml b/src/Avalonia.Themes.Fluent2/Controls/DrawerPage.xaml index 26d991de24..06fe9303b1 100644 --- a/src/Avalonia.Themes.Fluent2/Controls/DrawerPage.xaml +++ b/src/Avalonia.Themes.Fluent2/Controls/DrawerPage.xaml @@ -10,41 +10,140 @@ + + + M3 17h18a1 1 0 0 1 .117 1.993L21 19H3a1 1 0 0 1-.117-1.993L3 17h18H3Zm0-6 18-.002a1 1 0 0 1 .117 1.993l-.117.007L3 13a1 1 0 0 1-.117-1.993L3 11l18-.002L3 11Zm0-6h18a1 1 0 0 1 .117 1.993L21 7H3a1 1 0 0 1-.117-1.993L3 5h18H3Z + 48 - + + + + 40 + 36 + 4,2 + 0,4 + 1,1,0,0 + 8,0,0,0 + 0,1,0,0 + 0 + 0,1,0,0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + - - + + - - + + + - - - - - @@ -106,6 +195,8 @@ - - - - - @@ -157,6 +236,8 @@ + + + + + + + + + + + + + + + + + @@ -210,7 +333,10 @@ - + + @@ -218,7 +344,7 @@ - + @@ -226,39 +352,29 @@ + - - - - - - - - - - - - + diff --git a/src/Avalonia.Themes.Fluent2/Controls/NavigationPage.xaml b/src/Avalonia.Themes.Fluent2/Controls/NavigationPage.xaml index 2eb606d4da..2e0072aea5 100644 --- a/src/Avalonia.Themes.Fluent2/Controls/NavigationPage.xaml +++ b/src/Avalonia.Themes.Fluent2/Controls/NavigationPage.xaml @@ -1,5 +1,15 @@ + + + + + + + + + + @@ -10,8 +20,6 @@ M12.7347,4.20949 C13.0332,3.92233 13.508,3.93153 13.7952,4.23005 C14.0823,4.52857 14.0731,5.00335 13.7746,5.29051 L5.50039,13.25 L24.2532,13.25 C24.6674,13.25 25.0032,13.5858 25.0032,13.9999982 C25.0032,14.4142 24.6674,14.75 24.2532,14.75 L5.50137,14.75 L13.7746,22.7085 C14.0731,22.9957 14.0823,23.4705 13.7952,23.769 C13.508,24.0675 13.0332,24.0767 12.7347,23.7896 L3.30673,14.7202 C2.89776,14.3268 2.89776,13.6723 3.30673,13.2788 L12.7347,4.20949 Z - - diff --git a/src/Avalonia.Themes.Fluent2/Controls/TabbedPage.xaml b/src/Avalonia.Themes.Fluent2/Controls/TabbedPage.xaml index 23e46f4c06..b92731dd3b 100644 --- a/src/Avalonia.Themes.Fluent2/Controls/TabbedPage.xaml +++ b/src/Avalonia.Themes.Fluent2/Controls/TabbedPage.xaml @@ -1,5 +1,25 @@ + + + + + + + + + + + + + + + + + + + + @@ -19,16 +39,11 @@ - - - - - 3 18 @@ -48,10 +63,8 @@ - 0 0,1,0,0 - 0 0 diff --git a/tests/Avalonia.Themes.Fluent2.UnitTests/KeyParityTests.cs b/tests/Avalonia.Themes.Fluent2.UnitTests/KeyParityTests.cs index 4b3576d121..55ee6d8c5f 100644 --- a/tests/Avalonia.Themes.Fluent2.UnitTests/KeyParityTests.cs +++ b/tests/Avalonia.Themes.Fluent2.UnitTests/KeyParityTests.cs @@ -112,6 +112,59 @@ public class KeyParityTests "Compact density keys missing in Fluent2: " + string.Join(", ", missing)); } + [AvaloniaFact] + public void Window_scoped_dark_variant_resolves_same_values_as_theme_dark() + { + // Regression guard: brushes defined outside ThemeDictionaries that wrap + // variant-scoped colors anchor to the app variant instead of the consumer's + // scope. Every key must resolve identically whether dark is requested at + // theme level or via a window-scoped RequestedThemeVariant override. + var theme = new Fluent2Theme(); + var app = Application.Current!; + app.Styles.Add(theme); + var window = new Window + { + RequestedThemeVariant = ThemeVariant.Dark, + Content = new ContentControl(), + }; + window.Show(); + try + { + var control = (ContentControl)window.Content!; + var problems = new List(); + foreach (var key in ThemeResourceWalker.CollectKeys(theme)) + { + if (!((IResourceNode)theme).TryGetResource(key, ThemeVariant.Dark, out var expected)) + continue; + if (expected is not (IBrush or Color)) + continue; + control.TryFindResource(key, control.ActualThemeVariant, out var actual); + var expectedText = Describe(expected); + var actualText = Describe(actual); + if (expectedText != actualText) + problems.Add($"{key}: theme-dark={expectedText} window-dark={actualText}"); + } + + Assert.True(problems.Count == 0, + $"{problems.Count} keys resolve differently under window-scoped dark:\n" + + string.Join("\n", problems.Take(30))); + } + finally + { + window.Close(); + app.Styles.Remove(theme); + } + } + + private static string Describe(object? value) => value switch + { + ISolidColorBrush b => $"solid:{b.Color}", + Color c => $"color:{c}", + IBrush b => $"{b.GetType().Name}:{b.GetHashCode()}", + null => "null", + _ => value.GetType().Name, + }; + private static ResourceDictionary GetCompactStyles(object theme) { // Both themes stash the keyed CompactStyles dictionary in a private field;