Skip to content

Commit

Permalink
chore: add avalonia TextBlock demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
NaBian committed Dec 15, 2024
1 parent 1d181c8 commit 528f3ea
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
x:Class="HandyControlDemo.UserControl.TextBlockDemo"
Background="{DynamicResource RegionBrush}">
<ScrollViewer>
<hc:UniformSpacingPanel Margin="32"
Spacing="5"
Orientation="Vertical">
<TextBlock HorizontalAlignment="Left"
Text="TextBlockLargeBold"
Theme="{StaticResource TextBlockLargeBold}" />
<TextBlock HorizontalAlignment="Left"
Text="TextBlockLarge"
Theme="{StaticResource TextBlockLarge}" />
<TextBlock HorizontalAlignment="Left"
Text="TextBlockHeaderBold"
Theme="{StaticResource TextBlockTitleBold}" />
<TextBlock HorizontalAlignment="Left"
Text="TextBlockHeader"
Theme="{StaticResource TextBlockTitle}" />
<TextBlock HorizontalAlignment="Left"
Text="TextBlockSubHeaderBold"
Theme="{StaticResource TextBlockSubTitleBold}" />
<TextBlock HorizontalAlignment="Left"
Text="TextBlockSubHeader"
Theme="{StaticResource TextBlockSubTitle}" />

<TextBlock HorizontalAlignment="Left"
Text="TextBlockDefaultBold"
Theme="{StaticResource TextBlockDefaultBold}" />
<TextBlock HorizontalAlignment="Left"
Text="TextBlockDefault"
Theme="{StaticResource TextBlockDefault}" />
<TextBlock HorizontalAlignment="Left"
Text="TextBlockDefaultAccent"
Theme="{StaticResource TextBlockDefaultAccent}" />
<TextBlock HorizontalAlignment="Left"
Text="TextBlockDefaultSecLight"
Theme="{StaticResource TextBlockDefaultSecLight}" />
<TextBlock HorizontalAlignment="Left"
Text="TextBlockDefaultThiLight"
Theme="{StaticResource TextBlockDefaultThiLight}" />
<TextBlock HorizontalAlignment="Left"
Text="TextBlockDefaultPrimary"
Theme="{StaticResource TextBlockDefaultPrimary}" />
<TextBlock HorizontalAlignment="Left"
Text="TextBlockDefaultDanger"
Theme="{StaticResource TextBlockDefaultDanger}" />
<TextBlock HorizontalAlignment="Left"
Text="TextBlockDefaultWarning"
Theme="{StaticResource TextBlockDefaultWarning}" />
<TextBlock HorizontalAlignment="Left"
Text="TextBlockDefaultInfo"
Theme="{StaticResource TextBlockDefaultInfo}" />
<TextBlock HorizontalAlignment="Left"
Text="TextBlockDefaultSuccess"
Theme="{StaticResource TextBlockDefaultSuccess}" />
</hc:UniformSpacingPanel>
</ScrollViewer>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace HandyControlDemo.UserControl;

public partial class TextBlockDemo : Avalonia.Controls.UserControl
{
public TextBlockDemo()
{
InitializeComponent();
}
}
8 changes: 8 additions & 0 deletions src/Avalonia/HandyControl_Avalonia/Themes/Basic/Fonts.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="using:System">
<system:Double x:Key="LargeFontSize">24</system:Double>
<system:Double x:Key="HeadFontSize">20</system:Double>
<system:Double x:Key="SubHeadFontSize">16</system:Double>
<system:Double x:Key="TextFontSize">12</system:Double>
</ResourceDictionary>
37 changes: 0 additions & 37 deletions src/Avalonia/HandyControl_Avalonia/Themes/Styles/Style.axaml

This file was deleted.

125 changes: 125 additions & 0 deletions src/Avalonia/HandyControl_Avalonia/Themes/Styles/TextBlock.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTheme x:Key="TextBlockBaseStyle"
TargetType="TextBlock">
<Setter Property="VerticalAlignment"
Value="Center" />
<Setter Property="HorizontalAlignment"
Value="Center" />
<Setter Property="Foreground"
Value="{DynamicResource PrimaryTextBrush}" />
</ControlTheme>

<ControlTheme x:Key="TextBlockDefault"
BasedOn="{StaticResource TextBlockBaseStyle}"
TargetType="TextBlock" />

<ControlTheme x:Key="TextBlockDefaultAccent"
BasedOn="{StaticResource TextBlockBaseStyle}"
TargetType="TextBlock">
<Setter Property="Foreground"
Value="{DynamicResource AccentBrush}" />
</ControlTheme>

<ControlTheme x:Key="TextBlockDefaultPrimary"
BasedOn="{StaticResource TextBlockBaseStyle}"
TargetType="TextBlock">
<Setter Property="Foreground"
Value="{DynamicResource PrimaryBrush}" />
</ControlTheme>

<ControlTheme x:Key="TextBlockDefaultDanger"
BasedOn="{StaticResource TextBlockBaseStyle}"
TargetType="TextBlock">
<Setter Property="Foreground"
Value="{DynamicResource DangerBrush}" />
</ControlTheme>

<ControlTheme x:Key="TextBlockDefaultWarning"
BasedOn="{StaticResource TextBlockBaseStyle}"
TargetType="TextBlock">
<Setter Property="Foreground"
Value="{DynamicResource WarningBrush}" />
</ControlTheme>

<ControlTheme x:Key="TextBlockDefaultInfo"
BasedOn="{StaticResource TextBlockBaseStyle}"
TargetType="TextBlock">
<Setter Property="Foreground"
Value="{DynamicResource InfoBrush}" />
</ControlTheme>

<ControlTheme x:Key="TextBlockDefaultSuccess"
BasedOn="{StaticResource TextBlockBaseStyle}"
TargetType="TextBlock">
<Setter Property="Foreground"
Value="{DynamicResource SuccessBrush}" />
</ControlTheme>

<ControlTheme x:Key="TextBlockDefaultSecLight"
BasedOn="{StaticResource TextBlockBaseStyle}"
TargetType="TextBlock">
<Setter Property="Foreground"
Value="{DynamicResource SecondaryTextBrush}" />
</ControlTheme>

<ControlTheme x:Key="TextBlockDefaultThiLight"
BasedOn="{StaticResource TextBlockBaseStyle}"
TargetType="TextBlock">
<Setter Property="Foreground"
Value="{DynamicResource ThirdlyTextBrush}" />
</ControlTheme>

<ControlTheme x:Key="TextBlockLarge"
BasedOn="{StaticResource TextBlockBaseStyle}"
TargetType="TextBlock">
<Setter Property="FontSize"
Value="{StaticResource LargeFontSize}" />
</ControlTheme>

<ControlTheme x:Key="TextBlockTitle"
BasedOn="{StaticResource TextBlockBaseStyle}"
TargetType="TextBlock">
<Setter Property="FontSize"
Value="{StaticResource HeadFontSize}" />
</ControlTheme>

<ControlTheme x:Key="TextBlockSubTitle"
BasedOn="{StaticResource TextBlockBaseStyle}"
TargetType="TextBlock">
<Setter Property="FontSize"
Value="{StaticResource SubHeadFontSize}" />
</ControlTheme>

<ControlTheme x:Key="TextBlockBoldBaseStyle"
BasedOn="{StaticResource TextBlockBaseStyle}"
TargetType="TextBlock">
<Setter Property="FontWeight"
Value="Bold" />
</ControlTheme>

<ControlTheme x:Key="TextBlockLargeBold"
BasedOn="{StaticResource TextBlockBoldBaseStyle}"
TargetType="TextBlock">
<Setter Property="FontSize"
Value="{StaticResource LargeFontSize}" />
</ControlTheme>

<ControlTheme x:Key="TextBlockTitleBold"
BasedOn="{StaticResource TextBlockBoldBaseStyle}"
TargetType="TextBlock">
<Setter Property="FontSize"
Value="{StaticResource HeadFontSize}" />
</ControlTheme>

<ControlTheme x:Key="TextBlockSubTitleBold"
BasedOn="{StaticResource TextBlockBoldBaseStyle}"
TargetType="TextBlock">
<Setter Property="FontSize"
Value="{StaticResource SubHeadFontSize}" />
</ControlTheme>

<ControlTheme x:Key="TextBlockDefaultBold"
BasedOn="{StaticResource TextBlockBoldBaseStyle}"
TargetType="TextBlock" />
</ResourceDictionary>
35 changes: 32 additions & 3 deletions src/Avalonia/HandyControl_Avalonia/Themes/Theme.axaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,44 @@
<Styles xmlns="https://github.com/avaloniaui"
<!-- ReSharper disable once Xaml.RedundantNamespaceAlias -->
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="HandyControl.Themes.Theme">
x:Class="HandyControl.Themes.Theme"
xmlns:hc="clr-namespace:HandyControl.Controls">
<Styles.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<MergeResourceInclude Source="/Themes/Basic/Colors.axaml" />
<MergeResourceInclude Source="/Themes/Basic/Sizes.axaml" />
<MergeResourceInclude Source="/Themes/Basic/Fonts.axaml" />
<MergeResourceInclude Source="/Themes/Basic/Effects.axaml" />
<MergeResourceInclude Source="/Themes/Basic/Geometries.axaml" />
<MergeResourceInclude Source="/Themes/Basic/Paths.axaml" />
<MergeResourceInclude Source="/Themes/Basic/Brushes.axaml" />
<MergeResourceInclude Source="/Themes/Basic/Converters.axaml" />

<MergeResourceInclude Source="/Themes/Styles/TextBlock.axaml" />
<MergeResourceInclude Source="/Themes/Styles/ContentControl.axaml" />
<MergeResourceInclude Source="/Themes/Styles/UserControl.axaml" />
<MergeResourceInclude Source="/Themes/Styles/Window.axaml" />
<MergeResourceInclude Source="/Themes/Styles/Button.axaml" />
<MergeResourceInclude Source="/Themes/Styles/RepeatButton.axaml" />
<MergeResourceInclude Source="/Themes/Styles/ToggleButton.axaml" />
<MergeResourceInclude Source="/Themes/Styles/RadioButton.axaml" />
<MergeResourceInclude Source="/Themes/Styles/CheckBox.axaml" />
<MergeResourceInclude Source="/Themes/Styles/Border.axaml" />
<MergeResourceInclude Source="/Themes/Styles/ItemsControl.axaml" />
<MergeResourceInclude Source="/Themes/Styles/TabItem.axaml" />
<MergeResourceInclude Source="/Themes/Styles/TabControl.axaml" />
<MergeResourceInclude Source="/Themes/Styles/ListBoxItem.axaml" />
<MergeResourceInclude Source="/Themes/Styles/ScrollViewer.axaml" />
<MergeResourceInclude Source="/Themes/Styles/ListBox.axaml" />
<MergeResourceInclude Source="/Themes/Styles/Label.axaml" />
<MergeResourceInclude Source="/Themes/Styles/Slider.axaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Styles.Resources>

<StyleInclude Source="/Themes/Styles/Style.axaml" />
<Style Selector=":is(UserControl)">
<Setter Property="Theme"
Value="{DynamicResource {x:Type UserControl}}" />
</Style>
</Styles>
2 changes: 1 addition & 1 deletion src/Shared/HandyControl_Shared/Themes/Basic/Fonts.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
<system:Double x:Key="SubHeadFontSize">16</system:Double>
<system:Double x:Key="TextFontSize">12</system:Double>

</ResourceDictionary>
</ResourceDictionary>

0 comments on commit 528f3ea

Please sign in to comment.