Skip to content

Commit 72c3faf

Browse files
authored
Code Qaulity: Improved the code quality of NavigationToolbar.xaml (#16986)
1 parent 6cee330 commit 72c3faf

File tree

5 files changed

+587
-567
lines changed

5 files changed

+587
-567
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
<!-- Copyright (c) Files Community. Licensed under the MIT License. -->
2+
<ResourceDictionary
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:converters="using:Files.App.Converters"
6+
xmlns:wctconverters="using:CommunityToolkit.WinUI.Converters">
7+
8+
<Style x:Key="DefaultInfoBadgeStyle" TargetType="InfoBadge">
9+
<Setter Property="MinHeight" Value="{ThemeResource InfoBadgeMinHeight}" />
10+
<Setter Property="MinWidth" Value="{ThemeResource InfoBadgeMinWidth}" />
11+
<Setter Property="MaxHeight" Value="{ThemeResource InfoBadgeMaxHeight}" />
12+
<Setter Property="Background" Value="{ThemeResource InfoBadgeBackground}" />
13+
<Setter Property="Foreground" Value="{ThemeResource InfoBadgeForeground}" />
14+
<Setter Property="Padding" Value="{ThemeResource InfoBadgePadding}" />
15+
<Setter Property="IsTabStop" Value="False" />
16+
<Setter Property="Template">
17+
<Setter.Value>
18+
<ControlTemplate TargetType="InfoBadge">
19+
<Grid
20+
x:Name="RootGrid"
21+
Padding="{TemplateBinding Padding}"
22+
Background="{TemplateBinding Background}"
23+
CornerRadius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.InfoBadgeCornerRadius}">
24+
<TextBlock
25+
x:Name="ValueTextBlock"
26+
HorizontalAlignment="Center"
27+
VerticalAlignment="Center"
28+
FontSize="{ThemeResource InfoBadgeValueFontSize}"
29+
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value, Mode=OneWay}"
30+
Visibility="Collapsed" />
31+
<Viewbox
32+
x:Name="IconPresenter"
33+
HorizontalAlignment="Center"
34+
VerticalAlignment="Stretch"
35+
Visibility="Collapsed">
36+
<IconSourceElement IconSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IconSource, Mode=OneWay}" />
37+
</Viewbox>
38+
<VisualStateManager.VisualStateGroups>
39+
<VisualStateGroup x:Name="DisplayKindStates">
40+
<VisualState x:Name="Dot" />
41+
<VisualState x:Name="Icon">
42+
<VisualState.Setters>
43+
<Setter Target="IconPresenter.Visibility" Value="Visible" />
44+
<Setter Target="IconPresenter.Margin" Value="{ThemeResource IconInfoBadgeIconMargin}" />
45+
</VisualState.Setters>
46+
</VisualState>
47+
<VisualState x:Name="FontIcon">
48+
<VisualState.Setters>
49+
<Setter Target="IconPresenter.Visibility" Value="Visible" />
50+
<Setter Target="IconPresenter.Margin" Value="{ThemeResource IconInfoBadgeFontIconMargin}" />
51+
</VisualState.Setters>
52+
</VisualState>
53+
<VisualState x:Name="Value">
54+
<VisualState.Setters>
55+
<Setter Target="ValueTextBlock.Visibility" Value="Visible" />
56+
<Setter Target="ValueTextBlock.Margin" Value="{ThemeResource ValueInfoBadgeTextMargin}" />
57+
</VisualState.Setters>
58+
</VisualState>
59+
</VisualStateGroup>
60+
</VisualStateManager.VisualStateGroups>
61+
</Grid>
62+
</ControlTemplate>
63+
</Setter.Value>
64+
</Setter>
65+
</Style>
66+
67+
<Style
68+
x:Key="AttentionDotInfoBadgeStyle"
69+
BasedOn="{StaticResource DefaultInfoBadgeStyle}"
70+
TargetType="InfoBadge">
71+
<Setter Property="Background" Value="{ThemeResource SystemFillColorAttentionBrush}" />
72+
</Style>
73+
74+
<Style
75+
x:Key="AttentionValueInfoBadgeStyle"
76+
BasedOn="{StaticResource AttentionDotInfoBadgeStyle}"
77+
TargetType="InfoBadge" />
78+
79+
<Style
80+
x:Key="AttentionIconInfoBadgeStyle"
81+
BasedOn="{StaticResource AttentionDotInfoBadgeStyle}"
82+
TargetType="InfoBadge">
83+
<Setter Property="Padding" Value="0,4,0,2" />
84+
<Setter Property="IconSource">
85+
<Setter.Value>
86+
<FontIconSource Glyph="&#xEA38;" />
87+
</Setter.Value>
88+
</Setter>
89+
</Style>
90+
91+
<Style
92+
x:Key="InformationalDotInfoBadgeStyle"
93+
BasedOn="{StaticResource DefaultInfoBadgeStyle}"
94+
TargetType="InfoBadge">
95+
<Setter Property="Background" Value="{ThemeResource SystemFillColorSolidNeutralBrush}" />
96+
</Style>
97+
98+
<Style
99+
x:Key="InformationalValueInfoBadgeStyle"
100+
BasedOn="{StaticResource InformationalDotInfoBadgeStyle}"
101+
TargetType="InfoBadge" />
102+
103+
<Style
104+
x:Key="InformationalIconInfoBadgeStyle"
105+
BasedOn="{StaticResource InformationalDotInfoBadgeStyle}"
106+
TargetType="InfoBadge">
107+
<Setter Property="Padding" Value="0,4,0,2" />
108+
<Setter Property="IconSource">
109+
<Setter.Value>
110+
<FontIconSource Glyph="&#xF13F;" />
111+
</Setter.Value>
112+
</Setter>
113+
</Style>
114+
115+
<Style
116+
x:Key="SuccessDotInfoBadgeStyle"
117+
BasedOn="{StaticResource DefaultInfoBadgeStyle}"
118+
TargetType="InfoBadge">
119+
<Setter Property="Background" Value="{ThemeResource SystemFillColorSuccessBrush}" />
120+
</Style>
121+
122+
<Style
123+
x:Key="SuccessValueInfoBadgeStyle"
124+
BasedOn="{StaticResource SuccessDotInfoBadgeStyle}"
125+
TargetType="InfoBadge" />
126+
127+
<Style
128+
x:Key="SuccessIconInfoBadgeStyle"
129+
BasedOn="{StaticResource SuccessDotInfoBadgeStyle}"
130+
TargetType="InfoBadge">
131+
<Setter Property="IconSource">
132+
<Setter.Value>
133+
<SymbolIconSource Symbol="Accept" />
134+
</Setter.Value>
135+
</Setter>
136+
</Style>
137+
138+
<Style
139+
x:Key="CautionDotInfoBadgeStyle"
140+
BasedOn="{StaticResource DefaultInfoBadgeStyle}"
141+
TargetType="InfoBadge">
142+
<Setter Property="Background" Value="{ThemeResource SystemFillColorCautionBrush}" />
143+
</Style>
144+
145+
<Style
146+
x:Key="CautionValueInfoBadgeStyle"
147+
BasedOn="{StaticResource CautionDotInfoBadgeStyle}"
148+
TargetType="InfoBadge" />
149+
150+
<Style
151+
x:Key="CautionIconInfoBadgeStyle"
152+
BasedOn="{StaticResource CautionDotInfoBadgeStyle}"
153+
TargetType="InfoBadge">
154+
<Setter Property="IconSource">
155+
<Setter.Value>
156+
<SymbolIconSource Symbol="Important" />
157+
</Setter.Value>
158+
</Setter>
159+
</Style>
160+
161+
<Style
162+
x:Key="CriticalDotInfoBadgeStyle"
163+
BasedOn="{StaticResource DefaultInfoBadgeStyle}"
164+
TargetType="InfoBadge">
165+
<Setter Property="Background" Value="{ThemeResource SystemFillColorCriticalBrush}" />
166+
</Style>
167+
168+
<Style
169+
x:Key="CriticalValueInfoBadgeStyle"
170+
BasedOn="{StaticResource CriticalDotInfoBadgeStyle}"
171+
TargetType="InfoBadge" />
172+
173+
<Style
174+
x:Key="CriticalIconInfoBadgeStyle"
175+
BasedOn="{StaticResource CriticalDotInfoBadgeStyle}"
176+
TargetType="InfoBadge">
177+
<Setter Property="IconSource">
178+
<Setter.Value>
179+
<SymbolIconSource Symbol="Cancel" />
180+
</Setter.Value>
181+
</Setter>
182+
</Style>
183+
184+
</ResourceDictionary>

0 commit comments

Comments
 (0)