Added NavigationState implementation
MODIFY
WalletWasabi.Fluent/ViewModels/AddWalletPageViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWalletPageViewModel.cs
@@ -4,7 +4,7 @@ namespace WalletWasabi.Fluent.ViewModels
{
public class AddWalletPageViewModel : NavBarItemViewModel
{
- public AddWalletPageViewModel(IScreen screen) : base(screen)
+ public AddWalletPageViewModel(NavigationStateViewModel navigationState) : base(navigationState)
{
Title = "Add Wallet";
}

MODIFY
WalletWasabi.Fluent/ViewModels/ClosedHardwareWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/ClosedHardwareWalletViewModel.cs
@@ -5,7 +5,7 @@ namespace WalletWasabi.Fluent.ViewModels
{
public class ClosedHardwareWalletViewModel : ClosedWalletViewModel
{
- internal ClosedHardwareWalletViewModel(IScreen screen, WalletManager walletManager, Wallet wallet) : base(screen, walletManager, wallet)
+ internal ClosedHardwareWalletViewModel(NavigationStateViewModel navigationState, WalletManager walletManager, Wallet wallet) : base(navigationState, walletManager, wallet)
{
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/ClosedWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/ClosedWalletViewModel.cs
@@ -15,11 +15,11 @@ namespace WalletWasabi.Fluent.ViewModels
{
private ObservableCollection<NavBarItemViewModel> _items;
- protected ClosedWalletViewModel(IScreen screen, WalletManager walletManager, Wallet wallet) : base(screen, wallet)
+ protected ClosedWalletViewModel(NavigationStateViewModel navigationState, WalletManager walletManager, Wallet wallet) : base(navigationState, wallet)
{
_items = new ObservableCollection<NavBarItemViewModel>
{
- new HomePageViewModel(screen) { Parent = this }
+ new HomePageViewModel(navigationState) { Parent = this }
};
OpenWalletCommand = ReactiveCommand.CreateFromTask(
@@ -57,13 +57,13 @@ namespace WalletWasabi.Fluent.ViewModels
public override string IconName => "web_asset_regular";
- public static WalletViewModelBase Create(IScreen screen, WalletManager walletManager, Wallet wallet)
+ public static WalletViewModelBase Create(NavigationStateViewModel navigationState, WalletManager walletManager, Wallet wallet)
{
return wallet.KeyManager.IsHardwareWallet
- ? new ClosedHardwareWalletViewModel(screen, walletManager, wallet)
+ ? new ClosedHardwareWalletViewModel(navigationState, walletManager, wallet)
: wallet.KeyManager.IsWatchOnly
- ? new ClosedWatchOnlyWalletViewModel(screen, walletManager, wallet)
- : new ClosedWalletViewModel(screen, walletManager, wallet);
+ ? new ClosedWatchOnlyWalletViewModel(navigationState, walletManager, wallet)
+ : new ClosedWalletViewModel(navigationState, walletManager, wallet);
}
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/ClosedWatchOnlyWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/ClosedWatchOnlyWalletViewModel.cs
@@ -5,7 +5,7 @@ namespace WalletWasabi.Fluent.ViewModels
{
public class ClosedWatchOnlyWalletViewModel : ClosedWalletViewModel
{
- internal ClosedWatchOnlyWalletViewModel(IScreen screen, WalletManager walletManager, Wallet wallet) : base(screen, walletManager, wallet)
+ internal ClosedWatchOnlyWalletViewModel(NavigationStateViewModel navigationState, WalletManager walletManager, Wallet wallet) : base(navigationState, walletManager, wallet)
{
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/Dialogs/TestDialogViewModel.cs
WalletWasabi.Fluent/ViewModels/Dialogs/TestDialogViewModel.cs
@@ -5,12 +5,12 @@ namespace WalletWasabi.Fluent.ViewModels.Dialogs
{
public class TestDialogViewModel : DialogViewModelBase<bool>
{
- private IScreen _screen;
+ private NavigationStateViewModel _navigationState;
private string _message;
- public TestDialogViewModel(IScreen screen, string message)
+ public TestDialogViewModel(NavigationStateViewModel navigationState, string message)
{
- _screen = screen;
+ _navigationState = navigationState;
_message = message;
CancelCommand = ReactiveCommand.Create(() => Close(false));
@@ -28,7 +28,7 @@ namespace WalletWasabi.Fluent.ViewModels.Dialogs
protected override void OnDialogClosed()
{
- _screen.Router.NavigateAndReset.Execute(new HomePageViewModel(_screen));
+ _navigationState.Screen().Router.NavigateAndReset.Execute(new HomePageViewModel(_navigationState));
}
public void Close()

MODIFY
WalletWasabi.Fluent/ViewModels/HardwareWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/HardwareWalletViewModel.cs
@@ -6,7 +6,7 @@ namespace WalletWasabi.Fluent.ViewModels
{
public class HardwareWalletViewModel : WalletViewModel
{
- internal HardwareWalletViewModel(IScreen screen, UiConfig uiConfig, Wallet wallet) : base(screen, uiConfig, wallet)
+ internal HardwareWalletViewModel(NavigationStateViewModel navigationState, UiConfig uiConfig, Wallet wallet) : base(navigationState, uiConfig, wallet)
{
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/HomePageViewModel.cs
WalletWasabi.Fluent/ViewModels/HomePageViewModel.cs
@@ -4,7 +4,7 @@ namespace WalletWasabi.Fluent.ViewModels
{
public class HomePageViewModel : NavBarItemViewModel
{
- public HomePageViewModel(IScreen screen) : base(screen)
+ public HomePageViewModel(NavigationStateViewModel navigationState) : base(navigationState)
{
Title = "Home";
}

MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -11,6 +11,7 @@ namespace WalletWasabi.Fluent.ViewModels
public class MainViewModel : ViewModelBase, IScreen, IDialogHost
{
private Global _global;
+ private NavigationStateViewModel _navigationState;
private StatusBarViewModel _statusBar;
private string _title = "Wasabi Wallet";
private DialogViewModelBase _currentDialog;
@@ -19,11 +20,20 @@ namespace WalletWasabi.Fluent.ViewModels
{
_global = global;
+ _navigationState = new NavigationStateViewModel()
+ {
+ Screen = () => this,
+ // TODO: Add IScreen implementation to Dialog from main view
+ Dialog = () => this
+ // TODO: NextView
+ // TODO: CancelView
+ };
+
Network = global.Network;
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);
+ NavBar = new NavBarViewModel(_navigationState, Router, global.WalletManager, global.UiConfig);
}
public static MainViewModel Instance { get; internal set; }

MODIFY
WalletWasabi.Fluent/ViewModels/NavBarItemViewModel.cs
WalletWasabi.Fluent/ViewModels/NavBarItemViewModel.cs
@@ -4,15 +4,17 @@ using WalletWasabi.Gui.ViewModels;
namespace WalletWasabi.Fluent.ViewModels
{
+
public abstract class NavBarItemViewModel : ViewModelBase, IRoutableViewModel
{
+ private NavigationStateViewModel _navigationState;
private bool _isSelected;
private bool _isExpanded;
private string _title;
- public NavBarItemViewModel(IScreen screen)
+ public NavBarItemViewModel(NavigationStateViewModel navigationState)
{
- HostScreen = screen;
+ _navigationState = navigationState;
}
public NavBarItemViewModel Parent { get; set; }
@@ -21,7 +23,7 @@ namespace WalletWasabi.Fluent.ViewModels
public string UrlPathSegment { get; } = Guid.NewGuid().ToString().Substring(0, 5);
- public IScreen HostScreen { get; }
+ public IScreen HostScreen => _navigationState.Screen();
public bool IsExpanded
{

MODIFY
WalletWasabi.Fluent/ViewModels/NavBarViewModel.cs
WalletWasabi.Fluent/ViewModels/NavBarViewModel.cs
@@ -24,16 +24,16 @@ namespace WalletWasabi.Fluent.ViewModels
private Dictionary<Wallet, WalletViewModelBase> _walletDictionary;
private bool _anyWalletStarted;
private bool _isBackButtonVisible;
- private IScreen _screen;
+ private NavigationStateViewModel _navigationState;
private bool _isNavigating;
private bool _isOpen;
private Action _toggleAction;
private Action _collapseOnClickAction;
- public NavBarViewModel(IScreen screen, RoutingState router, WalletManager walletManager, UiConfig uiConfig)
+ public NavBarViewModel(NavigationStateViewModel navigationState, RoutingState router, WalletManager walletManager, UiConfig uiConfig)
{
- _screen = screen;
+ _navigationState = navigationState;
Router = router;
_topItems = new ObservableCollection<NavBarItemViewModel>();
_items = new ObservableCollection<WalletViewModelBase>();
@@ -41,10 +41,10 @@ namespace WalletWasabi.Fluent.ViewModels
_walletDictionary = new Dictionary<Wallet, WalletViewModelBase>();
- SelectedItem = new HomePageViewModel(screen);
+ SelectedItem = new HomePageViewModel(_navigationState);
_topItems.Add(_selectedItem);
- _bottomItems.Add(new AddWalletPageViewModel(screen));
- _bottomItems.Add(new SettingsPageViewModel(screen));
+ _bottomItems.Add(new AddWalletPageViewModel(_navigationState));
+ _bottomItems.Add(new SettingsPageViewModel(_navigationState));
Router.CurrentViewModel
.OfType<NavBarItemViewModel>()
@@ -109,8 +109,8 @@ namespace WalletWasabi.Fluent.ViewModels
.Subscribe(wallet =>
{
WalletViewModelBase vm = (wallet.State <= WalletState.Starting)
- ? ClosedWalletViewModel.Create(screen, walletManager, wallet)
- : WalletViewModel.Create(screen, uiConfig, wallet);
+ ? ClosedWalletViewModel.Create(_navigationState, walletManager, wallet)
+ : WalletViewModel.Create(_navigationState, uiConfig, wallet);
InsertWallet(vm);
});
@@ -226,7 +226,7 @@ namespace WalletWasabi.Fluent.ViewModels
{
foreach (var wallet in walletManager.GetWallets())
{
- InsertWallet(ClosedWalletViewModel.Create(_screen, walletManager, wallet));
+ InsertWallet(ClosedWalletViewModel.Create(_navigationState, walletManager, wallet));
}
}
@@ -251,7 +251,7 @@ namespace WalletWasabi.Fluent.ViewModels
throw new Exception("Wallet already opened.");
}
- var walletViewModel = WalletViewModel.Create(_screen, uiConfig, wallet);
+ var walletViewModel = WalletViewModel.Create(_navigationState, uiConfig, wallet);
InsertWallet(walletViewModel);

MODIFY
WalletWasabi.Fluent/ViewModels/SettingsPageViewModel.cs
WalletWasabi.Fluent/ViewModels/SettingsPageViewModel.cs
@@ -15,11 +15,11 @@ namespace WalletWasabi.Fluent.ViewModels
{
private string _randomString;
- public SettingsPageViewModel(IScreen screen) : base(screen)
+ public SettingsPageViewModel(NavigationStateViewModel navigationState) : base(navigationState)
{
Title = "Settings";
- NextCommand = ReactiveCommand.Create(() => screen.Router.Navigate.Execute(new HomePageViewModel(screen)));
+ NextCommand = ReactiveCommand.Create(() => navigationState.Screen().Router.Navigate.Execute(new HomePageViewModel(navigationState)));
OpenDialogCommand = ReactiveCommand.CreateFromTask(async () => await ConfirmSetting.Handle("Please confirm the setting:").ToTask());
@@ -28,7 +28,7 @@ namespace WalletWasabi.Fluent.ViewModels
ConfirmSetting.RegisterHandler(
async interaction =>
{
- var x = new TestDialogViewModel(screen, interaction.Input);
+ var x = new TestDialogViewModel(navigationState, interaction.Input);
var result = await x.ShowDialogAsync(MainViewModel.Instance);
interaction.SetOutput(result);
});

MODIFY
WalletWasabi.Fluent/ViewModels/WalletViewModel.cs
WalletWasabi.Fluent/ViewModels/WalletViewModel.cs
@@ -18,7 +18,7 @@ namespace WalletWasabi.Fluent.ViewModels
{
private ObservableCollection<ViewModelBase> _actions;
- protected WalletViewModel(IScreen screen, UiConfig uiConfig, Wallet wallet) : base(screen, wallet)
+ protected WalletViewModel(NavigationStateViewModel navigationState, UiConfig uiConfig, Wallet wallet) : base(navigationState, wallet)
{
Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");
@@ -67,13 +67,13 @@ namespace WalletWasabi.Fluent.ViewModels
public override string IconName => "web_asset_regular";
- public static WalletViewModel Create(IScreen screen, UiConfig uiConfig, Wallet wallet)
+ public static WalletViewModel Create(NavigationStateViewModel navigationState, UiConfig uiConfig, Wallet wallet)
{
return wallet.KeyManager.IsHardwareWallet
- ? new HardwareWalletViewModel(screen, uiConfig, wallet)
+ ? new HardwareWalletViewModel(navigationState, uiConfig, wallet)
: wallet.KeyManager.IsWatchOnly
- ? new WatchOnlyWalletViewModel(screen, uiConfig, wallet)
- : new WalletViewModel(screen, uiConfig, wallet);
+ ? new WatchOnlyWalletViewModel(navigationState, uiConfig, wallet)
+ : new WalletViewModel(navigationState, uiConfig, wallet);
}
public void OpenWalletTabs()

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(IScreen screen, Wallet wallet) : base(screen)
+ public WalletViewModelBase(NavigationStateViewModel navigationState, Wallet wallet) : base(navigationState)
{
Wallet = Guard.NotNull(nameof(wallet), wallet);

MODIFY
WalletWasabi.Fluent/ViewModels/WatchOnlyWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/WatchOnlyWalletViewModel.cs
@@ -6,7 +6,7 @@ namespace WalletWasabi.Fluent.ViewModels
{
public class WatchOnlyWalletViewModel : WalletViewModel
{
- internal WatchOnlyWalletViewModel(IScreen screen, UiConfig uiConfig, Wallet wallet) : base(screen, uiConfig, wallet)
+ internal WatchOnlyWalletViewModel(NavigationStateViewModel navigationState, UiConfig uiConfig, Wallet wallet) : base(navigationState, uiConfig, wallet)
{
}
}

Added NavigationState implementation