diff --git a/SukiUI.Demo/Features/ControlsLibrary/InfoBarView.axaml b/SukiUI.Demo/Features/ControlsLibrary/InfoBarView.axaml new file mode 100644 index 000000000..166180262 --- /dev/null +++ b/SukiUI.Demo/Features/ControlsLibrary/InfoBarView.axaml @@ -0,0 +1,80 @@ + + + + + + + InfoBar is a control that displays a message to the user. It can be used to show specific severity message to the user. + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SukiUI/Controls/InfoBar.axaml.cs b/SukiUI/Controls/InfoBar.axaml.cs new file mode 100644 index 000000000..2c70781df --- /dev/null +++ b/SukiUI/Controls/InfoBar.axaml.cs @@ -0,0 +1,111 @@ +using System.Windows.Input; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.Primitives; +using Avalonia.Interactivity; +using Avalonia.Media; +using SukiUI.ColorTheme; +using SukiUI.Content; +using SukiUI.Enums; + +namespace SukiUI.Controls; + +public class InfoBar : ContentControl +{ + public static readonly StyledProperty SeverityProperty = + AvaloniaProperty.Register(nameof(Severity), NotificationType.Info); + + public NotificationType Severity + { + get => GetValue(SeverityProperty); + set + { + Icon = value switch + { + NotificationType.Info => Icons.InformationOutline, + NotificationType.Success => Icons.Check, + NotificationType.Warning => Icons.AlertOutline, + NotificationType.Error => Icons.AlertOutline, + _ => Icons.InformationOutline + }; + + IconForeground = value switch + { + NotificationType.Info => NotificationColor.InfoIconForeground, + NotificationType.Success => NotificationColor.SuccessIconForeground, + NotificationType.Warning => NotificationColor.WarningIconForeground, + NotificationType.Error => NotificationColor.ErrorIconForeground, + _ => NotificationColor.InfoIconForeground + }; + + SetValue(SeverityProperty, value); + } + } + + public static readonly StyledProperty IconProperty = + AvaloniaProperty.Register(nameof(Icon), Icons.InformationOutline); + + public object? Icon + { + get => GetValue(IconProperty); + private set => SetValue(IconProperty, value); + } + + public static readonly StyledProperty IconForegroundProperty = + AvaloniaProperty.Register(nameof(IconForeground), NotificationColor.InfoIconForeground); + + public IBrush? IconForeground + { + get => GetValue(IconForegroundProperty); + private set => SetValue(IconForegroundProperty, value); + } + + public static readonly StyledProperty IsOpenProperty = + AvaloniaProperty.Register(nameof(IsOpen), true); + + public bool IsOpen + { + get => GetValue(IsOpenProperty); + set => SetValue(IsOpenProperty, value); + } + + public static readonly StyledProperty IsClosableProperty = + AvaloniaProperty.Register(nameof(IsClosable), true); + + public bool IsClosable + { + get => GetValue(IsClosableProperty); + set => SetValue(IsClosableProperty, value); + } + + public static readonly StyledProperty TitleProperty = + AvaloniaProperty.Register(nameof(Title), string.Empty); + + public string Title + { + get => GetValue(TitleProperty); + set => SetValue(TitleProperty, value); + } + + public static readonly StyledProperty MessageProperty = + AvaloniaProperty.Register(nameof(Message), string.Empty); + + public string Message + { + get => GetValue(MessageProperty); + set => SetValue(MessageProperty, value); + } + + protected override void OnApplyTemplate(TemplateAppliedEventArgs e) + { + base.OnApplyTemplate(e); + + e.NameScope.Get