Added NavBarItemSelectionMode
MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/AddWalletPageViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/AddWalletPageViewModel.cs
@@ -23,8 +23,8 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
private string _walletName = "";
private bool _optionsEnabled;
- public AddWalletPageViewModel(NavigationStateViewModel navigationState, LegalDocuments legalDocuments, WalletManager walletManager,
- BitcoinStore store, Network network) : base(navigationState, NavigationTarget.DialogScreen)
+ public AddWalletPageViewModel(NavigationStateViewModel navigationState, LegalDocuments legalDocuments, WalletManager walletManager, BitcoinStore store, Network network)
+ : base(navigationState, NavigationTarget.DialogScreen, NavBarItemSelectionMode.Button)
{
Title = "Add Wallet";

MODIFY
WalletWasabi.Fluent/ViewModels/HomePageViewModel.cs
WalletWasabi.Fluent/ViewModels/HomePageViewModel.cs
@@ -15,7 +15,8 @@ namespace WalletWasabi.Fluent.ViewModels
{
private readonly ReadOnlyObservableCollection<NavBarItemViewModel> _items;
- public HomePageViewModel(NavigationStateViewModel navigationState, WalletManagerViewModel walletManager, AddWalletPageViewModel addWalletPage) : base(navigationState, NavigationTarget.HomeScreen)
+ public HomePageViewModel(NavigationStateViewModel navigationState, WalletManagerViewModel walletManager, AddWalletPageViewModel addWalletPage)
+ : base(navigationState, NavigationTarget.HomeScreen, NavBarItemSelectionMode.Selected)
{
Title = "Home";

MODIFY
WalletWasabi.Fluent/ViewModels/NavBar/NavBarItemViewModel.cs
WalletWasabi.Fluent/ViewModels/NavBar/NavBarItemViewModel.cs
@@ -4,15 +4,23 @@ using WalletWasabi.Fluent.ViewModels.Navigation;
namespace WalletWasabi.Fluent.ViewModels.NavBar
{
+ public enum NavBarItemSelectionMode
+ {
+ Selected = 0,
+ Button = 1,
+ Toggle = 2
+ }
+
public abstract class NavBarItemViewModel : RoutableViewModel
{
private bool _isSelected;
private bool _isExpanded;
private string _title;
- protected NavBarItemViewModel(NavigationStateViewModel navigationState, NavigationTarget navigationTarget) : base(navigationState, navigationTarget)
+ protected NavBarItemViewModel(NavigationStateViewModel navigationState, NavigationTarget navigationTarget, NavBarItemSelectionMode mode) : base(navigationState, navigationTarget)
{
_title = "";
+ Mode = mode;
OpenCommand = ReactiveCommand.Create(NavigateToSelf);
}
@@ -20,6 +28,8 @@ namespace WalletWasabi.Fluent.ViewModels.NavBar
public abstract string IconName { get; }
+ public NavBarItemSelectionMode Mode { get; }
+
public bool IsExpanded
{
get => _isExpanded;
@@ -46,6 +56,10 @@ namespace WalletWasabi.Fluent.ViewModels.NavBar
set => this.RaiseAndSetIfChanged(ref _isSelected, value);
}
+ public virtual void Toggle()
+ {
+ }
+
public ICommand OpenCommand { get; protected set; }
}
}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/ViewModels/NavBar/NavBarViewModel.cs
WalletWasabi.Fluent/ViewModels/NavBar/NavBarViewModel.cs
@@ -117,7 +117,12 @@ namespace WalletWasabi.Fluent.ViewModels.NavBar
private void SetSelectedItem(NavBarItemViewModel? value)
{
- if (_selectedItem != value)
+ if (_selectedItem == value)
+ {
+ return;
+ }
+
+ if (value is null || value.Mode == NavBarItemSelectionMode.Selected)
{
if (_selectedItem is { })
{
@@ -151,6 +156,16 @@ namespace WalletWasabi.Fluent.ViewModels.NavBar
}
}
}
+
+ if (value is not null && value.Mode == NavBarItemSelectionMode.Button)
+ {
+ NavigateItem(value);
+ }
+
+ if (value is not null && value.Mode == NavBarItemSelectionMode.Toggle)
+ {
+ value.Toggle();
+ }
}
private void SelectItem(NavBarItemViewModel x, WalletManagerViewModel walletManager)
@@ -160,7 +175,7 @@ namespace WalletWasabi.Fluent.ViewModels.NavBar
if (!_isNavigating)
{
_isNavigating = true;
- SelectedItem = x;
+ SetSelectedItem(x);
_isNavigating = false;
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/Search/SearchItemViewModel.cs
WalletWasabi.Fluent/ViewModels/Search/SearchItemViewModel.cs
@@ -16,7 +16,8 @@ namespace WalletWasabi.Fluent.ViewModels.Search
string iconName,
NavigationStateViewModel navigationState,
NavigationTarget navigationTarget,
- Func<RoutableViewModel> createTargetView) : base(navigationState, navigationTarget)
+ Func<RoutableViewModel> createTargetView)
+ : base(navigationState, navigationTarget, NavBarItemSelectionMode.Button)
{
Title = title;
Caption = caption;

MODIFY
WalletWasabi.Fluent/ViewModels/Search/SearchPageViewModel.cs
WalletWasabi.Fluent/ViewModels/Search/SearchPageViewModel.cs
@@ -21,7 +21,8 @@ namespace WalletWasabi.Fluent.ViewModels.Search
private readonly bool _showSettings;
private readonly bool _showWallets;
- public SearchPageViewModel(NavigationStateViewModel navigationState, WalletManagerViewModel walletManager, AddWalletPageViewModel addWalletPage, SettingsPageViewModel settingsPage, HomePageViewModel homePage) : base(navigationState, NavigationTarget.HomeScreen)
+ public SearchPageViewModel(NavigationStateViewModel navigationState, WalletManagerViewModel walletManager, AddWalletPageViewModel addWalletPage, SettingsPageViewModel settingsPage, HomePageViewModel homePage)
+ : base(navigationState, NavigationTarget.HomeScreen, NavBarItemSelectionMode.Selected)
{
Title = "Search";

MODIFY
WalletWasabi.Fluent/ViewModels/Settings/SettingsPageViewModel.cs
WalletWasabi.Fluent/ViewModels/Settings/SettingsPageViewModel.cs
@@ -48,7 +48,8 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
private Global Global;
- public SettingsPageViewModel(NavigationStateViewModel navigationState) : base(navigationState, NavigationTarget.HomeScreen)
+ public SettingsPageViewModel(NavigationStateViewModel navigationState)
+ : base(navigationState, NavigationTarget.HomeScreen, NavBarItemSelectionMode.Selected)
{
Title = "Settings";

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModelBase.cs
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModelBase.cs
@@ -17,7 +17,8 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
private CompositeDisposable? _disposables;
private bool _disposedValue;
- protected WalletViewModelBase(NavigationStateViewModel navigationState, Wallet wallet) : base(navigationState, NavigationTarget.HomeScreen)
+ protected WalletViewModelBase(NavigationStateViewModel navigationState, Wallet wallet)
+ : base(navigationState, NavigationTarget.HomeScreen, NavBarItemSelectionMode.Selected)
{
Wallet = Guard.NotNull(nameof(wallet), wallet);

Added NavBarItemSelectionMode