diff --git a/demo/Ursa.Demo/Dialogs/PlainDialog.axaml b/demo/Ursa.Demo/Dialogs/PlainDialog.axaml
index 903a8b1..89dbb0d 100644
--- a/demo/Ursa.Demo/Dialogs/PlainDialog.axaml
+++ b/demo/Ursa.Demo/Dialogs/PlainDialog.axaml
@@ -9,10 +9,5 @@
x:Class="Ursa.Demo.Dialogs.PlainDialog">
-
- A
- B
- C
-
diff --git a/demo/Ursa.Demo/Pages/DrawerDemo.axaml b/demo/Ursa.Demo/Pages/DrawerDemo.axaml
index 866d7d1..fca5d36 100644
--- a/demo/Ursa.Demo/Pages/DrawerDemo.axaml
+++ b/demo/Ursa.Demo/Pages/DrawerDemo.axaml
@@ -1,18 +1,99 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demo/Ursa.Demo/ViewModels/DrawerDemoViewModel.cs b/demo/Ursa.Demo/ViewModels/DrawerDemoViewModel.cs
index 2d44a87..209eb52 100644
--- a/demo/Ursa.Demo/ViewModels/DrawerDemoViewModel.cs
+++ b/demo/Ursa.Demo/ViewModels/DrawerDemoViewModel.cs
@@ -1,3 +1,5 @@
+using System;
+using System.Collections.ObjectModel;
using System.Threading.Tasks;
using System.Windows.Input;
using Avalonia.Controls;
@@ -12,33 +14,54 @@ namespace Ursa.Demo.ViewModels;
public partial class DrawerDemoViewModel: ObservableObject
{
- public ICommand OpenDrawerCommand { get; set; }
- public ICommand OpenDefaultDrawerCommand { get; set; }
-
- [ObservableProperty] private Position _selectedPosition;
-
+ public ICommand ShowDialogCommand { get; set; }
+ public ICommand ShowCustomDialogCommand { get; set; }
+ [ObservableProperty] private Position _selectedPosition;
+ [ObservableProperty] private DialogButton _selectedButton;
+ [ObservableProperty] private bool _isGlobal;
+ [ObservableProperty] private bool _canCloseMaskToClose;
+ [ObservableProperty] private DialogResult? _defaultResult;
+ [ObservableProperty] private bool _result;
+ [ObservableProperty] private bool _showMask;
+ [ObservableProperty] private DateTime? _date;
+
+
public DrawerDemoViewModel()
{
- OpenDrawerCommand = new AsyncRelayCommand(OpenDrawer);
- OpenDefaultDrawerCommand = new AsyncRelayCommand(OpenDefaultDrawer);
- SelectedPosition = Position.Right;
+ ShowDialogCommand = new AsyncRelayCommand(ShowDefaultDialog);
+ ShowCustomDialogCommand = new AsyncRelayCommand(ShowCustomDrawer);
}
-
- private Task OpenDefaultDrawer()
+
+ private async Task ShowDefaultDialog()
{
- return Drawer.Show(new PlainDialogViewModel(), new DefaultDrawerOptions()
- {
- Buttons = DialogButton.OKCancel,
- Position = SelectedPosition,
- Title = "Please select a date",
- CanClickOnMaskToClose = false,
- });
+ var vm = new PlainDialogViewModel();
+ DefaultResult = await Drawer.Show(
+ vm,
+ IsGlobal ? null : "LocalHost",
+ new DefaultDrawerOptions()
+ {
+ Title = "Please select a date",
+ Position = SelectedPosition,
+ Buttons = SelectedButton,
+ CanClickOnMaskToClose = CanCloseMaskToClose,
+ ShowMask = ShowMask,
+ });
+ Date = vm.Date;
}
-
- private async Task OpenDrawer()
+
+ private async Task ShowCustomDrawer()
{
- await Drawer.ShowCustom(new DialogWithActionViewModel(),
- new CustomDrawerOptions() { Position = SelectedPosition, MinWidth = 400, MinHeight = 400});
+ var vm = new DialogWithActionViewModel();
+ Result = await Drawer.ShowCustom(
+ vm,
+ IsGlobal ? null : "LocalHost",
+ new CustomDrawerOptions()
+ {
+ Position = SelectedPosition,
+ CanClickOnMaskToClose = CanCloseMaskToClose,
+ ShowMask = ShowMask,
+ });
+ Date = vm.Date;
}
}
\ No newline at end of file
diff --git a/src/Ursa.Themes.Semi/Controls/Drawer.axaml b/src/Ursa.Themes.Semi/Controls/Drawer.axaml
index 31db2d0..e397fcd 100644
--- a/src/Ursa.Themes.Semi/Controls/Drawer.axaml
+++ b/src/Ursa.Themes.Semi/Controls/Drawer.axaml
@@ -17,7 +17,7 @@
BorderThickness="1 0 0 0"
IsHitTestVisible="True"
Theme="{DynamicResource CardBorder}">
-
+
-
+
DialogResult.None,
+ DialogButton.OK => DialogResult.OK,
+ DialogButton.OKCancel => DialogResult.Cancel,
+ DialogButton.YesNo => DialogResult.No,
+ DialogButton.YesNoCancel => DialogResult.Cancel,
+ _ => DialogResult.None
+ };
+ RaiseEvent(new ResultEventArgs(ClosedEvent, result));
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Ursa/Controls/Drawer/Drawer.cs b/src/Ursa/Controls/Drawer/Drawer.cs
index d8e2b4e..ae9d52f 100644
--- a/src/Ursa/Controls/Drawer/Drawer.cs
+++ b/src/Ursa/Controls/Drawer/Drawer.cs
@@ -6,11 +6,11 @@ namespace Ursa.Controls;
public static class Drawer
{
- public static Task Show(TViewModel vm, DefaultDrawerOptions? options = null)
+ public static Task Show(TViewModel vm, string? hostId = null, DefaultDrawerOptions? options = null)
where TView: Control, new()
{
- var host = OverlayDialogManager.GetHost(null);
- if (host is null) return Task.FromResult(default(TResult));
+ var host = OverlayDialogManager.GetHost(hostId);
+ if (host is null) return Task.FromResult(default(DialogResult?));
var drawer = new DefaultDrawerControl()
{
Content = new TView(),
@@ -18,13 +18,13 @@ public static class Drawer
};
ConfigureDefaultDrawer(drawer, options);
host.AddDrawer(drawer);
- return drawer.ShowAsync();
+ return drawer.ShowAsync();
}
- public static Task ShowCustom(TViewModel vm, CustomDrawerOptions? options = null)
+ public static Task ShowCustom(TViewModel vm, string? hostId = null, CustomDrawerOptions? options = null)
where TView: Control, new()
{
- var host = OverlayDialogManager.GetHost(null);
+ var host = OverlayDialogManager.GetHost(hostId);
if (host is null) return Task.FromResult(default(TResult));
var dialog = new CustomDrawerControl()
{
diff --git a/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Drawer.cs b/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Drawer.cs
index cf8d932..ec7323b 100644
--- a/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Drawer.cs
+++ b/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Drawer.cs
@@ -32,7 +32,15 @@ public partial class OverlayDialogHost
SetDrawerPosition(control);
control.AddHandler(OverlayFeedbackElement.ClosedEvent, OnDrawerControlClosing);
var animation = CreateAnimation(control.Bounds.Size, control.Position, true);
- await Task.WhenAll(animation.RunAsync(control), _maskAppearAnimation.RunAsync(mask));
+ if (mask is null)
+ {
+ await animation.RunAsync(control);
+ }
+ else
+ {
+ await Task.WhenAll(animation.RunAsync(control), _maskAppearAnimation.RunAsync(mask));
+ }
+
}
private void SetDrawerPosition(DrawerControlBase control)
@@ -59,7 +67,7 @@ public partial class OverlayDialogHost
control.Height = newSize.Height;
SetLeft(control, 0);
}
- else if (control.Position == Position.Bottom)
+ else if (control.Position == Position.Top)
{
control.Width = newSize.Width;
SetTop(control, 0);