Files
qbtmud/Lantean.QBTMudBlade/Models/UIAction.cs
2024-08-17 11:49:34 +01:00

64 lines
1.8 KiB
C#

using Microsoft.AspNetCore.Components;
using MudBlazor;
namespace Lantean.QBTMudBlade.Models
{
public record UIAction
{
private readonly Color _color;
public UIAction(string name, string text, string? icon, Color color, string href, bool separatorBefore = false)
{
Name = name;
Text = text;
Icon = icon;
_color = color;
Href = href;
SeparatorBefore = separatorBefore;
Children = [];
}
public UIAction(string name, string text, string? icon, Color color, EventCallback callback, bool separatorBefore = false)
{
Name = name;
Text = text;
Icon = icon;
_color = color;
Callback = callback;
SeparatorBefore = separatorBefore;
Children = [];
}
public UIAction(string name, string text, string? icon, Color color, IEnumerable<UIAction> children, bool useTextButton = false, bool separatorBefore = false)
{
Name = name;
Text = text;
Icon = icon;
_color = color;
Callback = default;
Children = children;
UseTextButton = useTextButton;
SeparatorBefore = separatorBefore;
}
public string Name { get; }
public string Text { get; }
public string? Icon { get; }
public Color Color => IsChecked is null || IsChecked.Value ? _color : Color.Transparent;
public EventCallback Callback { get; }
public string? Href { get; }
public bool SeparatorBefore { get; set; }
public IEnumerable<UIAction> Children { get; }
public bool UseTextButton { get; }
public bool? IsChecked { get; internal set; }
}
}