remove old action center code.
MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -11,7 +11,6 @@ using WalletWasabi.Fluent.ViewModels.HelpAndSupport;
using WalletWasabi.Fluent.ViewModels.NavBar;
using WalletWasabi.Fluent.ViewModels.Navigation;
using WalletWasabi.Fluent.ViewModels.OpenDirectory;
-using WalletWasabi.Fluent.ViewModels.Search;
using WalletWasabi.Fluent.ViewModels.SearchBar;
using WalletWasabi.Fluent.ViewModels.Settings;
using WalletWasabi.Fluent.ViewModels.StatusBar;
@@ -24,7 +23,6 @@ namespace WalletWasabi.Fluent.ViewModels;
public partial class MainViewModel : ViewModelBase
{
private readonly SettingsPageViewModel _settingsPage;
- private readonly SearchPageViewModel _searchPage;
private readonly PrivacyModeViewModel _privacyMode;
private readonly AddWalletPageViewModel _addWalletPage;
[AutoNotify] private bool _isMainContentEnabled;
@@ -76,20 +74,15 @@ public partial class MainViewModel : ViewModelBase
_addWalletPage = new AddWalletPageViewModel();
_settingsPage = new SettingsPageViewModel();
_privacyMode = new PrivacyModeViewModel();
- _searchPage = new SearchPageViewModel();
_navBar = new NavBarViewModel(MainScreen);
MusicControls = new MusicControlsViewModel();
NavigationManager.RegisterType(_navBar);
-
- RegisterCategories(_searchPage);
RegisterViewModels();
RxApp.MainThreadScheduler.Schedule(async () => await _navBar.InitialiseAsync());
- _searchPage.Initialise();
-
this.WhenAnyValue(x => x.WindowState, x => x.WindowPosition, x => x.WindowWidth, x => x.WindowHeight)
.Where(x => x.Item1 != WindowState.Minimized)
.Where(x => x.Item2 != new PixelPoint(-32000, -32000)) // value when minimized
@@ -216,7 +209,6 @@ public partial class MainViewModel : ViewModelBase
private void RegisterViewModels()
{
- SearchPageViewModel.Register(_searchPage);
PrivacyModeViewModel.Register(_privacyMode);
AddWalletPageViewModel.Register(_addWalletPage);
SettingsPageViewModel.Register(_settingsPage);
@@ -269,7 +261,6 @@ public partial class MainViewModel : ViewModelBase
var document = await Services.LegalChecker.WaitAndGetLatestDocumentAsync();
return new LegalDocumentsViewModel(document.Content);
});
- _searchPage.RegisterSearchEntry(LegalDocumentsViewModel.MetaData);
}
catch (Exception ex)
{
@@ -289,12 +280,4 @@ public partial class MainViewModel : ViewModelBase
OpenTorLogsViewModel.RegisterLazy(() => new OpenTorLogsViewModel());
OpenConfigFileViewModel.RegisterLazy(() => new OpenConfigFileViewModel());
}
-
- private static void RegisterCategories(SearchPageViewModel searchPage)
- {
- searchPage.RegisterCategory("General", 0);
- searchPage.RegisterCategory("Settings", 1);
- searchPage.RegisterCategory("Help & Support", 2);
- searchPage.RegisterCategory("Open", 3);
- }
}

DELETE
WalletWasabi.Fluent/ViewModels/Search/SearchCategory.cs
-namespace WalletWasabi.Fluent.ViewModels.Search;
-
-public class SearchCategory
-{
- public SearchCategory(string title, int order)
- {
- Title = title;
- Order = order;
- }
-
- public string Title { get; }
-
- public int Order { get; }
-}

DELETE
WalletWasabi.Fluent/ViewModels/Search/SearchItemViewModel.cs
-using System.Threading.Tasks;
-using System.Windows.Input;
-using ReactiveUI;
-using WalletWasabi.Fluent.ViewModels.NavBar;
-using WalletWasabi.Fluent.ViewModels.Navigation;
-
-namespace WalletWasabi.Fluent.ViewModels.Search;
-
-public class SearchItemViewModel : RoutableViewModel
-{
- private readonly NavigationMetaData _metaData;
-
- public SearchItemViewModel(
- SearchPageViewModel owner,
- NavigationMetaData metaData,
- SearchCategory category)
- {
- _metaData = metaData;
- Category = category;
- OpenCommand = ReactiveCommand.CreateFromTask(async () => await OnOpenAsync(owner, metaData));
- }
-
- private async Task OnOpenAsync(SearchPageViewModel owner, NavigationMetaData metaData)
- {
- owner.IsBusy = true;
- var view = await NavigationManager.MaterialiseViewModelAsync(metaData);
-
-
- if (view is NavBarItemViewModel navBarItem && navBarItem.OpenCommand.CanExecute(default))
- {
- navBarItem.OpenCommand.Execute(default);
- }
- else if (view is { })
- {
- Navigate(view.DefaultTarget).To(view);
- }
-
- owner.IsBusy = false;
- }
-
- public string Caption => _metaData.Caption;
-
- public int Order => _metaData.Order;
-
- public SearchCategory Category { get; }
-
- public string[] Keywords => _metaData.Keywords;
-
- public ICommand OpenCommand { get; }
-
- public override string Title
- {
- get => _metaData.Title;
- protected set { }
- }
-
- public override string IconName => _metaData.IconName;
-}

DELETE
WalletWasabi.Fluent/ViewModels/Search/SearchPageViewModel.cs
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Reactive.Linq;
-using DynamicData;
-using DynamicData.Binding;
-using ReactiveUI;
-using WalletWasabi.Fluent.ViewModels.NavBar;
-using WalletWasabi.Fluent.ViewModels.Navigation;
-
-namespace WalletWasabi.Fluent.ViewModels.Search;
-
-[NavigationMetaData(
- Title = "Action Center",
- IconName = "nav_grid_dots_regular",
- Searchable = false,
- NavBarPosition = NavBarPosition.Bottom)]
-public partial class SearchPageViewModel : NavBarItemViewModel
-{
- private readonly Dictionary<string, SearchCategory> _categories;
- private readonly Dictionary<SearchCategory, SourceList<SearchItemViewModel>> _categorySources;
- private ReadOnlyObservableCollection<SearchResult>? _searchResults;
- private IObservable<IChangeSet<SearchItemViewModel>>? _sourceObservable;
- [AutoNotify] private string? _searchQuery;
-
- public SearchPageViewModel()
- {
- _categories = new Dictionary<string, SearchCategory>();
- _categorySources = new Dictionary<SearchCategory, SourceList<SearchItemViewModel>>();
- }
-
- public ReadOnlyObservableCollection<SearchResult> SearchResults => _searchResults!;
-
- public void Initialise()
- {
- foreach (var metaData in NavigationManager.MetaData.Where(
- x => x.Searchable))
- {
- RegisterSearchEntry(metaData);
- }
-
- var queryFilter = this.WhenValueChanged(t => t.SearchQuery)
- .Throttle(TimeSpan.FromMilliseconds(100))
- .Select(SearchQueryFilter)
- .DistinctUntilChanged();
-
- _sourceObservable?
- .Filter(queryFilter)
- .GroupWithImmutableState(x => x.Category)
- .Transform(grouping =>
- new SearchResult(grouping.Key, grouping.Items.OrderBy(x => x.Order).ThenBy(x => x.Title)))
- .Sort(SortExpressionComparer<SearchResult>.Ascending(i => i.Category.Order)
- .ThenByAscending(i => i.Category.Title))
- .ObserveOn(RxApp.MainThreadScheduler)
- .Bind(out _searchResults)
- .AsObservableList();
- }
-
- public void RegisterCategory(string title, int order)
- {
- if (!_categories.ContainsKey(title))
- {
- var category = new SearchCategory(title, order);
-
- _categories.Add(title, category);
-
- var sourceList = new SourceList<SearchItemViewModel>();
-
- _categorySources.Add(category, sourceList);
-
- if (_sourceObservable is null)
- {
- _sourceObservable = sourceList.Connect();
- }
- else
- {
- _sourceObservable = _sourceObservable.Merge(sourceList.Connect());
- }
- return;
- }
-
- throw new Exception("Category already exists.");
- }
-
- public void RegisterSearchEntry(NavigationMetaData metaData)
- {
- if (_categories.TryGetValue(metaData.Category, out var searchCategory))
- {
- var result = new SearchItemViewModel(this, metaData, searchCategory);
-
- _categorySources[searchCategory].Add(result);
-
- return;
- }
-
- throw new Exception("Category doesn't exist.");
- }
-
- private Func<SearchItemViewModel, bool> SearchQueryFilter(string? searchQuery)
- {
- return item =>
- {
- if (!string.IsNullOrWhiteSpace(searchQuery)
- && !searchQuery.Contains(',', StringComparison.OrdinalIgnoreCase))
- {
- return item.Keywords.Any(x => x.Contains(searchQuery, StringComparison.OrdinalIgnoreCase)) ||
- item.Caption.Contains(searchQuery, StringComparison.OrdinalIgnoreCase);
- }
- return true;
- };
- }
-}

DELETE
WalletWasabi.Fluent/ViewModels/Search/SearchResult.cs
-using System.Collections.Generic;
-
-namespace WalletWasabi.Fluent.ViewModels.Search;
-
-public class SearchResult
-{
- public SearchResult(SearchCategory category, IEnumerable<SearchItemViewModel> items)
- {
- Category = category;
- Items = items;
- }
-
- public SearchCategory Category { get; }
-
- public IEnumerable<SearchItemViewModel> Items { get; }
-}

MODIFY
WalletWasabi.Fluent/Views/MainView.axaml
WalletWasabi.Fluent/Views/MainView.axaml
</Panel>
</Border>
- <searchBar:SearchBar DataContext="{Binding SearchBar}" HorizontalAlignment="Center" VerticalAlignment="Stretch"
- Grid.Row="0" Grid.Column="1" />
+ <searchBar:SearchBar DataContext="{Binding SearchBar}" Width="400" VerticalAlignment="Stretch"
+ Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" />
</Grid>
</Panel>

DELETE
WalletWasabi.Fluent/Views/Search/SearchPageView.axaml
-<UserControl xmlns="https://github.com/avaloniaui"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:vm="using:WalletWasabi.Fluent.ViewModels.Search"
- xmlns:search="using:WalletWasabi.Fluent.ViewModels.Search"
- xmlns:c="using:WalletWasabi.Fluent.Controls"
- xmlns:conv="using:WalletWasabi.Fluent.Converters"
- mc:Ignorable="d" d:DesignWidth="428" d:DesignHeight="371"
- x:DataType="vm:SearchPageViewModel"
- x:CompileBindings="True"
- x:Class="WalletWasabi.Fluent.Views.Search.SearchPageView">
- <c:ContentArea Title="{Binding Title}" IsBusy="{Binding IsBusy}">
- <c:ContentArea.Caption>
- <c:ConcatenatingWrapPanel>
- <TextBlock Text="Locate and discover features in Wasabi" VerticalAlignment="Top" Margin="0 0 20 32"/>
- <TextBox MinWidth="350" Margin="0 -22 0 0" VerticalAlignment="Top" Text="{Binding SearchQuery}" Watermark="Type here to search">
- <TextBox.InnerLeftContent>
- <PathIcon Data="{StaticResource search_regular}"
- Width="20" Height="20"
- Opacity="0.8"
- VerticalAlignment="Top" HorizontalAlignment="Left"
- Margin="16,8,0,0" />
- </TextBox.InnerLeftContent>
- </TextBox>
- </c:ConcatenatingWrapPanel>
- </c:ContentArea.Caption>
- <Panel>
- <ItemsControl HorizontalAlignment="Left"
- Items="{Binding SearchResults}"
- Margin="6,0,20,0"
- ClipToBounds="False">
- <ItemsControl.ItemsPanel>
- <ItemsPanelTemplate>
- <WrapPanel Orientation="Vertical" Margin="-8 0" />
- </ItemsPanelTemplate>
- </ItemsControl.ItemsPanel>
- <ItemsControl.ItemTemplate>
- <DataTemplate x:DataType="search:SearchResult">
- <DockPanel Margin="0,0,0,30">
- <Panel Margin="8 0" DockPanel.Dock="Top">
- <Label Classes="h6 bold"
- Margin="-6,0,0,0"
- DataContext="{Binding Category}"
- Content="{Binding Title}" />
- </Panel>
- <ItemsControl HorizontalAlignment="Left"
- Items="{Binding Items}"
- ClipToBounds="False">
- <ItemsControl.ItemsPanel>
- <ItemsPanelTemplate>
- <WrapPanel Orientation="Horizontal" />
- </ItemsPanelTemplate>
- </ItemsControl.ItemsPanel>
- <ItemsControl.ItemTemplate>
- <DataTemplate>
- <Button Classes="option" Command="{Binding OpenCommand}" Height="115" Width="178" Margin="4">
- <Panel>
- <PathIcon Width="20" Height="20" Opacity="0.8" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="12,12,0,0">
- <PathIcon.Data>
- <Binding Path="IconName" Converter="{x:Static conv:NavBarIconConverter.Instance}" />
- </PathIcon.Data>
- </PathIcon>
- <TextBlock Text="{Binding Title}" Classes="h7 bold" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="48 14 0 0" />
- <Panel Margin="12,46,12,12">
- <TextBlock Text="{Binding Caption}" Classes="h8" TextWrapping="Wrap" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Opacity="0.6" />
- </Panel>
- </Panel>
- </Button>
- </DataTemplate>
- </ItemsControl.ItemTemplate>
- </ItemsControl>
- </DockPanel>
- </DataTemplate>
- </ItemsControl.ItemTemplate>
- </ItemsControl>
- <TextBlock Text="Nothing found"
- IsVisible="{Binding !SearchResults.Count}"
- VerticalAlignment="Center"
- HorizontalAlignment="Center"/>
- </Panel>
- </c:ContentArea>
-</UserControl>

DELETE
WalletWasabi.Fluent/Views/Search/SearchPageView.axaml.cs
-using Avalonia.Controls;
-using Avalonia.Markup.Xaml;
-
-namespace WalletWasabi.Fluent.Views.Search;
-
-public class SearchPageView : UserControl
-{
- public SearchPageView()
- {
- InitializeComponent();
- }
-
- private void InitializeComponent()
- {
- AvaloniaXamlLoader.Load(this);
- }
-}

MODIFY
WalletWasabi.Fluent/Views/SearchBar/SearchBar.axaml
WalletWasabi.Fluent/Views/SearchBar/SearchBar.axaml
</Design.DataContext>
<TextBox x:Name="SearchBox" Watermark="Search settings / advanced features" HorizontalAlignment="Left"
- Text="{Binding SearchText, Mode=TwoWay}" MaxWidth="400" VerticalAlignment="Center">
+ Text="{Binding SearchText, Mode=TwoWay}" Width="400" VerticalAlignment="Center">
<TextBox.InnerLeftContent>
<PathIcon Data="{StaticResource action_center_regular}" Margin="10 0" />
</TextBox.InnerLeftContent>

remove old action center code.