feat: using Padding instead of Gap in Avatar.
This commit is contained in:
@@ -95,8 +95,8 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||||
<u:Avatar Content="AS" />
|
<u:Avatar Content="AS" />
|
||||||
<u:Avatar Content="Semi" Gap="4" />
|
<u:Avatar Content="Semi" Padding="4" />
|
||||||
<u:Avatar Content="Semi" Gap="10" />
|
<u:Avatar Content="Semi" Padding="10" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@@ -1,22 +1,20 @@
|
|||||||
<ResourceDictionary
|
<ResourceDictionary
|
||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:u="https://irihi.tech/ursa"
|
xmlns:u="https://irihi.tech/ursa">
|
||||||
xmlns:converters="clr-namespace:Ursa.Converters;assembly=Ursa">
|
|
||||||
<Design.PreviewWith>
|
<Design.PreviewWith>
|
||||||
<StackPanel Margin="20" Orientation="Horizontal" Spacing="8">
|
<StackPanel Margin="20" Orientation="Horizontal" Spacing="8">
|
||||||
<u:Avatar Content="AS" />
|
<u:Avatar Content="AS" />
|
||||||
<u:Avatar Content="Semi" Gap="4" />
|
<u:Avatar Content="Semi" Padding="4" />
|
||||||
<u:Avatar Content="Semi" Gap="10" />
|
<u:Avatar Content="Semi" Padding="10" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Design.PreviewWith>
|
</Design.PreviewWith>
|
||||||
<converters:DoubleToThicknessConverter x:Key="DoubleToThicknessConverter" />
|
|
||||||
<ControlTheme x:Key="{x:Type u:Avatar}" TargetType="{x:Type u:Avatar}">
|
<ControlTheme x:Key="{x:Type u:Avatar}" TargetType="{x:Type u:Avatar}">
|
||||||
<Setter Property="Foreground" Value="{DynamicResource AvatarForeground}" />
|
<Setter Property="Foreground" Value="{DynamicResource AvatarForeground}" />
|
||||||
<Setter Property="Background" Value="{DynamicResource AvatarGreyBackground}" />
|
<Setter Property="Background" Value="{DynamicResource AvatarGreyBackground}" />
|
||||||
<Setter Property="FontSize" Value="{DynamicResource AvatarMediumFontSize}" />
|
<Setter Property="FontSize" Value="{DynamicResource AvatarMediumFontSize}" />
|
||||||
<Setter Property="FontWeight" Value="{DynamicResource AvatarFontWeight}" />
|
<Setter Property="FontWeight" Value="{DynamicResource AvatarFontWeight}" />
|
||||||
<Setter Property="Gap" Value="3" />
|
<Setter Property="Padding" Value="3" />
|
||||||
<Setter Property="Width" Value="{DynamicResource AvatarMediumWidth}" />
|
<Setter Property="Width" Value="{DynamicResource AvatarMediumWidth}" />
|
||||||
<Setter Property="Height" Value="{Binding $self.Width}" />
|
<Setter Property="Height" Value="{Binding $self.Width}" />
|
||||||
<Setter Property="Cursor" Value="Hand" />
|
<Setter Property="Cursor" Value="Hand" />
|
||||||
@@ -32,10 +30,9 @@
|
|||||||
BorderBrush="{TemplateBinding BorderBrush}"
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
BorderThickness="{TemplateBinding BorderThickness}"
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
CornerRadius="{TemplateBinding CornerRadius}"
|
CornerRadius="{TemplateBinding CornerRadius}"
|
||||||
Background="{TemplateBinding Background}">
|
Background="{TemplateBinding Background}" />
|
||||||
</Border>
|
|
||||||
<Viewbox
|
<Viewbox
|
||||||
Margin="{TemplateBinding Gap, Converter={StaticResource DoubleToThicknessConverter}}"
|
Margin="{TemplateBinding Padding}"
|
||||||
StretchDirection="DownOnly">
|
StretchDirection="DownOnly">
|
||||||
<ContentPresenter
|
<ContentPresenter
|
||||||
Name="PART_ContentPresenter"
|
Name="PART_ContentPresenter"
|
||||||
|
|||||||
@@ -7,21 +7,12 @@ namespace Ursa.Controls;
|
|||||||
|
|
||||||
public class Avatar : Button
|
public class Avatar : Button
|
||||||
{
|
{
|
||||||
public static readonly StyledProperty<double> GapProperty = AvaloniaProperty.Register<Avatar, double>(
|
|
||||||
nameof(Gap));
|
|
||||||
|
|
||||||
public static readonly StyledProperty<IImage?> SourceProperty = AvaloniaProperty.Register<Avatar, IImage?>(
|
public static readonly StyledProperty<IImage?> SourceProperty = AvaloniaProperty.Register<Avatar, IImage?>(
|
||||||
nameof(Source));
|
nameof(Source));
|
||||||
|
|
||||||
public static readonly StyledProperty<object?> HoverMaskProperty = AvaloniaProperty.Register<Avatar, object?>(
|
public static readonly StyledProperty<object?> HoverMaskProperty = AvaloniaProperty.Register<Avatar, object?>(
|
||||||
nameof(HoverMask));
|
nameof(HoverMask));
|
||||||
|
|
||||||
public double Gap
|
|
||||||
{
|
|
||||||
get => GetValue(GapProperty);
|
|
||||||
set => SetValue(GapProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public IImage? Source
|
public IImage? Source
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
using System.Globalization;
|
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Data.Converters;
|
|
||||||
|
|
||||||
namespace Ursa.Converters;
|
|
||||||
|
|
||||||
public class DoubleToThicknessConverter : IValueConverter
|
|
||||||
{
|
|
||||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
if (value is double d)
|
|
||||||
{
|
|
||||||
return new Thickness(d, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return AvaloniaProperty.UnsetValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user