using System; using System.Collections.ObjectModel; using Avalonia; using Avalonia.Controls.Primitives; using Avalonia.Media; using SukiUI.Dialogs; namespace SukiUI.Controls { public class SukiDialog : TemplatedControl, ISukiDialog { public static readonly StyledProperty ViewModelProperty = AvaloniaProperty.Register(nameof(ViewModel)); public object? ViewModel { get => GetValue(ViewModelProperty); set => SetValue(ViewModelProperty, value); } public static readonly StyledProperty TitleProperty = AvaloniaProperty.Register(nameof(Title)); public string? Title { get => GetValue(TitleProperty); set => SetValue(TitleProperty, value); } public static readonly StyledProperty ContentProperty = AvaloniaProperty.Register(nameof(Content)); public object? Content { get => GetValue(ContentProperty); set => SetValue(ContentProperty, value); } public static readonly StyledProperty IsViewModelOnlyProperty = AvaloniaProperty.Register(nameof(IsViewModelOnly)); internal bool IsViewModelOnly { get => GetValue(IsViewModelOnlyProperty); set => SetValue(IsViewModelOnlyProperty, value); } public static readonly StyledProperty IconProperty = AvaloniaProperty.Register(nameof(Icon)); public object? Icon { get => GetValue(IconProperty); set => SetValue(IconProperty, value); } public static readonly StyledProperty ShowCardBackgroundProperty = AvaloniaProperty.Register(nameof(ShowCardBackground), defaultValue: true); public bool ShowCardBackground { get => GetValue(ShowCardBackgroundProperty); set => SetValue(ShowCardBackgroundProperty, value); } public static readonly StyledProperty IconColorProperty = AvaloniaProperty.Register(nameof(IconColor)); public IBrush? IconColor { get => GetValue(IconColorProperty); set => SetValue(IconColorProperty, value); } public static readonly StyledProperty> ActionButtonsProperty = AvaloniaProperty.Register>(nameof(ActionButtons)); public ObservableCollection ActionButtons { get => GetValue(ActionButtonsProperty); set => SetValue(ActionButtonsProperty, value); } public ISukiDialogManager? Manager { get; set; } public Action? OnDismissed { get; set; } public bool CanDismissWithBackgroundClick { get; set; } public SukiDialog() { ActionButtons = new ObservableCollection(); } public void Dismiss() => Manager?.TryDismissDialog(this); protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); IsViewModelOnly = ViewModel != null; } } }