add Copy button to PreviewItem
MODIFY
WalletWasabi.Fluent/Controls/PreviewItem.axaml
WalletWasabi.Fluent/Controls/PreviewItem.axaml
DockPanel.Dock="Left" />
<DockPanel DockPanel.Dock="Right" Margin="30 0 0 0">
<TextBlock Name="PART_Text" Text="{TemplateBinding Text}" DockPanel.Dock="Top" Margin="0 0 0 5" Opacity="0.6" />
+ <DockPanel HorizontalAlignment="Left" DockPanel.Dock="Bottom">
+ <c:AnimatedButton Margin="5 0 0 0"
+ Command="{TemplateBinding CopyCommand}"
+ CommandParameter="{TemplateBinding CopyParameter}"
+ ToolTip.Tip="Copy"
+ NormalIcon="{StaticResource copy_regular}"
+ ClickIcon="{StaticResource copy_confirmed}"
+ InitialOpacity="0.6"
+ DockPanel.Dock="Right"
+ IsVisible="{TemplateBinding CopyButtonVisibility}"/>
<ContentPresenter Name="PART_ContentPresenter" Content="{TemplateBinding Content}"
- ContentTemplate="{TemplateBinding ContentTemplate}" DockPanel.Dock="Bottom" />
+ ContentTemplate="{TemplateBinding ContentTemplate}" />
+ </DockPanel>
</DockPanel>
</DockPanel>
</ControlTemplate>

MODIFY
WalletWasabi.Fluent/Controls/PreviewItem.axaml.cs
WalletWasabi.Fluent/Controls/PreviewItem.axaml.cs
+using System;
+using System.Reactive.Linq;
using System.Windows.Input;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
+using ReactiveUI;
namespace WalletWasabi.Fluent.Controls
{
@@ -16,6 +19,30 @@ namespace WalletWasabi.Fluent.Controls
public static readonly StyledProperty<double> IconSizeProperty =
AvaloniaProperty.Register<PreviewItem, double>(nameof(IconSize), 24);
+ public static readonly StyledProperty<object?> CopyParameterProperty =
+ AvaloniaProperty.Register<PreviewItem, object?>(nameof(CopyParameter));
+
+ public static readonly StyledProperty<ICommand> CopyCommandProperty =
+ AvaloniaProperty.Register<PreviewItem, ICommand>(nameof(CopyCommand));
+
+ public static readonly StyledProperty<bool> CopyButtonVisibilityProperty =
+ AvaloniaProperty.Register<PreviewItem, bool>(nameof(CopyButtonVisibility));
+
+ public PreviewItem()
+ {
+ CopyCommand = ReactiveCommand.CreateFromTask<object>(async obj =>
+ {
+ if (obj.ToString() is { } text)
+ {
+ await Application.Current.Clipboard.SetTextAsync(text);
+ }
+ });
+
+ this.WhenAnyValue(x => x.CopyParameter)
+ .Select(x => !string.IsNullOrEmpty(x?.ToString()))
+ .Subscribe(x => CopyButtonVisibility = x);
+ }
+
public string Text
{
get => GetValue(TextProperty);
@@ -33,5 +60,23 @@ namespace WalletWasabi.Fluent.Controls
get => GetValue(IconSizeProperty);
set => SetValue(IconSizeProperty, value);
}
+
+ public object? CopyParameter
+ {
+ get => GetValue(CopyParameterProperty);
+ set => SetValue(CopyParameterProperty, value);
+ }
+
+ public ICommand CopyCommand
+ {
+ get => GetValue(CopyCommandProperty);
+ set => SetValue(CopyCommandProperty, value);
+ }
+
+ public bool CopyButtonVisibility
+ {
+ get => GetValue(CopyButtonVisibilityProperty);
+ set => SetValue(CopyButtonVisibilityProperty, value);
+ }
}
}

MODIFY
WalletWasabi.Fluent/Views/Wallets/Home/History/TransactionDetailsView.axaml
WalletWasabi.Fluent/Views/Wallets/Home/History/TransactionDetailsView.axaml
<!-- Transaction ID -->
<c:PreviewItem Icon="{StaticResource transaction_id}"
- Text="Transaction ID">
- <DockPanel HorizontalAlignment="Left">
- <c:AnimatedButton Margin="5 0 0 0"
- Command="{Binding CopyTransactionIdCommand}"
- ToolTip.Tip="Copy"
- NormalIcon="{StaticResource copy_regular}"
- ClickIcon="{StaticResource copy_confirmed}"
- InitialOpacity="0.6"
- DockPanel.Dock="Right"/>
- <TextBlock Text="{Binding TransactionId}"/>
- </DockPanel>
- </c:PreviewItem>
+ Text="Transaction ID"
+ Content="{Binding TransactionId}"
+ CopyParameter="{Binding TransactionId}"/>
<Separator />
<!-- Incoming amount -->
<c:PreviewItem Icon="{StaticResource btc_logo}"
Text="Amount"
- Content="{Binding Amount, StringFormat={}{0} BTC}"/>
+ Content="{Binding Amount, StringFormat={}{0} BTC}"
+ CopyParameter="{Binding Amount}" />
<Separator />
<!-- Block height -->
<c:PreviewItem Icon="{StaticResource block_height}"
Text="Block height"
- Content="{Binding BlockHeight}" />
+ Content="{Binding BlockHeight}"
+ CopyParameter="{Binding BlockHeight}" />
<Separator />
<!-- Confirmations -->
<c:PreviewItem Icon="{StaticResource copy_confirmed}"
Text="Confirmations"
- Content="{Binding Confirmations}" />
+ Content="{Binding Confirmations}"
+ CopyParameter="{Binding Confirmations}" />
<Separator />
<!-- Labels -->
<c:PreviewItem Icon="{StaticResource entities_regular}"
- Text="Labels">
+ Text="Labels"
+ CopyParameter="{Binding Labels}">
<c:TagsBox Padding="0" IsReadOnly="True" Items="{Binding Labels}" />
</c:PreviewItem>

add Copy button to PreviewItem