feat: extract shared resources.

This commit is contained in:
Zhang Dian
2024-06-28 16:46:06 +08:00
parent 52845ebae8
commit df7a6f188c
2 changed files with 49 additions and 22 deletions

View File

@@ -7,12 +7,12 @@
<ControlTheme x:Key="{x:Type u:Avatar}" TargetType="{x:Type u:Avatar}">
<Setter Property="Foreground" Value="{DynamicResource AvatarForeground}" />
<Setter Property="Background" Value="{DynamicResource AvatarGreyBackground}" />
<Setter Property="FontSize" Value="20" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="Width" Value="48" />
<Setter Property="FontSize" Value="{DynamicResource AvatarMediumFontSize}" />
<Setter Property="FontWeight" Value="{DynamicResource AvatarFontWeight}" />
<Setter Property="Width" Value="{DynamicResource AvatarMediumWidth}" />
<Setter Property="Height" Value="{Binding $self.Width}" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="CornerRadius" Value="100" />
<Setter Property="CornerRadius" Value="{DynamicResource AvatarCircleCornerRadius}" />
<Setter Property="Template">
<ControlTemplate TargetType="{x:Type u:Avatar}">
<Border
@@ -99,41 +99,41 @@
</Style>
<Style Selector="^.Square">
<Setter Property="CornerRadius" Value="3" />
<Setter Property="CornerRadius" Value="{DynamicResource AvatarSquareCornerRadius}" />
</Style>
<Style Selector="^.ExtraExtraSmall">
<Setter Property="Width" Value="20" />
<Setter Property="FontSize" Value="10" />
<Setter Property="Width" Value="{DynamicResource AvatarExtraExtraSmallWidth}" />
<Setter Property="FontSize" Value="{DynamicResource AvatarExtraExtraSmallFontSize}" />
</Style>
<Style Selector="^.ExtraSmall">
<Setter Property="Width" Value="24" />
<Setter Property="FontSize" Value="10" />
<Setter Property="Width" Value="{DynamicResource AvatarExtraSmallWidth}" />
<Setter Property="FontSize" Value="{DynamicResource AvatarExtraSmallFontSize}" />
</Style>
<Style Selector="^.Small">
<Setter Property="Width" Value="32" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Width" Value="{DynamicResource AvatarSmallWidth}" />
<Setter Property="FontSize" Value="{DynamicResource AvatarSmallFontSize}" />
</Style>
<Style Selector="^.Default">
<Setter Property="Width" Value="40" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Width" Value="{DynamicResource AvatarDefaultWidth}" />
<Setter Property="FontSize" Value="{DynamicResource AvatarDefaultFontSize}" />
</Style>
<Style Selector="^.Medium">
<Setter Property="Width" Value="48" />
<Setter Property="FontSize" Value="20" />
<Setter Property="Width" Value="{DynamicResource AvatarMediumWidth}" />
<Setter Property="FontSize" Value="{DynamicResource AvatarMediumFontSize}" />
</Style>
<Style Selector="^.Large">
<Setter Property="Width" Value="72" />
<Setter Property="FontSize" Value="32" />
<Setter Property="Width" Value="{DynamicResource AvatarLargeWidth}" />
<Setter Property="FontSize" Value="{DynamicResource AvatarLargeFontSize}" />
<Style Selector="^.Square">
<Setter Property="CornerRadius" Value="6" />
<Setter Property="CornerRadius" Value="{DynamicResource AvatarLargeSquareCornerRadius}" />
</Style>
</Style>
<Style Selector="^.ExtraLarge">
<Setter Property="Width" Value="128" />
<Setter Property="FontSize" Value="64" />
<Setter Property="Width" Value="{DynamicResource AvatarExtraLargeWidth}" />
<Setter Property="FontSize" Value="{DynamicResource AvatarExtraLargeFontSize}" />
<Style Selector="^.Square">
<Setter Property="CornerRadius" Value="12" />
<Setter Property="CornerRadius" Value="{DynamicResource AvatarExtraLargeSquareCornerRadius}" />
</Style>
</Style>
</ControlTheme>

View File

@@ -1,2 +1,29 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</ResourceDictionary>
<FontWeight x:Key="AvatarFontWeight">600</FontWeight>
<CornerRadius x:Key="AvatarCircleCornerRadius">100</CornerRadius>
<CornerRadius x:Key="AvatarSquareCornerRadius">3</CornerRadius>
<x:Double x:Key="AvatarExtraExtraSmallWidth">20</x:Double>
<x:Double x:Key="AvatarExtraExtraSmallFontSize">10</x:Double>
<x:Double x:Key="AvatarExtraSmallWidth">24</x:Double>
<x:Double x:Key="AvatarExtraSmallFontSize">10</x:Double>
<x:Double x:Key="AvatarSmallWidth">32</x:Double>
<x:Double x:Key="AvatarSmallFontSize">12</x:Double>
<x:Double x:Key="AvatarDefaultWidth">40</x:Double>
<x:Double x:Key="AvatarDefaultFontSize">18</x:Double>
<x:Double x:Key="AvatarMediumWidth">48</x:Double>
<x:Double x:Key="AvatarMediumFontSize">20</x:Double>
<x:Double x:Key="AvatarLargeWidth">72</x:Double>
<x:Double x:Key="AvatarLargeFontSize">32</x:Double>
<CornerRadius x:Key="AvatarLargeSquareCornerRadius">6</CornerRadius>
<x:Double x:Key="AvatarExtraLargeWidth">128</x:Double>
<x:Double x:Key="AvatarExtraLargeFontSize">64</x:Double>
<CornerRadius x:Key="AvatarExtraLargeSquareCornerRadius">12</CornerRadius>
</ResourceDictionary>