Use auto properties
MODIFY
WalletWasabi.Fluent/ViewModels/RoutableViewModel.cs
WalletWasabi.Fluent/ViewModels/RoutableViewModel.cs
@@ -7,13 +7,11 @@ namespace WalletWasabi.Fluent.ViewModels
{
public abstract class RoutableViewModel : ViewModelBase, IRoutableViewModel
{
- private NavigationStateViewModel _navigationState;
- private NavigationTarget _navigationTarget;
-
protected RoutableViewModel(NavigationStateViewModel navigationState, NavigationTarget navigationTarget)
{
- _navigationState = navigationState;
- _navigationTarget = navigationTarget;
+ NavigationState = navigationState;
+
+ NigationTarget = navigationTarget;
BackCommand = ReactiveCommand.Create(() => GoBack());
@@ -22,38 +20,42 @@ namespace WalletWasabi.Fluent.ViewModels
public string UrlPathSegment { get; } = Guid.NewGuid().ToString().Substring(0, 5);
- public IScreen HostScreen => _navigationTarget switch
+ public IScreen HostScreen => NigationTarget switch
{
- NavigationTarget.DialogScreen => _navigationState.DialogScreen.Invoke(),
- _ => _navigationState.HomeScreen.Invoke(),
+ NavigationTarget.DialogScreen => NavigationState.DialogScreen.Invoke(),
+ _ => NavigationState.HomeScreen.Invoke(),
};
+ public NavigationStateViewModel NavigationState { get; }
+
+ public NavigationTarget NigationTarget { get; }
+
public void Navigate()
{
- switch (_navigationTarget)
+ switch (NigationTarget)
{
case NavigationTarget.Default:
case NavigationTarget.HomeScreen:
- _navigationState.HomeScreen.Invoke().Router.Navigate.Execute(this);
+ NavigationState.HomeScreen.Invoke().Router.Navigate.Execute(this);
break;
case NavigationTarget.DialogScreen:
- _navigationState.DialogScreen.Invoke().Router.Navigate.Execute(this);
+ NavigationState.DialogScreen.Invoke().Router.Navigate.Execute(this);
break;
}
}
public void NavigateAndReset()
{
- switch (_navigationTarget)
+ switch (NigationTarget)
{
case NavigationTarget.Default:
case NavigationTarget.HomeScreen:
- _navigationState.HomeScreen.Invoke().Router.NavigateAndReset.Execute(this);
+ NavigationState.HomeScreen.Invoke().Router.NavigateAndReset.Execute(this);
break;
case NavigationTarget.DialogScreen:
- _navigationState.DialogScreen.Invoke().Router.NavigateAndReset.Execute(this);
+ NavigationState.DialogScreen.Invoke().Router.NavigateAndReset.Execute(this);
break;
}
}
@@ -64,30 +66,30 @@ namespace WalletWasabi.Fluent.ViewModels
public void GoBack()
{
- switch (_navigationTarget)
+ switch (NigationTarget)
{
case NavigationTarget.Default:
case NavigationTarget.HomeScreen:
- _navigationState.HomeScreen.Invoke().Router.NavigateBack.Execute();
+ NavigationState.HomeScreen.Invoke().Router.NavigateBack.Execute();
break;
case NavigationTarget.DialogScreen:
- _navigationState.DialogScreen.Invoke().Router.NavigateBack.Execute();
+ NavigationState.DialogScreen.Invoke().Router.NavigateBack.Execute();
break;
}
}
public void ClearNavigation()
{
- switch (_navigationTarget)
+ switch (NigationTarget)
{
case NavigationTarget.Default:
case NavigationTarget.HomeScreen:
- _navigationState.HomeScreen.Invoke().Router.NavigationStack.Clear();
+ NavigationState.HomeScreen.Invoke().Router.NavigationStack.Clear();
break;
case NavigationTarget.DialogScreen:
- _navigationState.DialogScreen.Invoke().Router.NavigationStack.Clear();
+ NavigationState.DialogScreen.Invoke().Router.NavigationStack.Clear();
break;
}
}

Use auto properties