sync navigation with navbar selection.
DELETE
WalletWasabi.Fluent/ViewModels/HomeViewModel.cs
-using ReactiveUI;
-
-namespace WalletWasabi.Fluent.ViewModels
-{
- public class HomeViewModel : NavBarItemViewModel
- {
- public HomeViewModel(IScreen screen) : base (screen)
- {
- }
- }
-}

MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -21,9 +21,6 @@ namespace WalletWasabi.Fluent.ViewModels
StatusBar = new StatusBarViewModel(global.DataDir, global.Network, global.Config, global.HostedServices, global.BitcoinStore.SmartHeaderChain, global.Synchronizer, global.LegalDocuments);
NavBar = new NavBarViewModel(this, Router, global.WalletManager, global.UiConfig);
-
- Router.Navigate.Execute(new HomeViewModel(this)); // for testing
- Router.Navigate.Execute(new HomeViewModel(this)); // for testing
}
public static MainViewModel Instance { get; internal set; }

MODIFY
WalletWasabi.Fluent/ViewModels/NavBarViewModel.cs
WalletWasabi.Fluent/ViewModels/NavBarViewModel.cs
@@ -21,6 +21,7 @@ namespace WalletWasabi.Fluent.ViewModels
private bool _anyWalletStarted;
private bool _isBackButtonVisible;
private IScreen _screen;
+ private bool _isNavigating;
public NavBarViewModel(IScreen screen, RoutingState router, WalletManager walletManager, UiConfig uiConfig)
{
@@ -32,10 +33,33 @@ namespace WalletWasabi.Fluent.ViewModels
_walletDictionary = new Dictionary<Wallet, WalletViewModelBase>();
- _topItems.Add(new HomePageViewModel(screen));
+ SelectedItem = new HomePageViewModel(screen);
+ _topItems.Add(_selectedItem);
_bottomItems.Add(new AddWalletPageViewModel(screen));
_bottomItems.Add(new SettingsPageViewModel(screen));
+ Router.CurrentViewModel
+ .OfType<NavBarItemViewModel>()
+ .Subscribe(x=>
+ {
+ if(_items.Contains(x) || _topItems.Contains(x) || _bottomItems.Contains(x))
+ {
+ _isNavigating = true;
+ SelectedItem = x;
+ _isNavigating = false;
+ }
+ });
+
+ this.WhenAnyValue(x => x.SelectedItem)
+ .OfType<IRoutableViewModel>()
+ .Subscribe(x =>
+ {
+ if (!_isNavigating)
+ {
+ Router.NavigateAndReset.Execute(x);
+ }
+ });
+
Observable.FromEventPattern(Router.NavigationStack, nameof(Router.NavigationStack.CollectionChanged))
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(_ => IsBackButtonVisible = Router.NavigationStack.Count > 1);
@@ -115,6 +139,8 @@ namespace WalletWasabi.Fluent.ViewModels
{
get { return _selectedItem; }
set
+ {
+ if (_selectedItem != value)
{
if (_selectedItem is { })
{
@@ -125,7 +151,9 @@ namespace WalletWasabi.Fluent.ViewModels
this.RaisePropertyChanged();
- this.RaiseAndSetIfChanged(ref _selectedItem, value);
+ _selectedItem = value;
+
+ this.RaisePropertyChanged();
if (_selectedItem is { })
{
@@ -133,6 +161,7 @@ namespace WalletWasabi.Fluent.ViewModels
}
}
}
+ }
public bool IsBackButtonVisible
{

RENAME
WalletWasabi.Fluent/Views/HomeView.axaml
WalletWasabi.Fluent/Views/HomePageView.axaml
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
- x:Class="WalletWasabi.Fluent.Views.HomeView">
+ x:Class="WalletWasabi.Fluent.Views.HomePageView">
<StackPanel HorizontalAlignment="Center"
VerticalAlignment="Center">
<TextBlock Text="Hi, I'm the first view!" />

RENAME
WalletWasabi.Fluent/Views/HomeView.axaml.cs
WalletWasabi.Fluent/Views/HomePageView.axaml.cs
@@ -6,14 +6,14 @@ using WalletWasabi.Fluent.ViewModels;
namespace WalletWasabi.Fluent.Views
{
- public class HomeView : UserControl, IViewFor<HomeViewModel>
+ public class HomePageView : UserControl, IViewFor<HomePageViewModel>
{
- public HomeView()
+ public HomePageView()
{
this.InitializeComponent();
}
- public HomeViewModel ViewModel { get; set; }
+ public HomePageViewModel ViewModel { get; set; }
object IViewFor.ViewModel { get; set; }

sync navigation with navbar selection.