Add sample non-actionable item
MODIFY
WalletWasabi.Fluent/Behaviors/SearchBarBehavior.cs
WalletWasabi.Fluent/Behaviors/SearchBarBehavior.cs
@@ -106,8 +106,12 @@ public class SearchBarBehavior : AttachedToVisualTreeBehavior<Control>
}
private void ShowFlyout()
+ {
+ if (AssociatedObject != null)
{
FlyoutBase.ShowAttachedFlyout(AssociatedObject);
+ }
+
IsSearchPanelOpen = true;
}
@@ -124,7 +128,7 @@ public class SearchBarBehavior : AttachedToVisualTreeBehavior<Control>
private void HideFlyout()
{
- FlyoutBase.GetAttachedFlyout(AssociatedObject).Hide();
+ FlyoutBase.GetAttachedFlyout(AssociatedObject)?.Hide();
IsSearchPanelOpen = false;
}

ADD
WalletWasabi.Fluent/DataTemplateSelector.cs
+using System.Collections.Generic;
+using System.Linq;
+using Avalonia.Controls;
+using Avalonia.Controls.Templates;
+using Avalonia.Metadata;
+
+namespace WalletWasabi.Fluent;
+
+public class DataTemplateSelector : IDataTemplate
+{
+ public IControl Build(object param)
+ {
+ return Templates.FirstOrDefault()?.Build(param) ?? new TextBlock {Text = "Not found "};
+ }
+
+ public bool Match(object data)
+ {
+ return true;
+ }
+
+ [Content] public IEnumerable<IDataTemplate> Templates { get; set; } = new List<IDataTemplate>();
+}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/ViewModels/SearchBar/AutocloseActionableItem.cs
WalletWasabi.Fluent/ViewModels/SearchBar/AutocloseActionableItem.cs
@@ -7,9 +7,9 @@ namespace WalletWasabi.Fluent.ViewModels.SearchBar;
public class AutocloseActionableItem : IActionableItem
{
- private readonly ActionableItem _item;
+ private readonly IActionableItem _item;
- public AutocloseActionableItem(ActionableItem item, Action collapseParent)
+ public AutocloseActionableItem(IActionableItem item, Action collapseParent)
{
_item = item;
Command = ReactiveCommand.CreateFromTask(async () =>

ADD
WalletWasabi.Fluent/ViewModels/SearchBar/DarkThemeSelector.cs
+using System.Reactive;
+using System.Reactive.Linq;
+using System.Threading.Tasks;
+using ReactiveUI;
+using WalletWasabi.Fluent.Helpers;
+
+namespace WalletWasabi.Fluent.ViewModels.SearchBar;
+
+public class DarkThemeSelector : ReactiveObject
+{
+ private bool _isDarkThemeEnabled;
+
+ public DarkThemeSelector()
+ {
+ IsDarkThemeEnabled = ThemeHelper.CurrentTheme == Theme.Dark;
+ this.WhenAnyValue(x => x.IsDarkThemeEnabled)
+ .SelectMany(b =>
+ {
+ return Observable.FromAsync(() =>
+ {
+ ThemeHelper.ApplyTheme(b ? Theme.Dark : Theme.Light);
+ return Task.FromResult(Unit.Default);
+ });
+ })
+ .Subscribe();
+ }
+
+ public bool IsDarkThemeEnabled
+ {
+ get => _isDarkThemeEnabled;
+ set => this.RaiseAndSetIfChanged(ref _isDarkThemeEnabled, value);
+ }
+}
\ No newline at end of file

ADD
WalletWasabi.Fluent/ViewModels/SearchBar/NonActionableSearchItem.cs
+using System.Collections.Generic;
+
+namespace WalletWasabi.Fluent.ViewModels.SearchBar;
+
+public class NonActionableSearchItem : ISearchItem
+{
+ public NonActionableSearchItem(object content, string name, string category, IEnumerable<string> keywords,
+ string? icon)
+ {
+ Name = name;
+ Content = content;
+ Category = category;
+ Keywords = keywords;
+ Icon = icon;
+ }
+
+ public string Name { get; }
+ public object Content { get; }
+ public ComposedKey Key => new(Name);
+ public string Description => "";
+ public string? Icon { get; set; }
+ public string Category { get; }
+ public IEnumerable<string> Keywords { get; }
+}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/ViewModels/SearchBar/SearchBarDesignViewModel.cs
WalletWasabi.Fluent/ViewModels/SearchBar/SearchBarDesignViewModel.cs
+using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reactive.Linq;
@@ -8,11 +9,11 @@ namespace WalletWasabi.Fluent.ViewModels.SearchBar;
public class SearchBarDesignViewModel : ReactiveObject
{
- private readonly ActionableItem[] _items;
+ private readonly IEnumerable<ISearchItem> _items;
public SearchBarDesignViewModel()
{
- _items = new[]
+ var actionable = new IActionableItem[]
{
new ActionableItem("Test 1: Short", "Description short", null, "Settings")
{Icon = "settings_bitcoin_regular"},
@@ -28,7 +29,14 @@ public class SearchBarDesignViewModel : ReactiveObject
"Help")
{Icon = "settings_bitcoin_regular"},
new ActionableItem("Test 3", "Another", null, "Help") {Icon = "settings_bitcoin_regular"}
+ }.Select(item => (ISearchItem) new AutocloseActionableItem(item, () => { }));
+
+ var nonActionable = new ISearchItem[]
+ {
+ new NonActionableSearchItem(new DarkThemeSelector(), "Dark theme", "Appearance", new List<string>(), null)
};
+
+ _items = actionable.Concat(nonActionable).ToList();
}
public ReadOnlyObservableCollection<SearchItemGroup> Groups => new(new ObservableCollection<SearchItemGroup>(_items

MODIFY
WalletWasabi.Fluent/ViewModels/SearchBar/SearchItemProvider.cs
WalletWasabi.Fluent/ViewModels/SearchBar/SearchItemProvider.cs
@@ -9,7 +9,7 @@ public static class SearchItemProvider
{
public static IObservable<ISearchItem> GetSearchItems()
{
- var data = NavigationManager.MetaData
+ var items = NavigationManager.MetaData
.Where(m => m.Searchable)
.Select(m =>
{
@@ -21,9 +21,14 @@ public static class SearchItemProvider
return searchItem;
});
- var items = data.ToObservable();
-
- return items;
+ return items
+ .Concat(new ISearchItem[]
+ {
+ new NonActionableSearchItem(new DarkThemeSelector(), "Dark theme", "Appearance",
+ new[] {"Dark", "Light", "Theme", "Appearance", "Colors"},
+ null)
+ })
+ .ToObservable();
}
private static Func<Task> CreateFunc(NavigationMetaData navigationMetaData)
@@ -48,7 +53,7 @@ public static class SearchItemProvider
NavigationTarget.DialogScreen => NavigationState.Instance.DialogScreenNavigation,
NavigationTarget.FullScreen => NavigationState.Instance.FullScreenNavigation,
NavigationTarget.CompactDialogScreen => NavigationState.Instance.CompactDialogScreenNavigation,
- _ => throw new NotSupportedException(),
+ _ => throw new NotSupportedException()
};
}
}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/Views/SearchBar/SearchBarDropdown.axaml
WalletWasabi.Fluent/Views/SearchBar/SearchBarDropdown.axaml
x:CompileBindings="False"
x:DataType="sb:SearchBarViewModel"
xmlns:conv="clr-namespace:WalletWasabi.Fluent.Converters"
- xmlns:sb="clr-namespace:WalletWasabi.Fluent.ViewModels.SearchBar">
+ xmlns:sb="clr-namespace:WalletWasabi.Fluent.ViewModels.SearchBar"
+ xmlns:fluent="clr-namespace:WalletWasabi.Fluent">
<Design.DataContext>
<sb:SearchBarDesignViewModel />
</Design.DataContext>
</UserControl.Styles>
<UserControl.DataTemplates>
- <DataTemplate x:DataType="sb:AutocloseActionableItem">
+
+ <DataTemplate DataType="sb:NonActionableSearchItem">
+ <DockPanel Background="Transparent" Margin="10">
+ <Panel DockPanel.Dock="Left" Width="16" Height="16" Opacity="0.8" VerticalAlignment="Center">
+ <!--TODO: Remove this workaround. We must leave the PathIcon only-->
+ <PathIcon Data="{Binding Icon, Converter={x:Static conv:NavBarIconConverter.Instance}}" />
+ <Image Source="{Binding Icon, Converter={x:Static conv:NavBarIconConverter.Instance}}" />
+ </Panel>
+ <TextBlock Margin="10 0 10 0" Text="{Binding Name}" VerticalAlignment="Center" />
+ <ContentControl HorizontalContentAlignment="Stretch"
+ VerticalContentAlignment="Stretch"
+ Content="{Binding Content}" />
+ </DockPanel>
+ </DataTemplate>
+
+ <DataTemplate DataType="sb:DarkThemeSelector">
+ <ToggleSwitch HorizontalAlignment="Right" IsChecked="{Binding IsDarkThemeEnabled, Mode=TwoWay}" />
+ </DataTemplate>
+
+ <DataTemplate DataType="sb:AutocloseActionableItem">
<Button Command="{Binding Command}" Background="Transparent" HorizontalAlignment="Stretch" Padding="0">
<DockPanel Background="Transparent" Margin="10">

Add sample non-actionable item