|
@@ -23,6 +23,14 @@ public interface IPopupViewModel
|
|
bool IsClosed { get; }
|
|
bool IsClosed { get; }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/// <summary>
|
|
|
|
+/// Indicates that this view model can be a module or a popup.
|
|
|
|
+/// </summary>
|
|
|
|
+public interface IDualFunctionViewModel : IPopupViewModel, IViewModelBase
|
|
|
|
+{
|
|
|
|
+ bool IsPopup { get; set; }
|
|
|
|
+}
|
|
|
|
+
|
|
public interface IPopupViewModel<TResult> : IPopupViewModel
|
|
public interface IPopupViewModel<TResult> : IPopupViewModel
|
|
{
|
|
{
|
|
TResult? GetResult();
|
|
TResult? GetResult();
|
|
@@ -59,6 +67,10 @@ public static class Navigation
|
|
public static async Task<object?> Popup<T>(T viewModel, bool canTapAway = true)
|
|
public static async Task<object?> Popup<T>(T viewModel, bool canTapAway = true)
|
|
where T : IViewModelBase, IPopupViewModel
|
|
where T : IViewModelBase, IPopupViewModel
|
|
{
|
|
{
|
|
|
|
+ if (viewModel is IDualFunctionViewModel dualFunction)
|
|
|
|
+ {
|
|
|
|
+ dualFunction.IsPopup = true;
|
|
|
|
+ }
|
|
await viewModel.Activate();
|
|
await viewModel.Activate();
|
|
var _result = await DialogHostAvalonia.DialogHost.Show(viewModel, (object sender, DialogClosingEventArgs eventArgs) =>
|
|
var _result = await DialogHostAvalonia.DialogHost.Show(viewModel, (object sender, DialogClosingEventArgs eventArgs) =>
|
|
{
|
|
{
|
|
@@ -81,6 +93,10 @@ public static class Navigation
|
|
public static async Task<TResult?> Popup<T, TResult>(T viewModel, bool canTapAway = true)
|
|
public static async Task<TResult?> Popup<T, TResult>(T viewModel, bool canTapAway = true)
|
|
where T : IViewModelBase, IPopupViewModel<TResult>
|
|
where T : IViewModelBase, IPopupViewModel<TResult>
|
|
{
|
|
{
|
|
|
|
+ if (viewModel is IDualFunctionViewModel dualFunction)
|
|
|
|
+ {
|
|
|
|
+ dualFunction.IsPopup = true;
|
|
|
|
+ }
|
|
await viewModel.Activate();
|
|
await viewModel.Activate();
|
|
var _result = await DialogHostAvalonia.DialogHost.Show(viewModel, (object sender, DialogClosingEventArgs eventArgs) =>
|
|
var _result = await DialogHostAvalonia.DialogHost.Show(viewModel, (object sender, DialogClosingEventArgs eventArgs) =>
|
|
{
|
|
{
|