Copy balance
MODIFY
WalletWasabi.Fluent/App.axaml
WalletWasabi.Fluent/App.axaml
<StyleInclude Source="avares://WalletWasabi.Fluent/Controls/LabelsItemsPresenter.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Controls/SuggestionItem.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Controls/ClipboardCopyButton.axaml" />
+ <StyleInclude Source="avares://WalletWasabi.Fluent/Controls/CopyableItem.axaml" />
</Application.Styles>
<NativeMenu.Menu>
<NativeMenu>

MODIFY
WalletWasabi.Fluent/Controls/ClipboardCopyButton.axaml.cs
WalletWasabi.Fluent/Controls/ClipboardCopyButton.axaml.cs
@@ -37,6 +37,7 @@ public class ClipboardCopyButton : TemplatedControl
if (Application.Current is { Clipboard: { } clipboard })
{
await clipboard.SetTextAsync(Text);
+ await Task.Delay(1000);
}
}
}

ADD
WalletWasabi.Fluent/Controls/CopyableItem.axaml
+<Styles xmlns="https://github.com/avaloniaui"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:controls="using:WalletWasabi.Fluent.Controls"
+ xmlns:converters="clr-namespace:WalletWasabi.Fluent.Converters">
+ <Design.PreviewWith>
+ <controls:CopyableItem>
+ <TextBlock>Hello everyone!</TextBlock>
+ </controls:CopyableItem>
+ </Design.PreviewWith>
+
+ <Style Selector="controls|CopyableItem">
+ <!-- Set Defaults -->
+ <Setter Property="Template">
+ <ControlTemplate>
+ <Grid x:Name="Grid" Background="Transparent" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="20" />
+ <ColumnDefinition />
+ <ColumnDefinition Width="Auto" />
+ </Grid.ColumnDefinitions>
+ <ContentPresenter Grid.Column="1" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" />
+ <Panel Grid.Column="2" Width="20">
+ <controls:ClipboardCopyButton VerticalAlignment="Center" HorizontalAlignment="Center" x:Name="CopyButton" Text="{TemplateBinding ContentToCopy}">
+ <controls:ClipboardCopyButton.IsVisible>
+ <MultiBinding Converter="{x:Static converters:BooleanConverters.Or}">
+ <Binding Path="#Grid.IsPointerOver" />
+ <Binding Path="#CopyButton.CopyCommand.IsExecuting^" />
+ </MultiBinding>
+ </controls:ClipboardCopyButton.IsVisible>
+ </controls:ClipboardCopyButton>
+ </Panel>
+ </Grid>
+ </ControlTemplate>
+ </Setter>
+ </Style>
+</Styles>

ADD
WalletWasabi.Fluent/Controls/CopyableItem.axaml.cs
+using Avalonia;
+using Avalonia.Controls;
+
+namespace WalletWasabi.Fluent.Controls;
+
+public class CopyableItem : ContentControl
+{
+ public static readonly StyledProperty<string?> ContentToCopyProperty = AvaloniaProperty.Register<CopyableItem, string?>(nameof(ContentToCopy));
+
+ public string? ContentToCopy
+ {
+ get => GetValue(ContentToCopyProperty);
+ set => SetValue(ContentToCopyProperty, value);
+ }
+}

ADD
WalletWasabi.Fluent/Converters/BooleanConverters.cs
+using System.Linq;
+using Avalonia.Data.Converters;
+
+namespace WalletWasabi.Fluent.Converters;
+
+public static class BooleanConverters
+{
+ public static readonly IMultiValueConverter Or = new FuncMultiValueConverter<bool, bool>(n => n.Any(b => b));
+}

MODIFY
WalletWasabi.Fluent/Converters/MoneyConverters.cs
WalletWasabi.Fluent/Converters/MoneyConverters.cs
+using System.Collections.Generic;
+using System.Globalization;
using Avalonia.Data.Converters;
+using NBitcoin;
using WalletWasabi.Fluent.Extensions;
namespace WalletWasabi.Fluent.Converters;
@@ -10,4 +13,7 @@ public static class MoneyConverters
public static readonly IValueConverter ToUsdAproxBetweenParens =
new FuncValueConverter<decimal, string>(n => n.ToUsdAproxBetweenParens());
+
+ public static readonly IValueConverter ToBtc =
+ new FuncValueConverter<Money, string>(n => n?.ToDecimal(MoneyUnit.BTC).FormattedBtc() + " BTC");
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/Tiles/WalletBalanceTileViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/Tiles/WalletBalanceTileViewModel.cs
@@ -11,16 +11,15 @@ public class WalletBalanceTileViewModel : ActivatableViewModel
{
var wallet = walletVm.Wallet;
- var balance = walletVm.UiTriggers.BalanceUpdateTrigger
+ var balanceBtc = walletVm.UiTriggers.BalanceUpdateTrigger
.Select(_ => wallet.Coins.TotalAmount());
- BalanceBtc = balance
- .Select(money => $"{money.ToFormattedString()} BTC");
+ BalanceBtc = balanceBtc;
- BalanceFiat = balance
+ BalanceFiat = balanceBtc
.Select(money => money.BtcToUsd(wallet.Synchronizer.UsdExchangeRate));
- HasBalance = balance
+ HasBalance = balanceBtc
.Select(money => money > Money.Zero);
}
@@ -28,5 +27,5 @@ public class WalletBalanceTileViewModel : ActivatableViewModel
public IObservable<decimal> BalanceFiat { get; }
- public IObservable<string> BalanceBtc { get; }
+ public IObservable<Money> BalanceBtc { get; }
}

MODIFY
WalletWasabi.Fluent/Views/Wallets/Home/Tiles/WalletBalanceTileView.axaml
WalletWasabi.Fluent/Views/Wallets/Home/Tiles/WalletBalanceTileView.axaml
mc:Ignorable="d" d:DesignWidth="320" d:DesignHeight="140"
x:CompileBindings="True"
x:DataType="tiles:WalletBalanceTileViewModel"
- x:Class="WalletWasabi.Fluent.Views.Wallets.Home.Tiles.WalletBalanceTileView">
+ x:Class="WalletWasabi.Fluent.Views.Wallets.Home.Tiles.WalletBalanceTileView" ClipToBounds="False">
+
+ <UserControl.Styles>
+ <Style Selector="c|PreviewItem">
+ <Setter Property="Template">
+ <ControlTemplate>
+ <Panel ClipToBounds="False">
+ <ContentPresenter Name="PART_ContentPresenter" Content="{TemplateBinding Content}"
+ ContentTemplate="{TemplateBinding ContentTemplate}"
+ HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
+ VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
+ <c:ClipboardCopyButton x:Name="PART_ClipboardCopyButton"
+ ToolTip.Tip="Copy"
+ HorizontalAlignment="Right"
+ Width="30"
+ Margin="0 0 -30 0"
+ Text="{TemplateBinding TextValue}"
+ IsVisible="{TemplateBinding IsCopyButtonVisible}" />
+ </Panel>
+ </ControlTemplate>
+ </Setter>
+ </Style>
+ </UserControl.Styles>
<c:TileControl Title="BALANCE" IsBottomContentVisible="{Binding HasBalance^}" SeparatorMargin="0 0 0 6">
<Viewbox Margin="0 3" VerticalAlignment="Center" MaxHeight="40">
+ <c:CopyableItem ContentToCopy="{Binding BalanceBtc^}">
<c:PrivacyContentControl Classes="h2 monoSpaced" HorizontalContentAlignment="Center"
- Content="{Binding BalanceBtc^}" />
+ Content="{Binding BalanceBtc^, Converter={x:Static converters:MoneyConverters.ToBtc}}" />
+ </c:CopyableItem>
</Viewbox>
<c:TileControl.BottomContent>
<c:PrivacyContentControl Classes="bold monoSpaced" Margin="4" VerticalAlignment="Center"
- HorizontalAlignment="Center" Opacity="0.8"
+ Opacity="0.8"
+ HorizontalContentAlignment="Center"
Content="{Binding BalanceFiat^, Converter={x:Static converters:MoneyConverters.ToUsdAproxBetweenParens}}" />
</c:TileControl.BottomContent>
</c:TileControl>

MODIFY
WalletWasabi.Fluent/Views/Wallets/Send/SendView.axaml
WalletWasabi.Fluent/Views/Wallets/Send/SendView.axaml
<TextBlock DataContext="{Binding Balance}">
<TextBlock.Text>
<MultiBinding StringFormat="Balance: {0} {1}">
- <Binding Path="BalanceBtc^" />
+ <Binding Path="BalanceBtc^" Converter="{x:Static converters:MoneyConverters.ToBtc}" />
<Binding Path="BalanceFiat^" Converter="{x:Static converters:MoneyConverters.ToUsdAproxBetweenParens}" />
</MultiBinding>
</TextBlock.Text>

Copy balance