Merge pull request #98 from irihitech/prism_drawer

feat: add prism drawer service.
This commit is contained in:
Dong Bin
2024-02-07 00:17:35 +08:00
committed by GitHub
3 changed files with 33 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
using Ursa.Controls;
using Ursa.Controls.Options;
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);
}

View File

@@ -11,6 +11,7 @@ public static class UrsaDialogServiceExtension
{
containerRegistry.RegisterSingleton<IUrsaDialogService, UrsaDialogService>();
containerRegistry.RegisterSingleton<IUrsaOverlayDialogService, UrsaOverlayDialogService>();
containerRegistry.RegisterSingleton<IUrsaDialogService, UrsaDialogService>();
}
public static void RegisterUrsaDialogView<T>(this IContainerRegistry containerRegistry, string name) where T : Control

View File

@@ -0,0 +1,22 @@
using Avalonia.Controls;
using Prism.Ioc;
using Ursa.Controls;
using Ursa.Controls.Options;
namespace Ursa.PrismExtension;
public class UrsaDrawerService(IContainerExtension container): IUrsaDrawerService
{
public Task<DialogResult> ShowDrawer(string viewName, object? vm, string? hostId = null, DefaultDrawerOptions? options = null)
{
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
return Drawer.Show(v, vm, hostId, options);
}
public Task<TResult?> ShowCustomDrawer<TResult>(string viewName, object? vm, string? hostId = null,
CustomDrawerOptions? options = null)
{
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
return Drawer.ShowCustom<TResult?>(v, vm, hostId, options);
}
}