begginings of navigation manager registration.
MODIFY
WalletWasabi.Fluent/ViewModels/AboutViewModel.cs
WalletWasabi.Fluent/ViewModels/AboutViewModel.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Reactive;
using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;
+using System.Threading.Tasks;
using System.Windows.Input;
using ReactiveUI;
using WalletWasabi.Fluent.ViewModels.Dialogs;
@@ -27,6 +28,11 @@ namespace WalletWasabi.Fluent.ViewModels
[AutoNotify]
private bool _test;
+ public static void Register(Func<Task<RoutableViewModel>> createInstance)
+ {
+ NavigationManager.RegisterRoutable<AboutViewModel>(MetaData, createInstance);
+ }
+
public AboutViewModel()
{
OpenBrowserCommand = ReactiveCommand.CreateFromTask<string>(IoHelpers.OpenBrowserAsync);
@@ -37,8 +43,7 @@ namespace WalletWasabi.Fluent.ViewModels
var interaction = new Interaction<Unit, Unit>();
interaction.RegisterHandler(
async x =>
- x.SetOutput(
- await new AboutAdvancedInfoViewModel().ShowDialogAsync()));
+ x.SetOutput(await new AboutAdvancedInfoViewModel().ShowDialogAsync()));
AboutAdvancedInfoDialogCommand = ReactiveCommand.CreateFromTask(
execute: async () => await interaction.Handle(Unit.Default).ToTask());

MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -153,31 +153,18 @@ namespace WalletWasabi.Fluent.ViewModels
private static void RegisterEntries(SearchPageViewModel searchPage, LegalDocuments legalDocuments)
{
- searchPage.RegisterSearchEntry(
- title: "Legal Docs",
- caption: "Displays terms and conditions",
- order: 3,
- category: "General",
- keywords: "View, Legal, Docs, Documentation, Terms, Conditions, Help",
- iconName: "info_regular",
- createTargetView: async () =>
+ /*NavigationManager.RegisterRoutable<LegalDocumentsViewModel>(
+ LegalDocumentsViewModel.MetaData,
+ async () =>
{
var content = await File.ReadAllTextAsync(legalDocuments.FilePath);
var legalDocs = new LegalDocumentsViewModel(content);
return legalDocs;
- });
+ });*/
- searchPage.RegisterSearchEntry(
- title: "About Wasabi",
- caption: "Displays all the current info about the app",
- order: 4,
- category: "General",
- keywords: "About, Software, Version, Source Code, Github, Status, Stats, Tor, Onion, Bug, Report, FAQ, Questions," +
- "Docs, Documentation, Link, Links, Help",
- iconName: "info_regular",
- createTargetView: async () => await Task.FromResult(new AboutViewModel()));
+ AboutViewModel.Register(async () => await Task.FromResult(new AboutViewModel()));
}
private static void RegisterRootEntries(

ADD
WalletWasabi.Fluent/ViewModels/Navigation/NavigationManager.cs
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using WalletWasabi.Fluent.ViewModels.AddWallet;
+
+namespace WalletWasabi.Fluent.ViewModels.Navigation
+{
+ public enum NavBarPosition
+ {
+ None,
+ Top,
+ Bottom
+ }
+
+ public class NavigationManager
+ {
+ struct NavigationEntry
+ {
+ public NavigationMetaData MetaData { get; set; }
+ public Func<Task<RoutableViewModel>> GenerateViewModel { get; set; }
+ }
+
+ private static Dictionary<Type, NavigationEntry> _navigationTypes = new();
+
+ public static IEnumerable<NavigationMetaData> MetaData => _navigationTypes.Values.Select(x => x.MetaData);
+
+ public static void RegisterRoutable<T>(NavigationMetaData metaData, Func<Task<RoutableViewModel>> generator)
+ where T : RoutableViewModel
+ {
+ if (!_navigationTypes.ContainsKey(typeof(T)))
+ {
+ _navigationTypes.Add(
+ typeof(T),
+ new NavigationEntry
+ {
+ GenerateViewModel = generator,
+ MetaData = metaData
+ });
+ }
+ }
+ }
+}
\ No newline at end of file

begginings of navigation manager registration.