Use IsLoggedIn property
MODIFY
WalletWasabi.Fluent/ViewModels/NavBar/NavBarViewModel.cs
WalletWasabi.Fluent/ViewModels/NavBar/NavBarViewModel.cs
@@ -219,6 +219,9 @@ namespace WalletWasabi.Fluent.ViewModels.NavBar
x.OpenCommand.Execute(default);
}
+ // TODO: TEMP
+ _walletManager.SelectionChanged(x);
+
CollapseOnClickAction?.Invoke();
_isNavigating = false;
}

MODIFY
WalletWasabi.Fluent/ViewModels/WalletManagerViewModel.cs
WalletWasabi.Fluent/ViewModels/WalletManagerViewModel.cs
@@ -17,8 +17,9 @@ namespace WalletWasabi.Fluent.ViewModels
public partial class WalletManagerViewModel : ViewModelBase
{
private readonly Dictionary<Wallet, WalletViewModelBase> _walletDictionary;
- private readonly Dictionary<WalletViewModel, List<NavBarItemViewModel>> _walletActionsDictionary;
+ private readonly Dictionary<WalletViewModelBase, List<NavBarItemViewModel>> _walletActionsDictionary;
[AutoNotify] private ViewModelBase? _selectedItem;
+ [AutoNotify] private bool _loggedInAndSelectedAlwaysFirst;
[AutoNotify] private ObservableCollection<NavBarItemViewModel> _items;
[AutoNotify] private ObservableCollection<WalletViewModelBase> _wallets;
[AutoNotify] private bool _anyWalletStarted;
@@ -28,9 +29,11 @@ namespace WalletWasabi.Fluent.ViewModels
Model = walletManager;
_walletDictionary = new Dictionary<Wallet, WalletViewModelBase>();
// TODO: TEMP
- _walletActionsDictionary = new Dictionary<WalletViewModel, List<NavBarItemViewModel>>();
+ _walletActionsDictionary = new Dictionary<WalletViewModelBase, List<NavBarItemViewModel>>();
_items = new ObservableCollection<NavBarItemViewModel>();
_wallets = new ObservableCollection<WalletViewModelBase>();
+ // TODO: TEMP
+ _loggedInAndSelectedAlwaysFirst = true;
Observable
.FromEventPattern<WalletState>(walletManager, nameof(WalletManager.WalletStateChanged))
@@ -84,8 +87,8 @@ namespace WalletWasabi.Fluent.ViewModels
var walletViewModel = OpenWallet(walletManager, uiConfig, closedWalletViewModel.Wallet);
// TODO: TEMP
- walletViewModel.Navigate().Clear();
- walletViewModel.Navigate(NavigationTarget.HomeScreen).To(walletViewModel);
+ // walletViewModel.Navigate().Clear();
+ // walletViewModel.Navigate(NavigationTarget.HomeScreen).To(walletViewModel);
// TODO: TEMP
// if (select)
@@ -105,26 +108,61 @@ namespace WalletWasabi.Fluent.ViewModels
InsertWallet(walletViewModel);
- if (!walletManager.AnyWallet(x => x.State >= WalletState.Started && x != walletViewModel.Wallet))
- {
- walletViewModel.OpenWalletTabs();
- }
+ // TODO: TEMP
+ // if (!walletManager.AnyWallet(x => x.State >= WalletState.Started && x != walletViewModel.Wallet))
+ // {
+ // walletViewModel.OpenWalletTabs();
+ // }
walletViewModel.IsExpanded = true;
return walletViewModel;
}
- private void OpenActions(WalletViewModel walletViewModel, List<NavBarItemViewModel> actions)
+ private void InsertWallet(WalletViewModelBase wallet)
+ {
+ _wallets.InsertSorted(wallet);
+
+ // TODO: Handle wallet Action being present in Items collection.
+ var index = _wallets.IndexOf(wallet);
+ if (index >= 0)
+ {
+ _items.Insert(index, wallet);
+ }
+
+ _walletDictionary.Add(wallet.Wallet, wallet);
+ }
+
+ private void RemoveWallet(WalletViewModelBase wallet)
+ {
+ wallet.Dispose();
+
+ _wallets.Remove(wallet);
+ _items.Remove(wallet);
+ // TODO: Remove wallet Actions
+
+ _walletDictionary.Remove(wallet.Wallet);
+ }
+
+ private void LoadWallets(WalletManager walletManager)
+ {
+ foreach (var wallet in walletManager.GetWallets())
+ {
+ InsertWallet(ClosedWalletViewModel.Create(walletManager, wallet));
+ }
+ }
+
+ private void OpenActions(WalletViewModelBase walletViewModel, List<NavBarItemViewModel> result)
{
// TODO: Insert current lodged in wallet at the top of the items list.
-#if true
+ if (_loggedInAndSelectedAlwaysFirst)
+ {
_items.Remove(walletViewModel);
_items.Insert(0, walletViewModel);
_wallets.Remove(walletViewModel);
_wallets.Insert(0, walletViewModel);
-#endif
+ }
// TODO: TEMP
var index = _wallets.IndexOf(walletViewModel);
@@ -136,58 +174,49 @@ namespace WalletWasabi.Fluent.ViewModels
{
var topSeparator = new SeparatorItemViewModel();
_items.Insert(index, topSeparator);
- actions.Add(topSeparator);
+ result.Add(topSeparator);
insertIndex += 1;
}
- for (var i = 0; i < walletViewModel.Actions.Count; i++)
+ var actions = GetWalletActions(walletViewModel);
+
+ for (var i = 0; i < actions.Count; i++)
{
- var action = walletViewModel.Actions[i];
+ var action = actions[i];
_items.Insert(insertIndex + i + 1, action);
- actions.Add(action);
+ result.Add(action);
}
// Add bottom separator only when wallet is not first or last item.
if (_wallets.Count > 1 && index != _wallets.Count - 1)
{
var bottomSeparator = new SeparatorItemViewModel();
- _items.Insert(insertIndex + walletViewModel.Actions.Count + 1, bottomSeparator);
- actions.Add(bottomSeparator);
+ _items.Insert(insertIndex + actions.Count + 1, bottomSeparator);
+ result.Add(bottomSeparator);
}
}
}
- private void InsertWallet(WalletViewModelBase wallet)
+ private List<WalletActionViewModel> GetWalletActions(WalletViewModelBase walletViewModel)
{
- _wallets.InsertSorted(wallet);
+ var wallet = walletViewModel.Wallet;
+ var actions = new List<WalletActionViewModel>();
- // TODO: Handle wallet Action being present in Items collection.
- var index = _wallets.IndexOf(wallet);
- if (index >= 0)
+ if (wallet.KeyManager.IsHardwareWallet || !wallet.KeyManager.IsWatchOnly)
{
- _items.Insert(index, wallet);
+ actions.Add(new SendWalletActionViewModel(walletViewModel));
}
- _walletDictionary.Add(wallet.Wallet, wallet);
- }
+ actions.Add(new ReceiveWalletActionViewModel(walletViewModel));
- private void RemoveWallet(WalletViewModelBase wallet)
+ if (!wallet.KeyManager.IsWatchOnly)
{
- wallet.Dispose();
-
- _wallets.Remove(wallet);
- _items.Remove(wallet);
- // TODO: Remove wallet Actions
-
- _walletDictionary.Remove(wallet.Wallet);
+ actions.Add(new CoinJoinWalletActionViewModel(walletViewModel));
}
- private void LoadWallets(WalletManager walletManager)
- {
- foreach (var wallet in walletManager.GetWallets())
- {
- InsertWallet(ClosedWalletViewModel.Create(walletManager, wallet));
- }
+ actions.Add(new AdvancedWalletActionViewModel(walletViewModel));
+
+ return actions;
}
public void SelectionChanged(NavBarItemViewModel item)
@@ -199,19 +228,19 @@ namespace WalletWasabi.Fluent.ViewModels
var previousItem = SelectedItem;
- if (previousItem is WalletViewModel walletViewModelPrevious && previousItem != item && item is not WalletActionViewModel)
+ if (previousItem is WalletViewModelBase walletViewModelPrevious && previousItem != item && item is not WalletActionViewModel && walletViewModelPrevious.Wallet.IsLoggedIn)
{
var actions = _walletActionsDictionary[walletViewModelPrevious];
foreach (var action in actions)
{
_items.Remove(action);
}
- actions.Clear();
+ // actions.Clear();
SelectedItem = null;
}
- if (item is WalletViewModel walletViewModelSelected)
+ if (item is WalletViewModelBase walletViewModelSelected && walletViewModelSelected.Wallet.IsLoggedIn)
{
SelectedItem = walletViewModelSelected;

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
@@ -19,13 +19,15 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
{
public partial class WalletViewModel : WalletViewModelBase
{
- [AutoNotify] private ObservableCollection<WalletActionViewModel> _actions;
+ // TODO: TEMP
+ // [AutoNotify] private ObservableCollection<WalletActionViewModel> _actions;
protected WalletViewModel(UiConfig uiConfig, Wallet wallet) : base(wallet)
{
Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");
- _actions = new ObservableCollection<WalletActionViewModel>();
+ // TODO: TEMP
+ // _actions = new ObservableCollection<WalletActionViewModel>();
uiConfig = Locator.Current.GetService<Global>().UiConfig;
@@ -52,7 +54,8 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
})
.DisposeWith(Disposables);
- if (Wallet.KeyManager.IsHardwareWallet || !Wallet.KeyManager.IsWatchOnly)
+ // TODO: TEMP
+ /*if (Wallet.KeyManager.IsHardwareWallet || !Wallet.KeyManager.IsWatchOnly)
{
_actions.Add(new SendWalletActionViewModel(this));
}
@@ -64,7 +67,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
_actions.Add(new CoinJoinWalletActionViewModel(this));
}
- _actions.Add(new AdvancedWalletActionViewModel(this));
+ _actions.Add(new AdvancedWalletActionViewModel(this));*/
}
private CompositeDisposable Disposables { get; set; }
@@ -80,9 +83,11 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
: new WalletViewModel(uiConfig, wallet);
}
+ // TODO: TEMP
+ /*
public void OpenWalletTabs()
{
// TODO: Implement.
- }
+ }*/
}
}

Use IsLoggedIn property