Skip to content

Commit 8b8cc65

Browse files
authored
Code: Optimized use of resource dictionaries (#10773)
1 parent 9ab8690 commit 8b8cc65

File tree

8 files changed

+39
-464
lines changed

8 files changed

+39
-464
lines changed

src/Files.App/App.xaml

+3-6
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
<SolidColorBrush x:Key="TabViewItemSeparator" Color="{StaticResource DividerStrokeColorDefault}" />
3232
<SolidColorBrush x:Key="TabContainerFillColorPrimary" Color="{StaticResource SolidBackgroundFillColorTertiary}" />
3333
<SolidColorBrush x:Key="TabContainerFillColorSecondary" Color="{StaticResource SolidBackgroundFillColorSecondary}" />
34-
<SolidColorBrush x:Key="NavigationToolbarBackgroundBrush" Color="{StaticResource LayerOnMicaBaseAltFillColorDefault}" />
35-
<SolidColorBrush x:Key="NavigationToolbarBreadcrumbBackgroundBrush" Color="Transparent" />
34+
<SolidColorBrush x:Key="AddressToolbarBackgroundBrush" Color="{StaticResource LayerOnMicaBaseAltFillColorDefault}" />
3635
<SolidColorBrush x:Key="FileBrowserHeaderBackgroundBrush" Color="Transparent" />
3736
<SolidColorBrush x:Key="RootBackgroundBrush" Color="Transparent" />
3837
<StaticResource x:Key="SidebarContentBackgroundBrush" ResourceKey="CardBackgroundFillColorDefault" />
@@ -47,8 +46,7 @@
4746
<SolidColorBrush x:Key="TabViewItemSeparator" Color="{StaticResource DividerStrokeColorDefault}" />
4847
<SolidColorBrush x:Key="TabContainerFillColorPrimary" Color="{StaticResource SolidBackgroundFillColorTertiary}" />
4948
<SolidColorBrush x:Key="TabContainerFillColorSecondary" Color="{StaticResource SolidBackgroundFillColorSecondary}" />
50-
<SolidColorBrush x:Key="NavigationToolbarBackgroundBrush" Color="{StaticResource LayerOnMicaBaseAltFillColorDefault}" />
51-
<SolidColorBrush x:Key="NavigationToolbarBreadcrumbBackgroundBrush" Color="Transparent" />
49+
<SolidColorBrush x:Key="AddressToolbarBackgroundBrush" Color="{StaticResource LayerOnMicaBaseAltFillColorDefault}" />
5250
<SolidColorBrush x:Key="FileBrowserHeaderBackgroundBrush" Color="Transparent" />
5351
<SolidColorBrush x:Key="RootBackgroundBrush" Color="Transparent" />
5452
<SolidColorBrush x:Key="SidebarContentBackgroundBrush" Color="#993A3A3A" />
@@ -63,8 +61,7 @@
6361
<SolidColorBrush x:Key="TabViewItemSeparator" Color="{StaticResource SystemColorGrayTextColor}" />
6462
<SolidColorBrush x:Key="TabContainerFillColorPrimary" Color="{StaticResource SolidBackgroundFillColorTertiary}" />
6563
<SolidColorBrush x:Key="TabContainerFillColorSecondary" Color="{StaticResource SolidBackgroundFillColorSecondary}" />
66-
<SolidColorBrush x:Key="NavigationToolbarBackgroundBrush" Color="Transparent" />
67-
<SolidColorBrush x:Key="NavigationToolbarBreadcrumbBackgroundBrush" Color="Transparent" />
64+
<SolidColorBrush x:Key="AddressToolbarBackgroundBrush" Color="Transparent" />
6865
<StaticResource x:Key="FileBrowserHeaderBackgroundBrush" ResourceKey="SolidBackgroundFillColorBaseBrush" />
6966
<SolidColorBrush x:Key="RootBackgroundBrush" Color="Transparent" />
7067
<StaticResource x:Key="SidebarContentBackgroundBrush" ResourceKey="CardBackgroundFillColorDefault" />

src/Files.App/ResourceDictionaries/ToolbarButtonStyle.xaml

-99
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,4 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
2-
<Style
3-
x:Key="ToolBarButtonStyle"
4-
BasedOn="{StaticResource DefaultButtonStyle}"
5-
TargetType="Button">
6-
<Setter Property="Background" Value="{ThemeResource ButtonBackground}" />
7-
<Setter Property="BackgroundSizing" Value="InnerBorderEdge" />
8-
<Setter Property="Foreground" Value="{ThemeResource ButtonForeground}" />
9-
<Setter Property="BorderBrush" Value="Transparent" />
10-
<Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}" />
11-
<Setter Property="Padding" Value="0" />
12-
<Setter Property="HorizontalAlignment" Value="Left" />
13-
<Setter Property="VerticalAlignment" Value="Center" />
14-
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
15-
<Setter Property="FontWeight" Value="Normal" />
16-
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
17-
<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" />
18-
<Setter Property="FocusVisualMargin" Value="-3" />
19-
<Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}" />
20-
<Setter Property="Template">
21-
<Setter.Value>
22-
<ControlTemplate TargetType="Button">
23-
<ContentPresenter
24-
x:Name="ContentPresenter"
25-
Padding="{TemplateBinding Padding}"
26-
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
27-
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
28-
AutomationProperties.AccessibilityView="Raw"
29-
Background="{TemplateBinding Background}"
30-
BackgroundSizing="{TemplateBinding BackgroundSizing}"
31-
BorderBrush="{TemplateBinding BorderBrush}"
32-
BorderThickness="{TemplateBinding BorderThickness}"
33-
Content="{TemplateBinding Content}"
34-
ContentTemplate="{TemplateBinding ContentTemplate}"
35-
ContentTransitions="{TemplateBinding ContentTransitions}"
36-
CornerRadius="{TemplateBinding CornerRadius}">
37-
<ContentPresenter.Resources>
38-
<ResourceDictionary>
39-
<ResourceDictionary.ThemeDictionaries>
40-
<ResourceDictionary x:Key="Default">
41-
<!-- Make border brushes always transparent -->
42-
<SolidColorBrush x:Key="ButtonBorderBrushDisabled" Color="Transparent" />
43-
<SolidColorBrush x:Key="ButtonBackgroundDisabled" Color="Transparent" />
44-
</ResourceDictionary>
45-
</ResourceDictionary.ThemeDictionaries>
46-
</ResourceDictionary>
47-
</ContentPresenter.Resources>
48-
49-
<VisualStateManager.VisualStateGroups>
50-
<VisualStateGroup x:Name="CommonStates">
51-
<VisualState x:Name="Normal" />
52-
53-
<VisualState x:Name="PointerOver">
54-
<Storyboard>
55-
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
56-
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBackgroundPointerOver}" />
57-
</ObjectAnimationUsingKeyFrames>
58-
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
59-
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBorderBrushPointerOver}" />
60-
</ObjectAnimationUsingKeyFrames>
61-
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
62-
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonForegroundPointerOver}" />
63-
</ObjectAnimationUsingKeyFrames>
64-
</Storyboard>
65-
</VisualState>
66-
67-
<VisualState x:Name="Pressed">
68-
<Storyboard>
69-
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
70-
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBackgroundPressed}" />
71-
</ObjectAnimationUsingKeyFrames>
72-
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
73-
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBorderBrushPressed}" />
74-
</ObjectAnimationUsingKeyFrames>
75-
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
76-
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonForegroundPressed}" />
77-
</ObjectAnimationUsingKeyFrames>
78-
</Storyboard>
79-
</VisualState>
80-
81-
<VisualState x:Name="Disabled">
82-
<Storyboard>
83-
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
84-
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBackgroundDisabled}" />
85-
</ObjectAnimationUsingKeyFrames>
86-
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
87-
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBorderBrushDisabled}" />
88-
</ObjectAnimationUsingKeyFrames>
89-
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
90-
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonForegroundDisabled}" />
91-
</ObjectAnimationUsingKeyFrames>
92-
</Storyboard>
93-
</VisualState>
94-
</VisualStateGroup>
95-
</VisualStateManager.VisualStateGroups>
96-
</ContentPresenter>
97-
</ControlTemplate>
98-
</Setter.Value>
99-
</Setter>
100-
</Style>
1012
<Style
1023
x:Key="ToolBarAppBarButtonFlyoutStyle"
1034
BasedOn="{StaticResource DefaultAppBarButtonStyle}"

0 commit comments

Comments
 (0)