bring back search.
MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -60,13 +60,11 @@ namespace WalletWasabi.Fluent.ViewModels
_navBar = new NavBarViewModel(MainScreen, walletManager);
-
-
RegisterCategories(searchPage);
HomePageViewModel.Register(async () => await Task.FromResult(homePage));
- SearchPageViewModel.Register(async () => searchPage);
+ SearchPageViewModel.Register(async () => await Task.FromResult(searchPage));
PrivacyModeViewModel.Register(async ()=> await Task.FromResult(privacyMode));
AddWalletPageViewModel.Register(async () => await Task.FromResult(addWalletPage));

MODIFY
WalletWasabi.Fluent/ViewModels/Navigation/NavigationManager.cs
WalletWasabi.Fluent/ViewModels/Navigation/NavigationManager.cs
@@ -23,6 +23,11 @@ namespace WalletWasabi.Fluent.ViewModels.Navigation
public static void RegisterRoutable(NavigationMetaData metaData, Func<Task<RoutableViewModel>> generator)
{
+ if (metaData.Searchable && (metaData.Category is null || metaData.Title is null))
+ {
+ throw new Exception("Searchable entries must have both a Category and a Title");
+ }
+
if (!_navigationEntries.ContainsKey(metaData))
{
_navigationEntries.Add(metaData, generator);

MODIFY
WalletWasabi.Fluent/ViewModels/Search/SearchItemViewModel.cs
WalletWasabi.Fluent/ViewModels/Search/SearchItemViewModel.cs
using System;
using System.Threading.Tasks;
+using System.Windows.Input;
using ReactiveUI;
using WalletWasabi.Fluent.ViewModels.NavBar;
using WalletWasabi.Fluent.ViewModels.Navigation;
+using WalletWasabi.Gui.ViewModels;
namespace WalletWasabi.Fluent.ViewModels.Search
{
- public class SearchItemViewModel : NavBarItemViewModel
+ public class SearchItemViewModel : RoutableViewModel
{
+ private readonly NavigationMetaData _metaData;
+
public SearchItemViewModel(
- string title,
- string caption,
- int order,
- SearchCategory category,
- string keywords,
- string iconName,
- Func<Task<RoutableViewModel>> createTargetView)
+ NavigationMetaData metaData,
+ SearchCategory category)
{
- Title = title;
- Caption = caption;
- Order = order;
+ _metaData = metaData;
Category = category;
- Keywords = keywords;
- IconName = iconName;
- SelectionMode = NavBarItemSelectionMode.Button;
OpenCommand = ReactiveCommand.CreateFromTask(
async () =>
{
- var view = await createTargetView();
-
+ var view = await NavigationManager.MaterialiseViewModel(metaData);
Navigate(view.DefaultTarget).To(view);
});
}
- public override string IconName { get; }
+ public string Title => _metaData.Title;
- public string Caption { get; }
+ public string Caption => _metaData.Caption;
- public int Order { get; }
+ public int Order => _metaData.Order;
public SearchCategory Category { get; }
- public string Keywords { get; }
+ public string Keywords => _metaData.Keywords.ToString();
+
+ public ICommand OpenCommand { get; }
+
+ public string IconName => _metaData.IconName;
}
}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/ViewModels/Search/SearchPageViewModel.cs
WalletWasabi.Fluent/ViewModels/Search/SearchPageViewModel.cs
@@ -16,7 +16,6 @@ namespace WalletWasabi.Fluent.ViewModels.Search
[NavigationMetaData(Title = "Search", NavBarPosition = NavBarPosition.Bottom)]
public partial class SearchPageViewModel : NavBarItemViewModel
{
- private readonly bool _showWallets = false;
private readonly WalletManagerViewModel _walletManager;
private readonly Dictionary<string, SearchCategory> _categories;
private readonly Dictionary<SearchCategory, SourceList<SearchItemViewModel>> _categorySources;
@@ -40,12 +39,9 @@ namespace WalletWasabi.Fluent.ViewModels.Search
public void Initialise()
{
- if (_showWallets)
+ foreach (var metaData in NavigationManager.MetaData.Where(x => x.Searchable))
{
- _walletManager.Items
- .ToObservableChangeSet()
- .OnItemAdded(x => RegisterWalletSearchItem(0, x))
- .Subscribe();
+ RegisterSearchEntry(metaData);
}
var queryFilter = this.WhenValueChanged(t => t.SearchQuery)
@@ -90,25 +86,11 @@ namespace WalletWasabi.Fluent.ViewModels.Search
throw new Exception("Category already exists.");
}
- public SearchItemViewModel RegisterSearchEntry(
- string title,
- string caption,
- int order,
- string category,
- string keywords,
- string iconName,
- Func<Task<RoutableViewModel>> createTargetView)
+ private SearchItemViewModel RegisterSearchEntry(NavigationMetaData metaData)
{
- if (_categories.TryGetValue(category, out var searchCategory))
+ if (_categories.TryGetValue(metaData.Category, out var searchCategory))
{
- var result = new SearchItemViewModel(
- title,
- caption,
- order,
- searchCategory,
- keywords,
- iconName,
- createTargetView);
+ var result = new SearchItemViewModel(metaData, searchCategory);
_categorySources[searchCategory].Add(result);
@@ -131,17 +113,5 @@ namespace WalletWasabi.Fluent.ViewModels.Search
return true;
};
}
-
- private void RegisterWalletSearchItem(int order, WalletViewModelBase wallet)
- {
- RegisterSearchEntry(
- title: wallet.WalletName,
- caption: "",
- order: order,
- category: "Wallets",
- keywords: $"Wallet, {wallet.WalletName}",
- iconName: "web_asset_regular",
- createTargetView: async () => await Task.FromResult(wallet));
- }
}
}

bring back search.