-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11463 from ichthus1604/PrivacyWarningsNewUx
[VDG] Privacy warnings Improved UX
- Loading branch information
Showing
6 changed files
with
191 additions
and
61 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
WalletWasabi.Fluent/Behaviors/PrivacyWarningFadeOutBehavior.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using Avalonia; | ||
using Avalonia.Animation; | ||
using Avalonia.Controls; | ||
using Avalonia.Controls.Primitives; | ||
using ReactiveUI; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using System.Reactive.Disposables; | ||
using System.Reactive.Linq; | ||
using WalletWasabi.Fluent.Extensions; | ||
using WalletWasabi.Fluent.Models.Transactions; | ||
|
||
namespace WalletWasabi.Fluent.Behaviors; | ||
|
||
public class PrivacyWarningFadeOutBehavior : AttachedToVisualTreeBehavior<Control> | ||
{ | ||
private const string FadeOutClassName = "fadeout"; | ||
|
||
public static readonly StyledProperty<IEnumerable<PrivacyWarning>> PreviewWarningsProperty = | ||
AvaloniaProperty.Register<PrivacyWarningFadeOutBehavior, IEnumerable<PrivacyWarning>>(nameof(PreviewWarnings)); | ||
|
||
public IEnumerable<PrivacyWarning> PreviewWarnings | ||
{ | ||
get => GetValue(PreviewWarningsProperty); | ||
set => SetValue(PreviewWarningsProperty, value); | ||
} | ||
|
||
protected override void OnAttachedToVisualTree(CompositeDisposable disposable) | ||
{ | ||
if (AssociatedObject?.DataContext is not PrivacyWarning current) | ||
{ | ||
return; | ||
} | ||
|
||
this.WhenAnyValue(x => x.PreviewWarnings) | ||
.WhereNotNull() | ||
.Do(_ => | ||
{ | ||
var fadeOut = !PreviewWarnings.Any(p => p == current); | ||
if (fadeOut && !AssociatedObject.Classes.Contains(FadeOutClassName)) | ||
{ | ||
AssociatedObject.Classes.Add(FadeOutClassName); | ||
} | ||
else if (!fadeOut && AssociatedObject.Classes.Contains(FadeOutClassName)) | ||
{ | ||
AssociatedObject.Classes.Remove(FadeOutClassName); | ||
} | ||
}) | ||
.Subscribe() | ||
.DisposeWith(disposable); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.