Added GetRouter method
MODIFY
WalletWasabi.Fluent/ViewModels/RoutableViewModel.cs
WalletWasabi.Fluent/ViewModels/RoutableViewModel.cs
@@ -94,7 +94,7 @@ namespace WalletWasabi.Fluent.ViewModels
public void NavigateToSelfAndReset() => NavigateTo(this, NavigationTarget, true);
- public void GoBack(NavigationTarget navigationTarget)
+ private RoutingState? GetRouter(NavigationTarget navigationTarget)
{
var router = default(RoutingState);
@@ -110,52 +110,45 @@ namespace WalletWasabi.Fluent.ViewModels
break;
}
- if (router is not null)
+ return router;
+ }
+
+ private void CloseDialogs(IEnumerable<IRoutableViewModel> navigationStack)
+ {
+ foreach (var routable in navigationStack)
{
// Close all dialogs so the awaited tasks can complete.
// - DialogViewModelBase.ShowDialogAsync()
// - DialogViewModelBase.GetDialogResultAsync()
- if (router.NavigationStack.LastOrDefault() is DialogViewModelBase dialog)
+ if (routable is DialogViewModelBase dialog)
{
dialog.IsDialogOpen = false;
}
-
- router.NavigateBack.Execute();
}
}
- public void GoBack() => GoBack(NavigationTarget);
-
- private void CloseDialogs(IEnumerable<IRoutableViewModel> navigationStack)
+ public void GoBack(NavigationTarget navigationTarget)
{
- foreach (var routable in navigationStack)
+ var router = GetRouter(navigationTarget);
+ if (router is not null)
{
// Close all dialogs so the awaited tasks can complete.
// - DialogViewModelBase.ShowDialogAsync()
// - DialogViewModelBase.GetDialogResultAsync()
- if (routable is DialogViewModelBase dialog)
+ if (router.NavigationStack.LastOrDefault() is DialogViewModelBase dialog)
{
dialog.IsDialogOpen = false;
}
+
+ router.NavigateBack.Execute();
}
}
- public void ClearNavigation(NavigationTarget navigationTarget)
- {
- var router = default(RoutingState);
+ public void GoBack() => GoBack(NavigationTarget);
- switch (navigationTarget)
+ public void ClearNavigation(NavigationTarget navigationTarget)
{
- case NavigationTarget.Default:
- case NavigationTarget.HomeScreen:
- router = NavigationState.HomeScreen.Invoke().Router;
- break;
-
- case NavigationTarget.DialogScreen:
- router = NavigationState.DialogScreen.Invoke().Router;
- break;
- }
-
+ var router = GetRouter(navigationTarget);
if (router is not null)
{
if (router.NavigationStack.Count >= 1)

Added GetRouter method