Merge pull request #98 from irihitech/prism_drawer
feat: add prism drawer service.
This commit is contained in:
10
src/Ursa.PrismExtension/IUrsaDrawerService.cs
Normal file
10
src/Ursa.PrismExtension/IUrsaDrawerService.cs
Normal 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);
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ public static class UrsaDialogServiceExtension
|
|||||||
{
|
{
|
||||||
containerRegistry.RegisterSingleton<IUrsaDialogService, UrsaDialogService>();
|
containerRegistry.RegisterSingleton<IUrsaDialogService, UrsaDialogService>();
|
||||||
containerRegistry.RegisterSingleton<IUrsaOverlayDialogService, UrsaOverlayDialogService>();
|
containerRegistry.RegisterSingleton<IUrsaOverlayDialogService, UrsaOverlayDialogService>();
|
||||||
|
containerRegistry.RegisterSingleton<IUrsaDialogService, UrsaDialogService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RegisterUrsaDialogView<T>(this IContainerRegistry containerRegistry, string name) where T : Control
|
public static void RegisterUrsaDialogView<T>(this IContainerRegistry containerRegistry, string name) where T : Control
|
||||||
|
|||||||
22
src/Ursa.PrismExtension/UrsaDrawerService.cs
Normal file
22
src/Ursa.PrismExtension/UrsaDrawerService.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user