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 #1426 from nopara73/enum
Use enum instead of strings + fix status gets stucked issue
- Loading branch information
Showing
7 changed files
with
151 additions
and
76 deletions.
There are no files selected for viewing
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
53 changes: 53 additions & 0 deletions
53
WalletWasabi.Gui/Converters/StatusBarStatusStringConverter.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.Data.Converters; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Text; | ||
using WalletWasabi.Gui.Models; | ||
|
||
namespace WalletWasabi.Gui.Converters | ||
{ | ||
public class StatusBarStatusStringConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (value is StatusBarStatus status) | ||
{ | ||
return Convert(status); | ||
} | ||
|
||
throw new InvalidOperationException($"Given value isn't a {nameof(StatusBarStatus)} enum."); | ||
} | ||
|
||
public static string Convert(StatusBarStatus status) | ||
{ | ||
switch (status) | ||
{ | ||
case StatusBarStatus.Ready: return "Ready"; | ||
case StatusBarStatus.CriticalUpdate: return "THE BACKEND WAS UPGRADED WITH BREAKING CHANGES - PLEASE UPDATE YOUR SOFTWARE"; | ||
case StatusBarStatus.OptionalUpdate: return "New Version Is Available"; | ||
case StatusBarStatus.Connecting: return "Connecting..."; | ||
case StatusBarStatus.Synchronizing: return "Synchronizing..."; | ||
case StatusBarStatus.Loading: return "Loading..."; | ||
case StatusBarStatus.SettingUpHardwareWallet: return "Setting up hardware wallet..."; | ||
case StatusBarStatus.ConnectingToHardwareWallet: return "Connecting to hardware wallet..."; | ||
case StatusBarStatus.AcquiringXpubFromHardwareWallet: return "Acquiring xpub from hardware wallet..."; | ||
case StatusBarStatus.AcquiringSignatureFromHardwareWallet: return "Acquiring signature from hardware wallet..."; | ||
case StatusBarStatus.BuildingTransaction: return "Building transaction..."; | ||
case StatusBarStatus.SigningTransaction: return "Signing transaction..."; | ||
case StatusBarStatus.BroadcastingTransaction: return "Broadcasting transaction..."; | ||
case StatusBarStatus.DequeuingSelectedCoins: return "Dequeueing selected coins..."; | ||
default: | ||
{ | ||
Logging.Logger.LogWarning<StatusBarStatusStringConverter>("Status don't have conversion string specified. Calling ToString() on enum."); | ||
return status.ToString(); | ||
} | ||
} | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotSupportedException(); | ||
} | ||
} | ||
} |
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,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace WalletWasabi.Gui.Models | ||
{ | ||
public enum StatusBarStatus | ||
{ | ||
Ready, | ||
CriticalUpdate, | ||
OptionalUpdate, | ||
Connecting, | ||
Synchronizing, | ||
Loading, | ||
SettingUpHardwareWallet, | ||
ConnectingToHardwareWallet, | ||
AcquiringXpubFromHardwareWallet, | ||
AcquiringSignatureFromHardwareWallet, | ||
BuildingTransaction, | ||
SigningTransaction, | ||
BroadcastingTransaction, | ||
DequeuingSelectedCoins | ||
} | ||
} |
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.