feat: make drawer api similar to dialog.

This commit is contained in:
rabbitism
2024-02-10 01:29:06 +08:00
parent 7a9bdf231d
commit f6f216f409
11 changed files with 228 additions and 108 deletions

View File

@@ -5,6 +5,8 @@ namespace Ursa.PrismExtension;
public interface IUrsaDrawerService
{
public Task<DialogResult> ShowDrawer(string viewName, object? vm, string? hostId = null, DefaultDrawerOptions? options = null);
public Task<TResult?> ShowCustomDrawer<TResult>(string viewName, object? vm, string? hostId = null, CustomDrawerOptions? options = null);
public void Show(string viewName, object? vm, string? hostId = null, DrawerOptions? options = null);
public void ShowCustom<TResult>(string viewName, object? vm, string? hostId = null, DrawerOptions? options = null);
public Task<DialogResult> ShowModal(string viewName, object? vm, string? hostId = null, DrawerOptions? options = null);
public Task<TResult?> ShowCustomModal<TResult>(string viewName, object? vm, string? hostId = null, DrawerOptions? options = null);
}

View File

@@ -7,16 +7,27 @@ namespace Ursa.PrismExtension;
public class UrsaDrawerService(IContainerExtension container): IUrsaDrawerService
{
public Task<DialogResult> ShowDrawer(string viewName, object? vm, string? hostId = null, DefaultDrawerOptions? options = null)
public void Show(string viewName, object? vm, string? hostId = null, DrawerOptions? options = null)
{
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
return Drawer.Show(v, vm, hostId, options);
Drawer.Show(v, vm, hostId, options);
}
public Task<TResult?> ShowCustomDrawer<TResult>(string viewName, object? vm, string? hostId = null,
CustomDrawerOptions? options = null)
public void ShowCustom<TResult>(string viewName, object? vm, string? hostId = null, DrawerOptions? options = null)
{
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
return Drawer.ShowCustom<TResult?>(v, vm, hostId, options);
Drawer.ShowCustom(v, vm, hostId, options);
}
public Task<DialogResult> ShowModal(string viewName, object? vm, string? hostId = null, DrawerOptions? options = null)
{
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
return Drawer.ShowModal(v, vm, hostId, options);
}
public Task<TResult?> ShowCustomModal<TResult>(string viewName, object? vm, string? hostId = null, DrawerOptions? options = null)
{
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
return Drawer.ShowCustomModal<TResult?>(v, vm, hostId, options);
}
}