add control for text hiding
MODIFY
WalletWasabi.Fluent/App.axaml
WalletWasabi.Fluent/App.axaml
<StyleInclude Source="avares://WalletWasabi.Fluent/Controls/TileControl.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Controls/StatusItem.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Controls/PrivacyContentControl.axaml" />
+ <StyleInclude Source="avares://WalletWasabi.Fluent/Controls/PrivacyTextControl.axaml" />
</Application.Styles>
<NativeMenu.Menu>
<NativeMenu>

MODIFY
WalletWasabi.Fluent/Controls/PrivacyContentControl.axaml.cs
WalletWasabi.Fluent/Controls/PrivacyContentControl.axaml.cs
@@ -9,6 +9,8 @@ namespace WalletWasabi.Fluent.Controls
{
public class PrivacyContentControl : ContentControl
{
+ private CompositeDisposable? _disposable;
+
public static readonly StyledProperty<bool> PrivacyModeEnabledProperty =
AvaloniaProperty.Register<PrivacyContentControl, bool>(nameof(PrivacyModeEnabled));
@@ -18,8 +20,6 @@ namespace WalletWasabi.Fluent.Controls
set => SetValue(PrivacyModeEnabledProperty, value);
}
- private CompositeDisposable? _disposable;
-
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
{
base.OnAttachedToVisualTree(e);

ADD
WalletWasabi.Fluent/Controls/PrivacyTextControl.axaml
+<Styles xmlns="https://github.com/avaloniaui"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:controls="using:WalletWasabi.Fluent.Controls"
+ xmlns:conv="clr-namespace:WalletWasabi.Fluent.Converters">
+ <Design.PreviewWith>
+ <controls:PrivacyTextControl />
+ </Design.PreviewWith>
+
+ <Style Selector="controls|PrivacyTextControl">
+ <Setter Property="Template">
+ <ControlTemplate>
+ <Panel Background="Transparent">
+
+ <TextBlock Name="PART_Text"
+ Text="{TemplateBinding Text}"
+ Opacity="{Binding !#PART_PrivacyText.IsVisible, Converter={x:Static conv:BoolOpacityConverters.BoolToOpacity}}"
+ IsVisible="{Binding $self.Opacity, Converter={x:Static conv:BoolOpacityConverters.OpacityToBool}}" />
+
+ <TextBlock Name="PART_PrivacyText"
+ Text="{TemplateBinding PrivacyText}"
+ Opacity="{TemplateBinding PrivacyModeEnabled, Converter={x:Static conv:BoolOpacityConverters.BoolToOpacity}}"
+ IsVisible="{Binding $self.Opacity, Converter={x:Static conv:BoolOpacityConverters.OpacityToBool}}" />
+
+ </Panel>
+ </ControlTemplate>
+ </Setter>
+ </Style>
+
+ <Style Selector="controls|PrivacyTextControl /template/ TextBlock#PART_PrivacyText">
+ <Setter Property="Transitions">
+ <Transitions>
+ <DoubleTransition Property="Opacity" Duration="0:0:0.3" />
+ </Transitions>
+ </Setter>
+ </Style>
+
+ <Style Selector="controls|PrivacyTextControl /template/ TextBlock#PART_Text">
+ <Setter Property="Transitions">
+ <Transitions>
+ <DoubleTransition Property="Opacity" Duration="0:0:0.3" />
+ </Transitions>
+ </Setter>
+ </Style>
+</Styles>

ADD
WalletWasabi.Fluent/Controls/PrivacyTextControl.axaml.cs
+using Avalonia;
+using System;
+using System.Linq;
+using System.Reactive.Disposables;
+using System.Reactive.Linq;
+using Avalonia.Controls;
+using Avalonia.Controls.Primitives;
+using ReactiveUI;
+
+namespace WalletWasabi.Fluent.Controls
+{
+ public class PrivacyTextControl : TemplatedControl
+ {
+ private const char PrivacyChar = '#';
+
+ private CompositeDisposable? _disposable;
+
+ public static readonly StyledProperty<bool> PrivacyModeEnabledProperty =
+ AvaloniaProperty.Register<PrivacyTextControl, bool>(nameof(PrivacyModeEnabled));
+
+ public static readonly StyledProperty<string> TextProperty =
+ AvaloniaProperty.Register<PrivacyTextControl, string>(nameof(Text));
+
+ public static readonly StyledProperty<string> TextBlockClassesProperty =
+ AvaloniaProperty.Register<PrivacyContentControl, string>(nameof(TextBlockClasses));
+
+ public static readonly StyledProperty<uint> NumberOfPrivacyCharsProperty =
+ AvaloniaProperty.Register<PrivacyContentControl, uint>(nameof(NumberOfPrivacyChars), 5);
+
+ public static readonly StyledProperty<string> PrivacyTextProperty =
+ AvaloniaProperty.Register<PrivacyContentControl, string>(nameof(PrivacyText));
+
+ private bool PrivacyModeEnabled
+ {
+ get => GetValue(PrivacyModeEnabledProperty);
+ set => SetValue(PrivacyModeEnabledProperty, value);
+ }
+
+ public string Text
+ {
+ get => GetValue(TextProperty);
+ set => SetValue(TextProperty, value);
+ }
+
+ public string TextBlockClasses
+ {
+ get => GetValue(TextBlockClassesProperty);
+ set => SetValue(TextBlockClassesProperty, value);
+ }
+
+ public uint NumberOfPrivacyChars
+ {
+ get => GetValue(NumberOfPrivacyCharsProperty);
+ set => SetValue(NumberOfPrivacyCharsProperty, value);
+ }
+
+ private string PrivacyText
+ {
+ get => GetValue(PrivacyTextProperty);
+ set => SetValue(PrivacyTextProperty, value);
+ }
+
+ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
+ {
+ base.OnApplyTemplate(e);
+
+ var textBlock = e.NameScope.Find<TextBlock>("PART_Text");
+ textBlock.Classes.Add(TextBlockClasses);
+
+ var privacyTextBlock = e.NameScope.Find<TextBlock>("PART_PrivacyText");
+ privacyTextBlock.Classes.Add(TextBlockClasses);
+ }
+
+ protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
+ {
+ base.OnAttachedToVisualTree(e);
+
+ _disposable = new CompositeDisposable();
+
+ Services.UiConfig
+ .WhenAnyValue(x => x.PrivacyMode)
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .Subscribe(value => PrivacyModeEnabled = value)
+ .DisposeWith(_disposable);
+
+ PrivacyText = new string(Enumerable.Repeat(PrivacyChar, (int) NumberOfPrivacyChars).ToArray());
+ }
+
+ protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
+ {
+ base.OnDetachedFromVisualTree(e);
+
+ _disposable?.Dispose();
+ _disposable = null;
+ }
+ }
+}

add control for text hiding