feat: initialize icon button.
This commit is contained in:
24
src/Ursa.Themes.Semi/Controls/IconButton.axaml
Normal file
24
src/Ursa.Themes.Semi/Controls/IconButton.axaml
Normal file
@@ -0,0 +1,24 @@
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:u="https://irihi.tech/ursa">
|
||||
<!-- Add Resources Here -->
|
||||
<ControlTheme x:Key="{x:Type u:IconButton}" TargetType="u:IconButton">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="u:IconButton">
|
||||
<Border>
|
||||
<Grid
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
ColumnDefinitions="Auto, Auto">
|
||||
<Panel Grid.Column="0">
|
||||
<ContentPresenter Content="{TemplateBinding Icon}" ContentTemplate="{TemplateBinding IconTemplate}" />
|
||||
<u:LoadingIcon Foreground="Red" IsVisible="{TemplateBinding IsLoading}" />
|
||||
</Panel>
|
||||
<ContentPresenter Grid.Column="1" Content="{TemplateBinding Content}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
@@ -6,6 +6,7 @@
|
||||
<ResourceInclude Source="ButtonGroup.axaml" />
|
||||
<ResourceInclude Source="Divider.axaml" />
|
||||
<ResourceInclude Source="DualBadge.axaml" />
|
||||
<ResourceInclude Source="IconButton.axaml" />
|
||||
<ResourceInclude Source="ImageViewer.axaml" />
|
||||
<ResourceInclude Source="IPv4Box.axaml" />
|
||||
<ResourceInclude Source="KeyGestureInput.axaml" />
|
||||
|
||||
35
src/Ursa/Controls/IconButton.cs
Normal file
35
src/Ursa/Controls/IconButton.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Templates;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
public class IconButton: Button
|
||||
{
|
||||
public static readonly StyledProperty<object?> IconProperty = AvaloniaProperty.Register<IconButton, object?>(
|
||||
nameof(Icon));
|
||||
|
||||
public object? Icon
|
||||
{
|
||||
get => GetValue(IconProperty);
|
||||
set => SetValue(IconProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<IDataTemplate?> IconTemplateProperty = AvaloniaProperty.Register<IconButton, IDataTemplate?>(
|
||||
nameof(IconTemplate));
|
||||
|
||||
public IDataTemplate? IconTemplate
|
||||
{
|
||||
get => GetValue(IconTemplateProperty);
|
||||
set => SetValue(IconTemplateProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<bool> IsLoadingProperty = AvaloniaProperty.Register<IconButton, bool>(
|
||||
nameof(IsLoading));
|
||||
|
||||
public bool IsLoading
|
||||
{
|
||||
get => GetValue(IsLoadingProperty);
|
||||
set => SetValue(IsLoadingProperty, value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user