feat: simple avatar group.
This commit is contained in:
@@ -64,5 +64,14 @@
|
|||||||
<u:Avatar Classes="Large" />
|
<u:Avatar Classes="Large" />
|
||||||
<u:Avatar Classes="ExtraLarge" />
|
<u:Avatar Classes="ExtraLarge" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<u:AvatarGroup>
|
||||||
|
<u:Avatar Classes="Red" Content="LL" />
|
||||||
|
<u:Avatar Classes="" Content="CX" />
|
||||||
|
<u:Avatar Classes="Amber" Content="RM" />
|
||||||
|
<u:Avatar Background="#FDE3CF" Foreground="#F56A00" Content="ZL" />
|
||||||
|
<u:Avatar Background="#87D068" Classes="" Content="YZ" />
|
||||||
|
</u:AvatarGroup>
|
||||||
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -21,9 +21,7 @@
|
|||||||
RadiusX="{Binding #PART_Ellipse.Bounds.Width, Converter={StaticResource DivideByTwoConverter}}"
|
RadiusX="{Binding #PART_Ellipse.Bounds.Width, Converter={StaticResource DivideByTwoConverter}}"
|
||||||
RadiusY="{Binding #PART_Ellipse.Bounds.Height, Converter={StaticResource DivideByTwoConverter}}" />
|
RadiusY="{Binding #PART_Ellipse.Bounds.Height, Converter={StaticResource DivideByTwoConverter}}" />
|
||||||
</Panel.Clip>
|
</Panel.Clip>
|
||||||
<Ellipse
|
<Ellipse Name="PART_Ellipse" />
|
||||||
Name="PART_Ellipse"
|
|
||||||
Fill="Transparent"/>
|
|
||||||
<Ellipse
|
<Ellipse
|
||||||
Fill="{TemplateBinding Background}"
|
Fill="{TemplateBinding Background}"
|
||||||
IsVisible="{TemplateBinding Source, Converter={x:Static ObjectConverters.IsNull}}" />
|
IsVisible="{TemplateBinding Source, Converter={x:Static ObjectConverters.IsNull}}" />
|
||||||
@@ -131,5 +129,12 @@
|
|||||||
<Setter Property="FontSize" Value="64" />
|
<Setter Property="FontSize" Value="64" />
|
||||||
</Style>
|
</Style>
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
<ControlTheme x:Key="{x:Type u:AvatarGroup}" TargetType="{x:Type u:AvatarGroup}" />
|
|
||||||
|
<ControlTheme x:Key="{x:Type u:AvatarGroup}" TargetType="{x:Type u:AvatarGroup}">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate TargetType="u:AvatarGroup">
|
||||||
|
<ItemsPresenter ItemsPanel="{TemplateBinding ItemsPanel}" />
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
</ControlTheme>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Controls.Templates;
|
||||||
|
using Avalonia.Layout;
|
||||||
|
|
||||||
namespace Ursa.Controls;
|
namespace Ursa.Controls;
|
||||||
|
|
||||||
@@ -7,10 +9,14 @@ public class AvatarGroup : ItemsControl
|
|||||||
{
|
{
|
||||||
public const string PART_RenderMore = "PART_RenderMore";
|
public const string PART_RenderMore = "PART_RenderMore";
|
||||||
|
|
||||||
|
private static readonly FuncTemplate<Panel?> DefaultPanel =
|
||||||
|
new(() => new StackPanel { Orientation = Orientation.Horizontal });
|
||||||
|
|
||||||
public static readonly StyledProperty<int> MaxCountProperty = AvaloniaProperty.Register<AvatarGroup, int>(
|
public static readonly StyledProperty<int> MaxCountProperty = AvaloniaProperty.Register<AvatarGroup, int>(
|
||||||
nameof(MaxCount));
|
nameof(MaxCount));
|
||||||
|
|
||||||
public static readonly StyledProperty<OverlapFromType> OverlapFromProperty = AvaloniaProperty.Register<AvatarGroup, OverlapFromType>(
|
public static readonly StyledProperty<OverlapFromType> OverlapFromProperty =
|
||||||
|
AvaloniaProperty.Register<AvatarGroup, OverlapFromType>(
|
||||||
nameof(OverlapFrom));
|
nameof(OverlapFrom));
|
||||||
|
|
||||||
public int MaxCount
|
public int MaxCount
|
||||||
@@ -24,6 +30,11 @@ public class AvatarGroup : ItemsControl
|
|||||||
get => GetValue(OverlapFromProperty);
|
get => GetValue(OverlapFromProperty);
|
||||||
set => SetValue(OverlapFromProperty, value);
|
set => SetValue(OverlapFromProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static AvatarGroup()
|
||||||
|
{
|
||||||
|
ItemsPanelProperty.OverrideDefaultValue<AvatarGroup>(DefaultPanel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum OverlapFromType
|
public enum OverlapFromType
|
||||||
|
|||||||
Reference in New Issue
Block a user