pastebutton flash behavior takes into account textbox status.
MODIFY
WalletWasabi.Fluent/Behaviors/PasteButtonFlashBehavior.cs
WalletWasabi.Fluent/Behaviors/PasteButtonFlashBehavior.cs
-using System;
using System.Reactive;
using System.Reactive.Concurrency;
+using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Avalonia;
+using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using ReactiveUI;
using WalletWasabi.Fluent.Controls;
@@ -19,6 +20,16 @@ namespace WalletWasabi.Fluent.Behaviors
public static readonly StyledProperty<string> CurrentAddressProperty =
AvaloniaProperty.Register<PasteButtonFlashBehavior, string>(nameof(FlashAnimation));
+ public static readonly StyledProperty<TextBox?> OwnerTextBoxProperty =
+ AvaloniaProperty.Register<CheckMarkVisibilityBehavior, TextBox?>(nameof(OwnerTextBox));
+
+ [ResolveByName]
+ public TextBox? OwnerTextBox
+ {
+ get => GetValue(OwnerTextBoxProperty);
+ set => SetValue(OwnerTextBoxProperty, value);
+ }
+
public string FlashAnimation
{
get => GetValue(FlashAnimationProperty);
@@ -31,32 +42,51 @@ namespace WalletWasabi.Fluent.Behaviors
set => SetValue(CurrentAddressProperty, value);
}
- protected override void OnAttachedToVisualTree()
+ protected override void OnAttachedToVisualTree(CompositeDisposable disposables)
{
RxApp.MainThreadScheduler.Schedule(async () => await CheckClipboardForValidAddressAsync());
- var mainWindow = ((IClassicDesktopStyleApplicationLifetime)Application.Current.ApplicationLifetime).MainWindow;
+ if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime lifetime)
+ {
+ var mainWindow = lifetime.MainWindow;
+
Observable
.FromEventPattern(mainWindow, nameof(mainWindow.Activated)).Select(_ => Unit.Default)
.Merge(this.WhenAnyValue(x => x.CurrentAddress).Select(_ => Unit.Default))
.Throttle(TimeSpan.FromMilliseconds(100))
.ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(async _ => await CheckClipboardForValidAddressAsync());
+ .Subscribe(async _ => await CheckClipboardForValidAddressAsync())
+ .DisposeWith(disposables);
+ }
AssociatedObject?.WhenAnyValue(x => x.AnimateIcon)
.Where(x => x)
- .Subscribe(_ => AssociatedObject.Classes.Remove(FlashAnimation));
+ .Subscribe(_ => AssociatedObject.Classes.Remove(FlashAnimation))
+ .DisposeWith(disposables);
+
+ OwnerTextBox?.WhenAnyValue(x => x.IsFocused)
+ .Subscribe(async _ =>
+ {
+ await CheckClipboardForValidAddressAsync();
+ })
+ .DisposeWith(disposables);
}
private async Task CheckClipboardForValidAddressAsync()
{
+ var tbFocussed = OwnerTextBox?.IsFocused ?? true;
+
AssociatedObject?.Classes.Remove(FlashAnimation);
+ if (tbFocussed)
+ {
var textToPaste = await Application.Current.Clipboard.GetTextAsync();
- if (AddressStringParser.TryParse(textToPaste, Services.WalletManager.Network, out _) && textToPaste != CurrentAddress)
+ if (AddressStringParser.TryParse(textToPaste, Services.WalletManager.Network, out _) &&
+ textToPaste != CurrentAddress)
{
AssociatedObject?.Classes.Add(FlashAnimation);
}
}
}
}
+}

MODIFY
WalletWasabi.Fluent/Views/Wallets/Send/SendView.axaml
WalletWasabi.Fluent/Views/Wallets/Send/SendView.axaml
xmlns:behaviors="using:WalletWasabi.Fluent.Behaviors"
xmlns:c="using:WalletWasabi.Fluent.Controls"
xmlns:vm="using:WalletWasabi.Fluent.ViewModels.Wallets.Send"
- xmlns:labels="clr-namespace:WalletWasabi.Fluent.Views.Wallets.Labels"
mc:Ignorable="d"
x:DataType="vm:SendViewModel"
x:CompileBindings="True"
<Style Selector="c|AnimatedButton.flash /template/ PathIcon#PART_IconNormal">
<Setter Property="Foreground" Value="{DynamicResource SystemAccentColor}" />
<Style.Animations>
- <Animation Duration="0.25" IterationCount="8" PlaybackDirection="AlternateReverse" Easing="{StaticResource FluentEasing}">
+ <Animation Duration="0.25" IterationCount="6"
+ PlaybackDirection="Alternate"
+ FillMode="Forward"
+ Easing="{StaticResource FluentEasing}">
<KeyFrame KeyTime="0:0:0.0">
<Setter Property="Opacity" Value="0.1" />
</KeyFrame>
NormalIcon="{StaticResource paste_regular}"
ClickIcon="{StaticResource copy_confirmed}">
<i:Interaction.Behaviors>
- <behaviors:PasteButtonFlashBehavior FlashAnimation="flash" CurrentAddress="{Binding To}"/>
+ <behaviors:PasteButtonFlashBehavior OwnerTextBox="toTb" FlashAnimation="flash" CurrentAddress="{Binding To}"/>
</i:Interaction.Behaviors>
</c:AnimatedButton>
<c:AnimatedButton IsVisible="{Binding IsQrButtonVisible}"

pastebutton flash behavior takes into account textbox status.