do not pass KeyManager to a converter
MODIFY
WalletWasabi.Fluent/Converters/WalletIconConverter.cs
WalletWasabi.Fluent/Converters/WalletIconConverter.cs
using System;
+using System.Linq;
using Avalonia;
using Avalonia.Data.Converters;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
-using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Wallets;
namespace WalletWasabi.Fluent.Converters
{
public static class WalletIconConverter
{
- public static readonly IValueConverter KeyManagerToImage =
- new FuncValueConverter<KeyManager, Bitmap>(km =>
+ public static readonly IMultiValueConverter TypesToImage =
+ new FuncMultiValueConverter<WalletType, Bitmap>(parts =>
{
- var type = Enum.TryParse(typeof(WalletType), km.Icon, true, out var typ) && typ is { }
- ? (WalletType)typ
- : km.IsHardwareWallet
- ? WalletType.Hardware
- : WalletType.Normal;
-
+ var inputs = parts.ToArray();
+ var type = inputs[0] == WalletType.Unknown ? inputs[1] : inputs[0];
return GetBitmap(type);
});
@@ -35,6 +31,24 @@ namespace WalletWasabi.Fluent.Converters
return GetBitmap(type);
});
+ public static readonly IValueConverter BoolToType =
+ new FuncValueConverter<bool, WalletType>(x => x ? WalletType.Hardware : WalletType.Normal);
+
+ public static readonly IValueConverter StringToType =
+ new FuncValueConverter<string?, WalletType>(x =>
+ {
+ if (x is { })
+ {
+ return Enum.TryParse(typeof(WalletType), x, true, out var typ) && typ is { }
+ ? (WalletType) typ
+ : WalletType.Normal;
+ }
+ else
+ {
+ return WalletType.Unknown;
+ }
+ });
+
private static Bitmap GetBitmap(WalletType type)
{
Uri uri = new("avares://WalletWasabi.Fluent/Assets/HardwareIcons/generic.png");
@@ -54,6 +68,7 @@ namespace WalletWasabi.Fluent.Converters
break;
case WalletType.Normal:
+ case WalletType.Unknown:
uri = new("avares://WalletWasabi.Fluent/Assets/HardwareIcons/normal.png");
break;
}

MODIFY
WalletWasabi.Fluent/Views/AddWallet/AddedWalletPageView.axaml
WalletWasabi.Fluent/Views/AddWallet/AddedWalletPageView.axaml
<TextBlock Text=" was added to Wasabi." />
</StackPanel>
<Viewbox MaxHeight="200">
- <Image Source="{Binding KeyManager, Converter={x:Static conv:WalletIconConverter.KeyManagerToImage}}" />
+ <Image DataContext="{Binding KeyManager}">
+ <Image.Source>
+ <MultiBinding Converter="{x:Static conv:WalletIconConverter.TypesToImage}">
+ <Binding Path="Icon" Converter="{x:Static conv:WalletIconConverter.StringToType}" />
+ <Binding Path="IsHardwareWallet" Converter="{x:Static conv:WalletIconConverter.BoolToType}" />
+ </MultiBinding>
+ </Image.Source>
+ </Image>
</Viewbox>
</DockPanel>
</c:ContentArea>

MODIFY
WalletWasabi.Fluent/Views/Login/LoginView.axaml
WalletWasabi.Fluent/Views/Login/LoginView.axaml
<!-- Icon -->
<Viewbox MaxHeight="200">
- <Image Source="{Binding KeyManager, Converter={x:Static conv:WalletIconConverter.KeyManagerToImage}}" />
+ <Image DataContext="{Binding KeyManager}">
+ <Image.Source>
+ <MultiBinding Converter="{x:Static conv:WalletIconConverter.TypesToImage}">
+ <Binding Path="Icon" Converter="{x:Static conv:WalletIconConverter.StringToType}" />
+ <Binding Path="IsHardwareWallet" Converter="{x:Static conv:WalletIconConverter.BoolToType}" />
+ </MultiBinding>
+ </Image.Source>
+ </Image>
</Viewbox>
</DockPanel>

MODIFY
WalletWasabi/Wallets/WalletType.cs
WalletWasabi/Wallets/WalletType.cs
@@ -6,6 +6,7 @@ namespace WalletWasabi.Wallets
Hardware,
Coldcard,
Trezor,
- Ledger
+ Ledger,
+ Unknown
}
}

do not pass KeyManager to a converter