diff --git a/demo/Ursa.Demo/Dialogs/DialogWithAction.axaml b/demo/Ursa.Demo/Dialogs/DialogWithAction.axaml new file mode 100644 index 0000000..3a0d2ac --- /dev/null +++ b/demo/Ursa.Demo/Dialogs/DialogWithAction.axaml @@ -0,0 +1,20 @@ + + + + + + + + + + + diff --git a/demo/Ursa.Demo/Dialogs/DialogWithAction.axaml.cs b/demo/Ursa.Demo/Dialogs/DialogWithAction.axaml.cs new file mode 100644 index 0000000..783f47b --- /dev/null +++ b/demo/Ursa.Demo/Dialogs/DialogWithAction.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Ursa.Demo.Dialogs; + +public partial class DialogWithAction : UserControl +{ + public DialogWithAction() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/demo/Ursa.Demo/Dialogs/DialogWithActionViewModel.cs b/demo/Ursa.Demo/Dialogs/DialogWithActionViewModel.cs new file mode 100644 index 0000000..5f43a7f --- /dev/null +++ b/demo/Ursa.Demo/Dialogs/DialogWithActionViewModel.cs @@ -0,0 +1,50 @@ +using System; +using System.Threading.Tasks; +using System.Windows.Input; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using Ursa.Controls; + +namespace Ursa.Demo.Dialogs; + +public partial class DialogWithActionViewModel: ObservableObject, IDialogContext +{ + [ObservableProperty] private string _title; + [ObservableProperty] private DateTime _date; + + public void Close() + { + Closed?.Invoke(this, false); + } + + public event EventHandler? Closed; + + public ICommand OKCommand { get; set; } + public ICommand CancelCommand { get; set; } + + public ICommand DialogCommand { get; set; } + + public DialogWithActionViewModel() + { + OKCommand = new RelayCommand(OK); + CancelCommand = new RelayCommand(Cancel); + DialogCommand = new AsyncRelayCommand(ShowDialog); + Title = "Please select a date"; + Date = DateTime.Now; + } + + private void OK() + { + Closed?.Invoke(this, true); + } + + private void Cancel() + { + Closed?.Invoke(this, false); + } + + private async Task ShowDialog() + { + await OverlayDialog.ShowCustomModalAsync(new DialogWithActionViewModel()); + } +} \ No newline at end of file diff --git a/demo/Ursa.Demo/Dialogs/PlainDialog.axaml b/demo/Ursa.Demo/Dialogs/PlainDialog.axaml new file mode 100644 index 0000000..89dbb0d --- /dev/null +++ b/demo/Ursa.Demo/Dialogs/PlainDialog.axaml @@ -0,0 +1,13 @@ + + + + + diff --git a/demo/Ursa.Demo/Dialogs/PlainDialog.axaml.cs b/demo/Ursa.Demo/Dialogs/PlainDialog.axaml.cs new file mode 100644 index 0000000..1e4be06 --- /dev/null +++ b/demo/Ursa.Demo/Dialogs/PlainDialog.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Ursa.Demo.Dialogs; + +public partial class PlainDialog : UserControl +{ + public PlainDialog() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/demo/Ursa.Demo/Dialogs/PlainDialogViewModel.cs b/demo/Ursa.Demo/Dialogs/PlainDialogViewModel.cs new file mode 100644 index 0000000..2e199a6 --- /dev/null +++ b/demo/Ursa.Demo/Dialogs/PlainDialogViewModel.cs @@ -0,0 +1,15 @@ +using System; +using CommunityToolkit.Mvvm.ComponentModel; + +namespace Ursa.Demo.Dialogs; + +public class PlainDialogViewModel: ObservableObject +{ + private DateTime? _date; + + public DateTime? Date + { + get => _date; + set => SetProperty(ref _date, value); + } +} \ No newline at end of file diff --git a/demo/Ursa.Demo/Models/MenuKeys.cs b/demo/Ursa.Demo/Models/MenuKeys.cs index 17714e1..2b30912 100644 --- a/demo/Ursa.Demo/Models/MenuKeys.cs +++ b/demo/Ursa.Demo/Models/MenuKeys.cs @@ -6,6 +6,7 @@ public static class MenuKeys public const string MenuKeyBadge = "Badge"; public const string MenuKeyBanner = "Banner"; public const string MenuKeyButtonGroup = "ButtonGroup"; + public const string MenuKeyDialog = "Dialog"; public const string MenuKeyDivider = "Divider"; public const string MenuKeyDualBadge = "DualBadge"; public const string MenuKeyEnumSelector = "EnumSelector"; diff --git a/demo/Ursa.Demo/Pages/DialogDemo.axaml b/demo/Ursa.Demo/Pages/DialogDemo.axaml new file mode 100644 index 0000000..75b27c1 --- /dev/null +++ b/demo/Ursa.Demo/Pages/DialogDemo.axaml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + - - - - - - - - -