Toolkit.UI.Controls.Avalonia

This commit is contained in:
TheXamlGuy
2024-04-13 11:41:33 +01:00
parent 62a7e94e19
commit 862e7b2e34
97 changed files with 8558 additions and 0 deletions
@@ -0,0 +1,52 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Toolkit.UI.Controls.Avalonia"
xmlns:ui="using:FluentAvalonia.UI.Controls">
<Design.PreviewWith>
<Border Padding="20" />
</Design.PreviewWith>
<ControlTheme x:Key="{x:Type controls:SettingsExpander}" TargetType="controls:SettingsExpander">
<Setter Property="Background" Value="{DynamicResource ExpanderBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource ExpanderHeaderBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource ExpanderHeaderBorderThickness}" />
<Setter Property="Padding" Value="{DynamicResource SettingsExpanderPadding}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="MinHeight" Value="{DynamicResource SettingsExpanderMinHeight}" />
<Setter Property="ItemsPanel">
<ItemsPanelTemplate>
<StackPanel Spacing="1" />
</ItemsPanelTemplate>
</Setter>
<Setter Property="Template">
<ControlTemplate>
<Expander
Name="Expander"
IsExpanded="{TemplateBinding IsExpanded,
Mode=TwoWay}"
Theme="{StaticResource SettingsExpanderExpanderStyle}">
<Expander.Header>
<controls:SettingsExpanderItem
Name="ContentHost"
Padding="{DynamicResource SettingsExpanderPadding}"
ActionIconSource="{TemplateBinding ActionIconSource}"
Background="Transparent"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
Description="{TemplateBinding Description}"
Footer="{TemplateBinding Footer}"
FooterTemplate="{TemplateBinding FooterTemplate}"
IconSource="{TemplateBinding IconSource}"
IsClickEnabled="{TemplateBinding IsClickEnabled}" />
</Expander.Header>
<ItemsPresenter ItemsPanel="{TemplateBinding ItemsPanel}" />
</Expander>
</ControlTemplate>
</Setter>
<Style Selector="^:empty /template/ ItemsPresenter#ItemsHost">
<Setter Property="IsVisible" Value="False" />
</Style>
</ControlTheme>
</ResourceDictionary>
@@ -0,0 +1,33 @@
using Avalonia;
namespace Toolkit.UI.Controls.Avalonia;
public class SettingsExpander : FluentAvalonia.UI.Controls.SettingsExpander
{
protected override Type StyleKeyOverride =>
typeof(SettingsExpander);
public new static readonly StyledProperty<object> DescriptionProperty =
AvaloniaProperty.Register<SettingsExpander, object>(nameof(Description));
public new object Description
{
get => GetValue(DescriptionProperty);
set => SetValue(DescriptionProperty, value);
}
}
public class SettingsExpanderItem : FluentAvalonia.UI.Controls.SettingsExpanderItem
{
protected override Type StyleKeyOverride =>
typeof(SettingsExpanderItem);
public new static readonly StyledProperty<object> DescriptionProperty =
AvaloniaProperty.Register<SettingsExpanderItem, object>(nameof(Description));
public new object Description
{
get => GetValue(DescriptionProperty);
set => SetValue(DescriptionProperty, value);
}
}
@@ -0,0 +1,144 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Toolkit.UI.Controls.Avalonia"
xmlns:ui="using:FluentAvalonia.UI.Controls">
<Design.PreviewWith>
<Border Padding="20" />
</Design.PreviewWith>
<Thickness x:Key="SettingsExpanderItemPadding">16 10</Thickness>
<x:Double x:Key="SettingsExpanderItemMinHeight">48</x:Double>
<Thickness x:Key="SettingsExpanderItemContentMargin">42 0 0 0</Thickness>
<Thickness x:Key="SettingsExpanderItemFooterMargin">16 0 0 0</Thickness>
<Thickness x:Key="SettingsExpanderItemBottomFooterMargin">42 16 0 0</Thickness>
<x:Double x:Key="SettingsExpanderItemIconSize">24</x:Double>
<x:Double x:Key="SettingsExpanderItemActionIconSize">18</x:Double>
<x:Double x:Key="SettingsExpanderItemAdaptiveWidthTrigger">460</x:Double>
<ControlTheme x:Key="{x:Type controls:SettingsExpanderItem}" TargetType="controls:SettingsExpanderItem">
<Setter Property="Background" Value="{DynamicResource ExpanderHeaderBackground}" />
<Setter Property="Padding" Value="{DynamicResource SettingsExpanderItemPadding}" />
<Setter Property="MinHeight" Value="{DynamicResource SettingsExpanderItemMinHeight}" />
<Setter Property="Template">
<ControlTemplate>
<ui:FABorder
Name="Root"
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ui:FABorder.Transitions>
<Transitions>
<BrushTransition Property="Background" Duration="00:00:00.083" />
<BrushTransition Property="BorderBrush" Duration="00:00:00.083" />
</Transitions>
</ui:FABorder.Transitions>
<Grid ColumnDefinitions="*,Auto,Auto" RowDefinitions="*,Auto">
<Viewbox
Name="IconHost"
Width="{DynamicResource SettingsExpanderItemIconSize}"
Height="{DynamicResource SettingsExpanderItemIconSize}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
IsVisible="False">
<ContentPresenter Name="IconPresenter" Content="{Binding TemplateSettings.Icon, RelativeSource={RelativeSource TemplatedParent}}" />
</Viewbox>
<StackPanel
Name="HeaderRegion"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="Center">
<ContentPresenter
Name="ContentPresenter"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
IsVisible="False" />
<ContentPresenter
Name="DescriptionText"
Content="{TemplateBinding Description}"
FontSize="{DynamicResource CaptionTextBlockFontSize}"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
TextWrapping="Wrap"
Theme="{StaticResource CaptionTextBlockStyle}" />
</StackPanel>
<ContentPresenter
Name="FooterPresenter"
Grid.Row="0"
Grid.Column="1"
Grid.ColumnSpan="1"
Margin="{DynamicResource SettingsExpanderItemFooterMargin}"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Content="{TemplateBinding Footer}"
ContentTemplate="{TemplateBinding FooterTemplate}"
IsVisible="False" />
<Viewbox
Name="ActionIconHost"
Grid.Column="2"
Width="{DynamicResource SettingsExpanderItemActionIconSize}"
Height="{DynamicResource SettingsExpanderItemActionIconSize}"
IsVisible="False">
<ContentPresenter Name="ExpandChevronActionIconContainer" Content="{Binding TemplateSettings.ActionIcon, RelativeSource={RelativeSource TemplatedParent}}" />
</Viewbox>
</Grid>
</ui:FABorder>
</ControlTemplate>
</Setter>
<Style Selector="^:empty /template/ ItemsPresenter#ItemsHost">
<Setter Property="IsVisible" Value="False" />
</Style>
<Style Selector="^:nth-last-child(1) /template/ ui|FABorder#Root">
<Setter Property="CornerRadius" Value="{Binding Source={StaticResource ControlCornerRadius}, Converter={StaticResource BottomCornerRadiusFilterConverter}}" />
</Style>
<Style Selector="^:footer /template/ ContentPresenter#FooterPresenter">
<Setter Property="IsVisible" Value="True" />
</Style>
<Style Selector="^:footerBottom /template/ ContentPresenter#FooterPresenter">
<Setter Property="Grid.Row" Value="1" />
<Setter Property="Grid.Column" Value="0" />
<Setter Property="Grid.ColumnSpan" Value="3" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Margin" Value="{DynamicResource SettingsExpanderItemBottomFooterMargin}" />
</Style>
<Style Selector="^:actionIcon /template/ Viewbox#ActionIconHost">
<Setter Property="IsVisible" Value="True" />
</Style>
<Style Selector="^:content /template/ ContentPresenter#ContentPresenter">
<Setter Property="IsVisible" Value="True" />
</Style>
<Style Selector="^:icon">
<Style Selector="^ /template/ Viewbox#IconHost">
<Setter Property="IsVisible" Value="True" />
</Style>
<Style Selector="^ /template/ StackPanel#HeaderRegion">
<Setter Property="Margin" Value="{DynamicResource SettingsExpanderItemContentMargin}" />
</Style>
</Style>
<Style Selector="^:iconPlaceholder">
<Style Selector="^ /template/ StackPanel#HeaderRegion">
<Setter Property="Margin" Value="{DynamicResource SettingsExpanderItemContentMargin}" />
</Style>
</Style>
<Style Selector="^:allowClick">
<Style Selector="^:pointerover /template/ ui|FABorder#Root">
<Setter Property="Background" Value="{DynamicResource ControlFillColorSecondaryBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource ControlFillColorSecondaryBrush}" />
</Style>
<Style Selector="^:pressed /template/ ui|FABorder#Root">
<Setter Property="Background" Value="{DynamicResource ControlFillColorTertiaryBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource ControlStrokeColorDefaultBrush}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource TextFillColorSecondaryBrush}" />
</Style>
</Style>
<Style Selector="^:disabled">
<Style Selector="^ /template/ ui|FABorder#Root">
<Setter Property="Background" Value="{DynamicResource ControlFillColorDisabledBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource ControlStrokeColorDefaultBrush}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource TextFillColorDisabledBrush}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#DescriptionText">
<Setter Property="TextElement.Foreground" Value="{DynamicResource TextFillColorDisabledBrush}" />
</Style>
</Style>
</ControlTheme>
</ResourceDictionary>