feat: add RefreshContainer and ThemeVariantScope.

This commit is contained in:
rabbitism 2023-02-04 11:49:22 +08:00
parent 3ee089fb32
commit caae00b7c0
12 changed files with 133 additions and 0 deletions

View File

@ -0,0 +1,18 @@
<UserControl
x:Class="Semi.Avalonia.Demo.Pages.RefreshContainerDemo"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<StackPanel
Margin="20"
HorizontalAlignment="Left"
Spacing="20">
<RefreshContainer Name="container">
<TextBlock Text="Content" />
</RefreshContainer>
</StackPanel>
</UserControl>

View File

@ -0,0 +1,14 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace Semi.Avalonia.Demo.Pages;
public partial class RefreshContainerDemo : UserControl
{
public RefreshContainerDemo()
{
InitializeComponent();
}
}

View File

@ -0,0 +1,13 @@
<UserControl
x:Class="Semi.Avalonia.Demo.Pages.ThemeVariantDemo"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<ThemeVariantScope>
<TextBox Width="100" />
</ThemeVariantScope>
</UserControl>

View File

@ -0,0 +1,13 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Semi.Avalonia.Demo.Pages;
public partial class ThemeVariantDemo : UserControl
{
public ThemeVariantDemo()
{
InitializeComponent();
}
}

View File

@ -78,6 +78,9 @@
<TabItem Header="RadioButton">
<pages:RadioButtonDemo />
</TabItem>
<TabItem Header="RefreshContainer">
<pages:RefreshContainerDemo />
</TabItem>
<TabItem Header="RepeatButton">
<pages:RepeatButtonDemo />
</TabItem>
@ -96,6 +99,9 @@
<TabItem Header="TextBox">
<pages:TextBoxDemo />
</TabItem>
<TabItem Header="ThemeVariantScope">
<pages:ThemeVariantDemo />
</TabItem>
<TabItem Header="TimePicker">
<pages:TimePickerDemo />
</TabItem>

View File

@ -31,6 +31,7 @@
<ResourceInclude Source="avares://Semi.Avalonia/Controls/Popup.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Controls/ProgressBar.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Controls/RadioButton.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Controls/RefreshContainer.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Controls/RepeatButton.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Controls/SelectableTextBlock.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Controls/ScrollViewer.axaml" />
@ -42,6 +43,7 @@
<ResourceInclude Source="avares://Semi.Avalonia/Controls/TabStrip.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Controls/TextBlock.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Controls/TextBox.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Controls/ThemeVariantScope.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Controls/TimePicker.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Controls/TitleBar.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Controls/ToggleButton.axaml" />

View File

@ -0,0 +1,45 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<ControlTheme x:Key="{x:Type RefreshContainer}" TargetType="RefreshContainer">
<Setter Property="Template">
<ControlTemplate>
<Grid>
<ContentPresenter
Name="PART_ContentPresenter"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
CornerRadius="{TemplateBinding CornerRadius}" />
<Grid Name="PART_RefreshVisualizerPresenter" />
</Grid>
</ControlTemplate>
</Setter>
</ControlTheme>
<ControlTheme x:Key="{x:Type RefreshVisualizer}" TargetType="RefreshVisualizer">
<Setter Property="IsTabStop" Value="False" />
<Setter Property="IsHitTestVisible" Value="False" />
<Setter Property="Height" Value="100" />
<Setter Property="Background" Value="{DynamicResource RefreshContainerIconBackground}" />
<Setter Property="Foreground" Value="{DynamicResource RefreshContainerIconForeground}" />
<Setter Property="Template">
<ControlTemplate>
<Grid
Name="PART_Root"
MinHeight="80"
Background="{TemplateBinding Background}">
<Grid.Styles>
<Style Selector="PathIcon#PART_Icon">
<Setter Property="Data" Value="{DynamicResource RefreshContainerIconGlyph}" />
</Style>
</Grid.Styles>
</Grid>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>

View File

@ -0,0 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<ControlTheme x:Key="{x:Type ThemeVariantScope}" TargetType="ThemeVariantScope">
<!-- Add Resources Here -->
</ControlTheme>
</ResourceDictionary>

View File

@ -25,6 +25,7 @@
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Dark/NumericUpDown.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Dark/ProgressBar.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Dark/RadioButton.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Dark/RefreshContainer.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Dark/ScrollViewer.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Dark/Slider.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Dark/SplitButton.axaml" />

View File

@ -0,0 +1,7 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<SolidColorBrush x:Key="RefreshContainerIconForeground" Color="#54A9FF" />
<SolidColorBrush x:Key="RefreshContainerIconBackground" Color="Transparent" />
<x:Double x:Key="RefreshContainerIconSize">24</x:Double>
<PathGeometry x:Key="RefreshContainerIconGlyph">M14.2 3.78966C9.66551 2.57466 5.00465 5.26561 3.78964 9.80007C3.12066 12.2967 3.63433 14.8301 4.99177 16.8102C5.46019 17.4935 5.28601 18.4271 4.60273 18.8955C3.91945 19.364 2.98581 19.1898 2.51739 18.5065C0.685557 15.8344 -0.0134454 12.4023 0.891867 9.02361C2.5357 2.88875 8.84157 -0.751945 14.9764 0.891885C21.1113 2.53572 24.752 8.84159 23.1082 14.9765C22.8937 15.7767 22.0712 16.2515 21.271 16.0371C20.4708 15.8227 19.996 15.0002 20.2104 14.2C21.4254 9.66553 18.7344 5.00467 14.2 3.78966Z</PathGeometry>
</ResourceDictionary>

View File

@ -24,6 +24,7 @@
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/NumericUpDown.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/ProgressBar.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/RadioButton.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/RefreshContainer.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/ScrollViewer.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/Slider.axaml" />
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/SplitButton.axaml" />

View File

@ -0,0 +1,7 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<SolidColorBrush x:Key="RefreshContainerIconForeground" Color="#0077FA" />
<SolidColorBrush x:Key="RefreshContainerIconBackground" Color="Transparent" />
<x:Double x:Key="RefreshContainerIconSize">24</x:Double>
<PathGeometry x:Key="RefreshContainerIconGlyph">M14.2 3.78966C9.66551 2.57466 5.00465 5.26561 3.78964 9.80007C3.12066 12.2967 3.63433 14.8301 4.99177 16.8102C5.46019 17.4935 5.28601 18.4271 4.60273 18.8955C3.91945 19.364 2.98581 19.1898 2.51739 18.5065C0.685557 15.8344 -0.0134454 12.4023 0.891867 9.02361C2.5357 2.88875 8.84157 -0.751945 14.9764 0.891885C21.1113 2.53572 24.752 8.84159 23.1082 14.9765C22.8937 15.7767 22.0712 16.2515 21.271 16.0371C20.4708 15.8227 19.996 15.0002 20.2104 14.2C21.4254 9.66553 18.7344 5.00467 14.2 3.78966Z</PathGeometry>
</ResourceDictionary>