Confirmation Expected Text moved to FeeTarget Converter
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendTabView.xaml
WalletWasabi.Gui/Controls/WalletExplorer/SendTabView.xaml
<UserControl.Resources>
<converters:AmountForegroundConverter x:Key="AmountForegroundConverter" />
<converters:BooleanStringConverter x:Key="BooleanStringConverter" />
+ <converters:FeeTargetTimeConverter x:Key="FeeTargetTimeConverter" />
<converters:UsdExchangeRateAmountToolTipConverter x:Key="UsdExchangeRateAmountToolTipConverter" />
</UserControl.Resources>
<i:Interaction.Behaviors>
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Spacing="4">
<TextBlock Text="Confirmation Expected In:" VerticalAlignment="Center" />
- <TextBlock Foreground="YellowGreen" Text="{Binding ConfirmationExpectedText}" Width="80" VerticalAlignment="Center" />
+ <TextBlock Foreground="YellowGreen" Text="{Binding FeeTarget, Converter={StaticResource FeeTargetTimeConverter}}" Width="80" VerticalAlignment="Center" />
<Button Content="{Binding FeeText}" ToolTip.Tip="{Binding FeeToolTip}" Command="{Binding FeeRateCommand}" Padding="0" Background="{DynamicResource EditorBackgroundBrush}" BorderBrush="{DynamicResource EditorBackgroundBrush}" VerticalAlignment="Top" />
</StackPanel>
</StackPanel>

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
@@ -43,7 +43,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private int _minimumFeeTarget;
private int _maximumFeeTarget;
private ObservableAsPropertyHelper<bool> _minMaxFeeTargetsEqual;
- private string _confirmationExpectedText;
private string _feeText;
private decimal _usdFee;
private Money _estimatedBtcFee;
@@ -661,29 +660,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
}
- if (feeTarget >= 2 && feeTarget <= 6) // minutes
- {
- ConfirmationExpectedText = $"{feeTarget}0 minutes";
- }
- else if (feeTarget >= 7 && feeTarget <= Constants.OneDayConfirmationTarget) // hours
- {
- var h = feeTarget / 6;
- ConfirmationExpectedText = $"{h} {IfPlural(h, "hour", "hours")}";
- }
- else if (feeTarget >= 145 && feeTarget < Constants.SevenDaysConfirmationTarget) // days
- {
- var d = feeTarget / Constants.OneDayConfirmationTarget;
- ConfirmationExpectedText = $"{d} {IfPlural(d, "day", "days")}";
- }
- else if (feeTarget == Constants.SevenDaysConfirmationTarget)
- {
- ConfirmationExpectedText = "one week";
- }
- else if (feeTarget == -1)
- {
- ConfirmationExpectedText = $"Invalid";
- }
-
if (allFeeEstimate != null)
{
SetFees(allFeeEstimate, feeTarget);
@@ -725,16 +701,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
SetAmountIfMax();
}
- private static string IfPlural(int val, string singular, string plural)
- {
- if (val == 1)
- {
- return singular;
- }
-
- return plural;
- }
-
private void SetAmountIfMax()
{
if (IsMax)
@@ -959,12 +925,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public bool MinMaxFeeTargetsEqual => _minMaxFeeTargetsEqual?.Value ?? false;
- public string ConfirmationExpectedText
- {
- get => _confirmationExpectedText;
- set => this.RaiseAndSetIfChanged(ref _confirmationExpectedText, value);
- }
-
public string FeeText
{
get => _feeText;

ADD
WalletWasabi.Gui/Converters/FeeTargetTimeConverter.cs
+using Avalonia.Data.Converters;
+using System;
+using System.Globalization;
+using WalletWasabi.Helpers;
+using WalletWasabi.Gui.Models;
+
+namespace WalletWasabi.Gui.Converters
+{
+ public class FeeTargetTimeConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is int feeTarget)
+ {
+ if (feeTarget >= 2 && feeTarget <= 6) // minutes
+ {
+ return $"{feeTarget}0 minutes";
+ }
+ else if (feeTarget >= 7 && feeTarget <= Constants.OneDayConfirmationTarget) // hours
+ {
+ var hours = feeTarget / 6;
+ return $"{hours} {IfPlural(hours, "hour", "hours")}";
+ }
+ else if (feeTarget >= 145 && feeTarget < Constants.SevenDaysConfirmationTarget) // days
+ {
+ var days = feeTarget / Constants.OneDayConfirmationTarget;
+ return $"{days} {IfPlural(days, "day", "days")}";
+ }
+ else if (feeTarget == Constants.SevenDaysConfirmationTarget)
+ {
+ return "one week";
+ }
+ else
+ {
+ return "Invalid";
+ }
+ }
+ else
+ {
+ throw new TypeArgumentException(value, typeof(SmartCoinStatus), nameof(value));
+ }
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
+ }
+
+ private static string IfPlural(int val, string singular, string plural)
+ {
+ return val == 1 ? singular : plural;
+ }
+ }
+}

Confirmation Expected Text moved to FeeTarget Converter