Review USD-BTC rate tile
MODIFY
WalletWasabi.Fluent/Converters/MoneyConverters.cs
WalletWasabi.Fluent/Converters/MoneyConverters.cs
using Avalonia.Data.Converters;
using NBitcoin;
using WalletWasabi.Fluent.Helpers;
+using WalletWasabi.Helpers;
namespace WalletWasabi.Fluent.Converters;
@@ -8,4 +9,7 @@ public static class MoneyConverters
{
public static readonly IValueConverter ToFormattedString =
new FuncValueConverter<Money?, string>(money => money is null ? "" : money.ToFormattedString());
+
+ public static readonly IValueConverter ToUsd =
+ new FuncValueConverter<decimal, string>(n => n.RoundToSignificantFigures(5) + " USD");
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/Tiles/BtcPriceTileViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/Tiles/BtcPriceTileViewModel.cs
-using System.Reactive.Disposables;
using System.Reactive.Linq;
using ReactiveUI;
-using WalletWasabi.Fluent.Helpers;
+using WalletWasabi.Fluent.Extensions;
using WalletWasabi.Wallets;
namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.Tiles;
-public partial class BtcPriceTileViewModel : TileViewModel
+public class BtcPriceTileViewModel : TileViewModel
{
- private readonly Wallet _wallet;
- [AutoNotify] private string _btcPrice;
-
public BtcPriceTileViewModel(Wallet wallet)
{
- _wallet = wallet;
- _btcPrice = "";
- }
-
- protected override void OnActivated(CompositeDisposable disposables)
- {
- base.OnActivated(disposables);
+ Wallet = wallet;
- _wallet.Synchronizer.WhenAnyValue(x => x.UsdExchangeRate)
+ BtcPrice = this
+ .WhenAnyValue(x => x.Wallet.Synchronizer.UsdExchangeRate)
.ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(usd => BtcPrice = usd.FormattedFiat(format: "N0") + " USD")
- .DisposeWith(disposables);
+ .ReplayLastActive();
}
+
+ public IObservable<decimal> BtcPrice { get; }
+
+ private Wallet Wallet { get; }
}

MODIFY
WalletWasabi.Fluent/Views/Wallets/Home/Tiles/BtcPriceTileView.axaml
WalletWasabi.Fluent/Views/Wallets/Home/Tiles/BtcPriceTileView.axaml
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="using:WalletWasabi.Fluent.ViewModels.Wallets.Home.Tiles"
xmlns:controls="clr-namespace:WalletWasabi.Fluent.Controls"
+ xmlns:converters="clr-namespace:WalletWasabi.Fluent.Converters"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:CompileBindings="True" x:DataType="vm:BtcPriceTileViewModel"
x:Class="WalletWasabi.Fluent.Views.Wallets.Home.Tiles.BtcPriceTileView">
Classes="h2 monoSpaced"
VerticalAlignment="Center" HorizontalAlignment="Center"
TextAlignment="Center"
- Text="{Binding BtcPrice, FallbackValue='53 540.00'}" />
+ Text="{Binding BtcPrice^, Converter={x:Static converters:MoneyConverters.ToUsd}}" />
</DockPanel>
</controls:TileControl>

Review USD-BTC rate tile