Skip to content

Commit 528f3ea

Browse files
committed
chore: add avalonia TextBlock demo.
1 parent 1d181c8 commit 528f3ea

File tree

7 files changed

+236
-41
lines changed

7 files changed

+236
-41
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<UserControl xmlns="https://github.com/avaloniaui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:hc="https://handyorg.github.io/handycontrol"
4+
x:Class="HandyControlDemo.UserControl.TextBlockDemo"
5+
Background="{DynamicResource RegionBrush}">
6+
<ScrollViewer>
7+
<hc:UniformSpacingPanel Margin="32"
8+
Spacing="5"
9+
Orientation="Vertical">
10+
<TextBlock HorizontalAlignment="Left"
11+
Text="TextBlockLargeBold"
12+
Theme="{StaticResource TextBlockLargeBold}" />
13+
<TextBlock HorizontalAlignment="Left"
14+
Text="TextBlockLarge"
15+
Theme="{StaticResource TextBlockLarge}" />
16+
<TextBlock HorizontalAlignment="Left"
17+
Text="TextBlockHeaderBold"
18+
Theme="{StaticResource TextBlockTitleBold}" />
19+
<TextBlock HorizontalAlignment="Left"
20+
Text="TextBlockHeader"
21+
Theme="{StaticResource TextBlockTitle}" />
22+
<TextBlock HorizontalAlignment="Left"
23+
Text="TextBlockSubHeaderBold"
24+
Theme="{StaticResource TextBlockSubTitleBold}" />
25+
<TextBlock HorizontalAlignment="Left"
26+
Text="TextBlockSubHeader"
27+
Theme="{StaticResource TextBlockSubTitle}" />
28+
29+
<TextBlock HorizontalAlignment="Left"
30+
Text="TextBlockDefaultBold"
31+
Theme="{StaticResource TextBlockDefaultBold}" />
32+
<TextBlock HorizontalAlignment="Left"
33+
Text="TextBlockDefault"
34+
Theme="{StaticResource TextBlockDefault}" />
35+
<TextBlock HorizontalAlignment="Left"
36+
Text="TextBlockDefaultAccent"
37+
Theme="{StaticResource TextBlockDefaultAccent}" />
38+
<TextBlock HorizontalAlignment="Left"
39+
Text="TextBlockDefaultSecLight"
40+
Theme="{StaticResource TextBlockDefaultSecLight}" />
41+
<TextBlock HorizontalAlignment="Left"
42+
Text="TextBlockDefaultThiLight"
43+
Theme="{StaticResource TextBlockDefaultThiLight}" />
44+
<TextBlock HorizontalAlignment="Left"
45+
Text="TextBlockDefaultPrimary"
46+
Theme="{StaticResource TextBlockDefaultPrimary}" />
47+
<TextBlock HorizontalAlignment="Left"
48+
Text="TextBlockDefaultDanger"
49+
Theme="{StaticResource TextBlockDefaultDanger}" />
50+
<TextBlock HorizontalAlignment="Left"
51+
Text="TextBlockDefaultWarning"
52+
Theme="{StaticResource TextBlockDefaultWarning}" />
53+
<TextBlock HorizontalAlignment="Left"
54+
Text="TextBlockDefaultInfo"
55+
Theme="{StaticResource TextBlockDefaultInfo}" />
56+
<TextBlock HorizontalAlignment="Left"
57+
Text="TextBlockDefaultSuccess"
58+
Theme="{StaticResource TextBlockDefaultSuccess}" />
59+
</hc:UniformSpacingPanel>
60+
</ScrollViewer>
61+
</UserControl>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace HandyControlDemo.UserControl;
2+
3+
public partial class TextBlockDemo : Avalonia.Controls.UserControl
4+
{
5+
public TextBlockDemo()
6+
{
7+
InitializeComponent();
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<ResourceDictionary xmlns="https://github.com/avaloniaui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:system="using:System">
4+
<system:Double x:Key="LargeFontSize">24</system:Double>
5+
<system:Double x:Key="HeadFontSize">20</system:Double>
6+
<system:Double x:Key="SubHeadFontSize">16</system:Double>
7+
<system:Double x:Key="TextFontSize">12</system:Double>
8+
</ResourceDictionary>

src/Avalonia/HandyControl_Avalonia/Themes/Styles/Style.axaml

-37
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<ResourceDictionary xmlns="https://github.com/avaloniaui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
3+
<ControlTheme x:Key="TextBlockBaseStyle"
4+
TargetType="TextBlock">
5+
<Setter Property="VerticalAlignment"
6+
Value="Center" />
7+
<Setter Property="HorizontalAlignment"
8+
Value="Center" />
9+
<Setter Property="Foreground"
10+
Value="{DynamicResource PrimaryTextBrush}" />
11+
</ControlTheme>
12+
13+
<ControlTheme x:Key="TextBlockDefault"
14+
BasedOn="{StaticResource TextBlockBaseStyle}"
15+
TargetType="TextBlock" />
16+
17+
<ControlTheme x:Key="TextBlockDefaultAccent"
18+
BasedOn="{StaticResource TextBlockBaseStyle}"
19+
TargetType="TextBlock">
20+
<Setter Property="Foreground"
21+
Value="{DynamicResource AccentBrush}" />
22+
</ControlTheme>
23+
24+
<ControlTheme x:Key="TextBlockDefaultPrimary"
25+
BasedOn="{StaticResource TextBlockBaseStyle}"
26+
TargetType="TextBlock">
27+
<Setter Property="Foreground"
28+
Value="{DynamicResource PrimaryBrush}" />
29+
</ControlTheme>
30+
31+
<ControlTheme x:Key="TextBlockDefaultDanger"
32+
BasedOn="{StaticResource TextBlockBaseStyle}"
33+
TargetType="TextBlock">
34+
<Setter Property="Foreground"
35+
Value="{DynamicResource DangerBrush}" />
36+
</ControlTheme>
37+
38+
<ControlTheme x:Key="TextBlockDefaultWarning"
39+
BasedOn="{StaticResource TextBlockBaseStyle}"
40+
TargetType="TextBlock">
41+
<Setter Property="Foreground"
42+
Value="{DynamicResource WarningBrush}" />
43+
</ControlTheme>
44+
45+
<ControlTheme x:Key="TextBlockDefaultInfo"
46+
BasedOn="{StaticResource TextBlockBaseStyle}"
47+
TargetType="TextBlock">
48+
<Setter Property="Foreground"
49+
Value="{DynamicResource InfoBrush}" />
50+
</ControlTheme>
51+
52+
<ControlTheme x:Key="TextBlockDefaultSuccess"
53+
BasedOn="{StaticResource TextBlockBaseStyle}"
54+
TargetType="TextBlock">
55+
<Setter Property="Foreground"
56+
Value="{DynamicResource SuccessBrush}" />
57+
</ControlTheme>
58+
59+
<ControlTheme x:Key="TextBlockDefaultSecLight"
60+
BasedOn="{StaticResource TextBlockBaseStyle}"
61+
TargetType="TextBlock">
62+
<Setter Property="Foreground"
63+
Value="{DynamicResource SecondaryTextBrush}" />
64+
</ControlTheme>
65+
66+
<ControlTheme x:Key="TextBlockDefaultThiLight"
67+
BasedOn="{StaticResource TextBlockBaseStyle}"
68+
TargetType="TextBlock">
69+
<Setter Property="Foreground"
70+
Value="{DynamicResource ThirdlyTextBrush}" />
71+
</ControlTheme>
72+
73+
<ControlTheme x:Key="TextBlockLarge"
74+
BasedOn="{StaticResource TextBlockBaseStyle}"
75+
TargetType="TextBlock">
76+
<Setter Property="FontSize"
77+
Value="{StaticResource LargeFontSize}" />
78+
</ControlTheme>
79+
80+
<ControlTheme x:Key="TextBlockTitle"
81+
BasedOn="{StaticResource TextBlockBaseStyle}"
82+
TargetType="TextBlock">
83+
<Setter Property="FontSize"
84+
Value="{StaticResource HeadFontSize}" />
85+
</ControlTheme>
86+
87+
<ControlTheme x:Key="TextBlockSubTitle"
88+
BasedOn="{StaticResource TextBlockBaseStyle}"
89+
TargetType="TextBlock">
90+
<Setter Property="FontSize"
91+
Value="{StaticResource SubHeadFontSize}" />
92+
</ControlTheme>
93+
94+
<ControlTheme x:Key="TextBlockBoldBaseStyle"
95+
BasedOn="{StaticResource TextBlockBaseStyle}"
96+
TargetType="TextBlock">
97+
<Setter Property="FontWeight"
98+
Value="Bold" />
99+
</ControlTheme>
100+
101+
<ControlTheme x:Key="TextBlockLargeBold"
102+
BasedOn="{StaticResource TextBlockBoldBaseStyle}"
103+
TargetType="TextBlock">
104+
<Setter Property="FontSize"
105+
Value="{StaticResource LargeFontSize}" />
106+
</ControlTheme>
107+
108+
<ControlTheme x:Key="TextBlockTitleBold"
109+
BasedOn="{StaticResource TextBlockBoldBaseStyle}"
110+
TargetType="TextBlock">
111+
<Setter Property="FontSize"
112+
Value="{StaticResource HeadFontSize}" />
113+
</ControlTheme>
114+
115+
<ControlTheme x:Key="TextBlockSubTitleBold"
116+
BasedOn="{StaticResource TextBlockBoldBaseStyle}"
117+
TargetType="TextBlock">
118+
<Setter Property="FontSize"
119+
Value="{StaticResource SubHeadFontSize}" />
120+
</ControlTheme>
121+
122+
<ControlTheme x:Key="TextBlockDefaultBold"
123+
BasedOn="{StaticResource TextBlockBoldBaseStyle}"
124+
TargetType="TextBlock" />
125+
</ResourceDictionary>
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,44 @@
1-
<Styles xmlns="https://github.com/avaloniaui"
1+
<!-- ReSharper disable once Xaml.RedundantNamespaceAlias -->
2+
<Styles xmlns="https://github.com/avaloniaui"
23
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3-
x:Class="HandyControl.Themes.Theme">
4+
x:Class="HandyControl.Themes.Theme"
5+
xmlns:hc="clr-namespace:HandyControl.Controls">
46
<Styles.Resources>
57
<ResourceDictionary>
68
<ResourceDictionary.MergedDictionaries>
79
<MergeResourceInclude Source="/Themes/Basic/Colors.axaml" />
810
<MergeResourceInclude Source="/Themes/Basic/Sizes.axaml" />
11+
<MergeResourceInclude Source="/Themes/Basic/Fonts.axaml" />
912
<MergeResourceInclude Source="/Themes/Basic/Effects.axaml" />
13+
<MergeResourceInclude Source="/Themes/Basic/Geometries.axaml" />
14+
<MergeResourceInclude Source="/Themes/Basic/Paths.axaml" />
15+
<MergeResourceInclude Source="/Themes/Basic/Brushes.axaml" />
16+
<MergeResourceInclude Source="/Themes/Basic/Converters.axaml" />
17+
18+
<MergeResourceInclude Source="/Themes/Styles/TextBlock.axaml" />
19+
<MergeResourceInclude Source="/Themes/Styles/ContentControl.axaml" />
20+
<MergeResourceInclude Source="/Themes/Styles/UserControl.axaml" />
21+
<MergeResourceInclude Source="/Themes/Styles/Window.axaml" />
22+
<MergeResourceInclude Source="/Themes/Styles/Button.axaml" />
23+
<MergeResourceInclude Source="/Themes/Styles/RepeatButton.axaml" />
24+
<MergeResourceInclude Source="/Themes/Styles/ToggleButton.axaml" />
25+
<MergeResourceInclude Source="/Themes/Styles/RadioButton.axaml" />
26+
<MergeResourceInclude Source="/Themes/Styles/CheckBox.axaml" />
27+
<MergeResourceInclude Source="/Themes/Styles/Border.axaml" />
28+
<MergeResourceInclude Source="/Themes/Styles/ItemsControl.axaml" />
29+
<MergeResourceInclude Source="/Themes/Styles/TabItem.axaml" />
30+
<MergeResourceInclude Source="/Themes/Styles/TabControl.axaml" />
31+
<MergeResourceInclude Source="/Themes/Styles/ListBoxItem.axaml" />
32+
<MergeResourceInclude Source="/Themes/Styles/ScrollViewer.axaml" />
33+
<MergeResourceInclude Source="/Themes/Styles/ListBox.axaml" />
34+
<MergeResourceInclude Source="/Themes/Styles/Label.axaml" />
35+
<MergeResourceInclude Source="/Themes/Styles/Slider.axaml" />
1036
</ResourceDictionary.MergedDictionaries>
1137
</ResourceDictionary>
1238
</Styles.Resources>
1339

14-
<StyleInclude Source="/Themes/Styles/Style.axaml" />
40+
<Style Selector=":is(UserControl)">
41+
<Setter Property="Theme"
42+
Value="{DynamicResource {x:Type UserControl}}" />
43+
</Style>
1544
</Styles>

src/Shared/HandyControl_Shared/Themes/Basic/Fonts.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
<system:Double x:Key="SubHeadFontSize">16</system:Double>
88
<system:Double x:Key="TextFontSize">12</system:Double>
99

10-
</ResourceDictionary>
10+
</ResourceDictionary>

0 commit comments

Comments
 (0)