feat: add prism extension.
This commit is contained in:
6
Ursa.sln
6
Ursa.sln
@@ -16,6 +16,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ursa.Demo.iOS", "demo\Ursa.
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ursa.Demo.Browser", "demo\Ursa.Demo.Browser\Ursa.Demo.Browser.csproj", "{D1942476-8473-4608-BB9F-5AC01083BBDA}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ursa.Demo.Browser", "demo\Ursa.Demo.Browser\Ursa.Demo.Browser.csproj", "{D1942476-8473-4608-BB9F-5AC01083BBDA}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ursa.PrismExtension", "src\Ursa.PrismExtension\Ursa.PrismExtension.csproj", "{2E934F60-F5DF-4856-B05A-B949C7F9D948}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -50,6 +52,10 @@ Global
|
|||||||
{D1942476-8473-4608-BB9F-5AC01083BBDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{D1942476-8473-4608-BB9F-5AC01083BBDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{D1942476-8473-4608-BB9F-5AC01083BBDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{D1942476-8473-4608-BB9F-5AC01083BBDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{D1942476-8473-4608-BB9F-5AC01083BBDA}.Release|Any CPU.Build.0 = Release|Any CPU
|
{D1942476-8473-4608-BB9F-5AC01083BBDA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{2E934F60-F5DF-4856-B05A-B949C7F9D948}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{2E934F60-F5DF-4856-B05A-B949C7F9D948}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{2E934F60-F5DF-4856-B05A-B949C7F9D948}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{2E934F60-F5DF-4856-B05A-B949C7F9D948}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{407A91FD-A88B-459B-8DCE-8C6AA98279FE} = {A41BAF0D-DA61-4A63-889A-084BAD36FD66}
|
{407A91FD-A88B-459B-8DCE-8C6AA98279FE} = {A41BAF0D-DA61-4A63-889A-084BAD36FD66}
|
||||||
|
|||||||
7
global.json
Normal file
7
global.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"sdk": {
|
||||||
|
"version": "8.0.0",
|
||||||
|
"rollForward": "latestMajor",
|
||||||
|
"allowPrerelease": false
|
||||||
|
}
|
||||||
|
}
|
||||||
6
src/Ursa.PrismExtension/IUrsaDialogService.cs
Normal file
6
src/Ursa.PrismExtension/IUrsaDialogService.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Ursa.PrismExtension;
|
||||||
|
|
||||||
|
public interface IUrsaDialogService
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
6
src/Ursa.PrismExtension/IUrsaOverlayDialogService.cs
Normal file
6
src/Ursa.PrismExtension/IUrsaOverlayDialogService.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Ursa.PrismExtension;
|
||||||
|
|
||||||
|
public class IUrsaOverlayDialogService
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
18
src/Ursa.PrismExtension/Ursa.PrismExtension.csproj
Normal file
18
src/Ursa.PrismExtension/Ursa.PrismExtension.csproj
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Ursa\Ursa.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Prism.Core" Version="8.1.97" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
26
src/Ursa.PrismExtension/UrsaDialogService.cs
Normal file
26
src/Ursa.PrismExtension/UrsaDialogService.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Prism.Ioc;
|
||||||
|
using Ursa.Controls;
|
||||||
|
|
||||||
|
namespace Ursa.PrismExtension;
|
||||||
|
|
||||||
|
public class UrsaDialogService(IContainerExtension container) : IUrsaDialogService
|
||||||
|
{
|
||||||
|
public void ShowCustom(string viewName, object? vm, Window? owner = null, DialogOptions? options = null)
|
||||||
|
{
|
||||||
|
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
|
||||||
|
Dialog.ShowCustom(v, vm, owner, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<DialogResult> ShowModal(string viewName, object? vm, Window? owner = null, DialogOptions? options = null)
|
||||||
|
{
|
||||||
|
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
|
||||||
|
return Dialog.ShowModal(v, vm, owner, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<TResult?> ShowCustomModal<TResult>(string viewName, object? vm, Window? owner = null, DialogOptions? options = null)
|
||||||
|
{
|
||||||
|
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
|
||||||
|
return Dialog.ShowCustomModal<TResult>(v, vm, owner, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/Ursa.PrismExtension/UrsaDialogServiceExtension.cs
Normal file
20
src/Ursa.PrismExtension/UrsaDialogServiceExtension.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Prism.Ioc;
|
||||||
|
|
||||||
|
namespace Ursa.PrismExtension;
|
||||||
|
|
||||||
|
public static class UrsaDialogServiceExtension
|
||||||
|
{
|
||||||
|
internal const string UrsaDialogViewPrefix = "URSA_DIALOG_VIEW_";
|
||||||
|
|
||||||
|
public static void RegisterDialogService(this IContainerRegistry containerRegistry)
|
||||||
|
{
|
||||||
|
containerRegistry.RegisterSingleton<IUrsaDialogService, UrsaDialogService>();
|
||||||
|
containerRegistry.RegisterSingleton<IUrsaOverlayDialogService, UrsaOverlayDialogService>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RegisterUrsaDialogView<T>(this IContainerRegistry containerRegistry, string name) where T : Control
|
||||||
|
{
|
||||||
|
containerRegistry.Register<Control, T>(UrsaDialogViewPrefix+name);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/Ursa.PrismExtension/UrsaOverlayDialogService.cs
Normal file
32
src/Ursa.PrismExtension/UrsaOverlayDialogService.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Prism.Ioc;
|
||||||
|
using Ursa.Controls;
|
||||||
|
|
||||||
|
namespace Ursa.PrismExtension;
|
||||||
|
|
||||||
|
public class UrsaOverlayDialogService(IContainerExtension container): IUrsaOverlayDialogService
|
||||||
|
{
|
||||||
|
public void Show(string viewName, object? vm, string? hostId = null, OverlayDialogOptions? options = null)
|
||||||
|
{
|
||||||
|
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
|
||||||
|
OverlayDialog.Show(v, vm, hostId, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowCustom(string viewName, object? vm, string? hostId = null, OverlayDialogOptions? options = null)
|
||||||
|
{
|
||||||
|
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
|
||||||
|
OverlayDialog.ShowCustom(v, vm, hostId, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<DialogResult> ShowModal(string viewName, object? vm, string? hostId = null, OverlayDialogOptions? options = null)
|
||||||
|
{
|
||||||
|
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
|
||||||
|
return OverlayDialog.ShowModal(v, vm, hostId, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<TResult?> ShowCustomModal<TResult>(string viewName, object? vm, string? hostId = null, OverlayDialogOptions? options = null)
|
||||||
|
{
|
||||||
|
var v = container.Resolve<Control>(UrsaDialogServiceExtension.UrsaDialogViewPrefix + viewName);
|
||||||
|
return OverlayDialog.ShowCustomModal<TResult>(v, vm, hostId, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user