remove compareto logic and all navigatable vms take iscreen.
MODIFY
WalletWasabi.Fluent/ViewModels/ClosedWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/ClosedWalletViewModel.cs
@@ -21,11 +21,11 @@ namespace WalletWasabi.Fluent.ViewModels
set { this.RaiseAndSetIfChanged(ref _items, value); }
}
- protected ClosedWalletViewModel(WalletManager walletManager, Wallet wallet) : base(wallet)
+ protected ClosedWalletViewModel(IScreen screen, WalletManager walletManager, Wallet wallet) : base(screen, wallet)
{
_items = new ObservableCollection<NavBarItemViewModel>
{
- new HomePageViewModel()
+ new HomePageViewModel(screen)
};
IsExpanded = true;
@@ -57,13 +57,13 @@ namespace WalletWasabi.Fluent.ViewModels
public ReactiveCommand<Unit, Unit> OpenWalletCommand { get; }
- public static WalletViewModelBase Create(WalletManager walletManager, Wallet wallet)
+ public static WalletViewModelBase Create(IScreen screen, WalletManager walletManager, Wallet wallet)
{
return wallet.KeyManager.IsHardwareWallet
- ? new ClosedHardwareWalletViewModel(walletManager, wallet)
+ ? new ClosedHardwareWalletViewModel(screen, walletManager, wallet)
: wallet.KeyManager.IsWatchOnly
- ? new ClosedWatchOnlyWalletViewModel(walletManager, wallet)
- : new ClosedWalletViewModel(walletManager, wallet);
+ ? new ClosedWatchOnlyWalletViewModel(screen, walletManager, wallet)
+ : new ClosedWalletViewModel(screen, walletManager, wallet);
}
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/HomeViewModel.cs
WalletWasabi.Fluent/ViewModels/HomeViewModel.cs
@@ -2,11 +2,10 @@ using ReactiveUI;
namespace WalletWasabi.Fluent.ViewModels
{
- public class HomeViewModel : ViewModelBase
+ public class HomeViewModel : NavBarItemViewModel
{
- public HomeViewModel(IScreen screen)
+ public HomeViewModel(IScreen screen) : base (screen)
{
- HostScreen = screen;
}
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -20,7 +20,7 @@ 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(Router, global.WalletManager, global.UiConfig);
+ 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

MODIFY
WalletWasabi.Fluent/ViewModels/NavBarItemViewModel.cs
WalletWasabi.Fluent/ViewModels/NavBarItemViewModel.cs
using ReactiveUI;
using System;
-using System.Diagnostics.CodeAnalysis;
namespace WalletWasabi.Fluent.ViewModels
{
public class HomePageViewModel : NavBarItemViewModel
{
- public HomePageViewModel()
+ public HomePageViewModel(IScreen screen) : base(screen)
{
Title = "Home";
}
-
- public override int CompareTo([AllowNull] NavBarItemViewModel other)
- {
- return 0;
- }
}
public class SettingsPageViewModel : NavBarItemViewModel
{
- public SettingsPageViewModel()
+ public SettingsPageViewModel(IScreen screen) : base(screen)
{
Title = "Settings";
}
-
- public override int CompareTo([AllowNull] NavBarItemViewModel other)
- {
- return 0;
- }
}
public class AddWalletPageViewModel : NavBarItemViewModel
{
- public AddWalletPageViewModel()
+ public AddWalletPageViewModel(IScreen screen) : base(screen)
{
Title = "Add Wallet";
}
-
- public override int CompareTo([AllowNull] NavBarItemViewModel other)
- {
- return -1;
- }
}
- public abstract class NavBarItemViewModel : ViewModelBase, IComparable<NavBarItemViewModel>
+ public abstract class NavBarItemViewModel : ViewModelBase, IRoutableViewModel
{
private bool _isSelected;
private bool _isExpanded;
private string _title;
+ public NavBarItemViewModel(IScreen screen)
+ {
+ HostScreen = screen;
+ }
+
+ public string UrlPathSegment { get; } = Guid.NewGuid().ToString().Substring(0, 5);
+
+ public IScreen HostScreen { get; }
+
public bool IsExpanded
{
get => _isExpanded;
@@ -66,7 +59,5 @@ namespace WalletWasabi.Fluent.ViewModels
get { return _isSelected; }
set { this.RaiseAndSetIfChanged(ref _isSelected, value); }
}
-
- public abstract int CompareTo([AllowNull] NavBarItemViewModel other);
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/NavBarViewModel.cs
WalletWasabi.Fluent/ViewModels/NavBarViewModel.cs
@@ -13,26 +13,28 @@ namespace WalletWasabi.Fluent.ViewModels
{
public class NavBarViewModel : ViewModelBase
{
- private ObservableCollection<NavBarItemViewModel> _items;
+ private ObservableCollection<WalletViewModelBase> _items;
private ObservableCollection<NavBarItemViewModel> _topItems;
private ObservableCollection<NavBarItemViewModel> _bottomItems;
private NavBarItemViewModel _selectedItem;
private Dictionary<Wallet, WalletViewModelBase> _walletDictionary;
private bool _anyWalletStarted;
private bool _isBackButtonVisible;
+ private IScreen _screen;
- public NavBarViewModel(RoutingState router, WalletManager walletManager, UiConfig uiConfig)
+ public NavBarViewModel(IScreen screen, RoutingState router, WalletManager walletManager, UiConfig uiConfig)
{
+ _screen = screen;
Router = router;
_topItems = new ObservableCollection<NavBarItemViewModel>();
- _items = new ObservableCollection<NavBarItemViewModel>();
+ _items = new ObservableCollection<WalletViewModelBase>();
_bottomItems = new ObservableCollection<NavBarItemViewModel>();
_walletDictionary = new Dictionary<Wallet, WalletViewModelBase>();
- _topItems.Add(new HomePageViewModel());
- _bottomItems.Add(new AddWalletPageViewModel());
- _bottomItems.Add(new SettingsPageViewModel());
+ _topItems.Add(new HomePageViewModel(screen));
+ _bottomItems.Add(new AddWalletPageViewModel(screen));
+ _bottomItems.Add(new SettingsPageViewModel(screen));
Observable.FromEventPattern(Router.NavigationStack, nameof(Router.NavigationStack.CollectionChanged))
.ObserveOn(RxApp.MainThreadScheduler)
@@ -68,8 +70,8 @@ namespace WalletWasabi.Fluent.ViewModels
.Subscribe(wallet =>
{
WalletViewModelBase vm = (wallet.State <= WalletState.Starting)
- ? ClosedWalletViewModel.Create(walletManager, wallet)
- : WalletViewModel.Create(uiConfig, wallet);
+ ? ClosedWalletViewModel.Create(screen, walletManager, wallet)
+ : WalletViewModel.Create(screen, uiConfig, wallet);
InsertWallet(vm);
});
@@ -97,7 +99,7 @@ namespace WalletWasabi.Fluent.ViewModels
}
- public ObservableCollection<NavBarItemViewModel> Items
+ public ObservableCollection<WalletViewModelBase> Items
{
get { return _items; }
set { this.RaiseAndSetIfChanged(ref _items, value); }
@@ -144,7 +146,7 @@ namespace WalletWasabi.Fluent.ViewModels
{
foreach (var wallet in walletManager.GetWallets())
{
- InsertWallet(ClosedWalletViewModel.Create(walletManager, wallet));
+ InsertWallet(ClosedWalletViewModel.Create(_screen, walletManager, wallet));
}
}
@@ -169,7 +171,7 @@ namespace WalletWasabi.Fluent.ViewModels
throw new Exception("Wallet already opened.");
}
- var walletViewModel = WalletViewModel.Create(uiConfig, wallet);
+ var walletViewModel = WalletViewModel.Create(_screen, uiConfig, wallet);
InsertWallet(walletViewModel);

MODIFY
WalletWasabi.Fluent/ViewModels/ViewModelBase.cs
WalletWasabi.Fluent/ViewModels/ViewModelBase.cs
@@ -5,10 +5,8 @@ using ReactiveUI;
namespace WalletWasabi.Fluent.ViewModels
{
- public class ViewModelBase : ReactiveObject, IRoutableViewModel
+ public class ViewModelBase : ReactiveObject
{
- public string UrlPathSegment { get; } = Guid.NewGuid().ToString().Substring(0, 5);
- public IScreen HostScreen { get; set; }
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/WalletViewModelBase.cs
WalletWasabi.Fluent/ViewModels/WalletViewModelBase.cs
@@ -15,7 +15,7 @@ namespace WalletWasabi.Fluent.ViewModels
private CompositeDisposable _disposables;
private bool _disposedValue;
- public WalletViewModelBase(Wallet wallet)
+ public WalletViewModelBase(IScreen screen, Wallet wallet) : base(screen)
{
Wallet = Guard.NotNull(nameof(wallet), wallet);
@@ -63,18 +63,6 @@ namespace WalletWasabi.Fluent.ViewModels
return Title.CompareTo(other.Title);
}
- public override int CompareTo([AllowNull] NavBarItemViewModel other)
- {
- if (other is WalletViewModelBase wvmb)
- {
- return CompareTo(wvmb);
- }
- else
- {
- return -1;
- }
- }
-
public override string ToString() => WalletName;
#region IDisposable Support

remove compareto logic and all navigatable vms take iscreen.