implement loading as a user control.
MODIFY
WalletWasabi.Fluent/App.axaml
WalletWasabi.Fluent/App.axaml
<StyleInclude Source="avares://WalletWasabi.Fluent/Controls/NavBarTreeItem.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Controls/TileButton.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Controls/QuestionControl.axaml" />
- <StyleInclude Source="avares://WalletWasabi.Fluent/Controls/LoadingControl.axaml" />
</Application.Styles>
<NativeMenu.Menu>
<NativeMenu>

DELETE
WalletWasabi.Fluent/Controls/LoadingControl.axaml
-<Styles xmlns="https://github.com/avaloniaui"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:c="using:WalletWasabi.Fluent.Controls">
-
- <Style Selector="c|LoadingControl">
- <Setter Property="Template">
- <ControlTemplate>
- <DockPanel LastChildFill="True" HorizontalAlignment="Center" VerticalAlignment="Center" MaxWidth="500">
- <TextBlock Text="{TemplateBinding StatusText}" Opacity="0.6" DockPanel.Dock="Bottom" Margin="0 10 0 0" />
- <ProgressBar Value="{TemplateBinding Percent}" IsIndeterminate="{Binding !$self.Value}" DockPanel.Dock="Bottom" />
- <TextBlock Text="This process may take some time depending on the size of your wallet. Grab a coffee or watch a movie."
- TextAlignment="Center" TextWrapping="Wrap" Opacity="0.6" DockPanel.Dock="Bottom" Margin="0 10 0 30" />
- <TextBlock Text="Wasabi is busy crunching data..." TextAlignment="Center" FontSize="22"
- DockPanel.Dock="Bottom" Margin="0 30 0 0" />
- <Viewbox MaxHeight="200" DockPanel.Dock="Top">
- <Image Height="100" Source="/Assets/Loading/loading.png" />
- </Viewbox>
- </DockPanel>
- </ControlTemplate>
- </Setter>
- </Style>
-</Styles>

DELETE
WalletWasabi.Fluent/Controls/LoadingControl.axaml.cs
-using Avalonia;
-using Avalonia.Controls;
-
-namespace WalletWasabi.Fluent.Controls
-{
- public class LoadingControl : UserControl
- {
- public static readonly StyledProperty<double> PercentProperty =
- AvaloniaProperty.Register<LoadingControl, double>(nameof(Percent));
-
- public static readonly StyledProperty<string> StatusTextProperty =
- AvaloniaProperty.Register<LoadingControl, string>(nameof(StatusText));
-
- public double Percent
- {
- get => GetValue(PercentProperty);
- set => SetValue(PercentProperty, value);
- }
-
- public string StatusText
- {
- get => GetValue(StatusTextProperty);
- set => SetValue(StatusTextProperty, value);
- }
- }
-}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/ClosedWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/ClosedWalletViewModel.cs
@@ -17,9 +17,6 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
{
private readonly SmartHeaderChain _smartHeaderChain;
- [AutoNotify] private string _statusText;
- [AutoNotify] private uint _percent;
-
private Stopwatch? _stopwatch;
private uint? _startingFilterIndex;
@@ -27,12 +24,12 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
: base(wallet)
{
_smartHeaderChain = walletManagerViewModel.BitcoinStore.SmartHeaderChain;
- _statusText = " ";
- _percent = 0;
OpenCommand = ReactiveCommand.Create(() => OnOpen(walletManagerViewModel));
}
+ public LoadingControlViewModel Loading { get; } = new ();
+
public override string IconName => "web_asset_regular";
protected override void OnNavigatedTo(bool isInHistory, CompositeDisposable disposables)
@@ -74,14 +71,14 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
return;
}
- Percent = tempPercent;
- var percentText = $"{Percent}% completed";
+ Loading.Percent = tempPercent;
+ var percentText = $"{Loading.Percent}% completed";
var remainingMilliseconds = elapsedMilliseconds / realProcessedFilters * remainingFilterCount;
var userFriendlyTime = TextHelpers.TimeSpanToFriendlyString(TimeSpan.FromMilliseconds(remainingMilliseconds));
var remainingTimeText = string.IsNullOrEmpty(userFriendlyTime) ? "" : $"- {userFriendlyTime} remaining";
- StatusText = $"{percentText} {remainingTimeText}";
+ Loading.StatusText = $"{percentText} {remainingTimeText}";
}
private void OnOpen(WalletManagerViewModel walletManagerViewModel)

ADD
WalletWasabi.Fluent/ViewModels/Wallets/LoadingControlViewModel.cs
+namespace WalletWasabi.Fluent.ViewModels.Wallets
+{
+ public partial class LoadingControlViewModel : ViewModelBase
+ {
+ [AutoNotify] private double _percent;
+ [AutoNotify] private string? _statusText;
+
+ public LoadingControlViewModel()
+ {
+ _statusText = "";
+ _percent = 0;
+ }
+ }
+}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/Views/Wallets/ClosedWalletView.axaml
WalletWasabi.Fluent/Views/Wallets/ClosedWalletView.axaml
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wallets="clr-namespace:WalletWasabi.Fluent.ViewModels.Wallets"
- xmlns:controls="clr-namespace:WalletWasabi.Fluent.Controls"
+ xmlns:local="using:WalletWasabi.Fluent.Views.Wallets"
mc:Ignorable="d" d:DesignWidth="428" d:DesignHeight="371"
+ x:CompileBindings="True"
x:Class="WalletWasabi.Fluent.Views.Wallets.ClosedWalletView"
x:DataType="wallets:ClosedWalletViewModel">
- <controls:LoadingControl Percent="{Binding Percent}"
- StatusText="{Binding StatusText}"/>
+ <local:LoadingControl DataContext="{Binding Loading}" />
</UserControl>

MODIFY
WalletWasabi.Fluent/Views/Wallets/HardwareWallet/ClosedHardwareWalletView.axaml
WalletWasabi.Fluent/Views/Wallets/HardwareWallet/ClosedHardwareWalletView.axaml
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:hardwareWallet="clr-namespace:WalletWasabi.Fluent.ViewModels.Wallets.HardwareWallet"
- xmlns:controls="clr-namespace:WalletWasabi.Fluent.Controls"
+ xmlns:local="using:WalletWasabi.Fluent.Views.Wallets"
mc:Ignorable="d" d:DesignWidth="428" d:DesignHeight="371"
x:DataType="hardwareWallet:ClosedHardwareWalletViewModel"
+ x:CompileBindings="True"
x:Class="WalletWasabi.Fluent.Views.Wallets.HardwareWallet.ClosedHardwareWalletView">
- <controls:LoadingControl Percent="{Binding Percent}"
- StatusText="{Binding StatusText}" />
+ <local:LoadingControl DataContext="{Binding Loading}" />
</UserControl>

ADD
WalletWasabi.Fluent/Views/Wallets/LoadingControl.axaml
+<UserControl xmlns="https://github.com/avaloniaui"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:vm="using:WalletWasabi.Fluent.ViewModels.Wallets"
+ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
+ x:DataType="vm:LoadingControlViewModel"
+ x:Class="WalletWasabi.Fluent.Views.Wallets.LoadingControl">
+ <DockPanel LastChildFill="True" HorizontalAlignment="Center" VerticalAlignment="Center" MaxWidth="500">
+ <TextBlock Text="{Binding StatusText}" Opacity="0.6" DockPanel.Dock="Bottom" Margin="0 10 0 0" />
+ <ProgressBar Value="{Binding Percent}" IsIndeterminate="{Binding !$self.Value}" DockPanel.Dock="Bottom" />
+ <TextBlock
+ Text="This process may take some time depending on the size of your wallet. Grab a coffee or watch a movie."
+ TextAlignment="Center" TextWrapping="Wrap" Opacity="0.6" DockPanel.Dock="Bottom" Margin="0 10 0 30" />
+ <TextBlock Text="Wasabi is busy crunching data..." TextAlignment="Center" FontSize="22"
+ DockPanel.Dock="Bottom" Margin="0 30 0 0" />
+ <Viewbox MaxHeight="200" DockPanel.Dock="Top">
+ <Image Height="100" Source="/Assets/Loading/loading.png" />
+ </Viewbox>
+ </DockPanel>
+</UserControl>
\ No newline at end of file

ADD
WalletWasabi.Fluent/Views/Wallets/LoadingControl.axaml.cs
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace WalletWasabi.Fluent.Views.Wallets
+{
+ public class LoadingControl : UserControl
+ {
+ public LoadingControl()
+ {
+ InitializeComponent();
+ }
+
+ private void InitializeComponent()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+ }
+}
\ No newline at end of file

implement loading as a user control.