From e93fcf7fbda8ab1fb45404f33b1c3aeb2c5954b6 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 18 Aug 2020 12:54:43 +0200 Subject: [PATCH] show fiat fee amount --- .../com/sparrowwallet/sparrow/io/Bip39.java | 2 +- .../sparrow/wallet/SendController.java | 17 +++++++++++++++++ .../com/sparrowwallet/sparrow/wallet/send.css | 11 +++++++++-- .../com/sparrowwallet/sparrow/wallet/send.fxml | 12 +++++++----- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Bip39.java b/src/main/java/com/sparrowwallet/sparrow/io/Bip39.java index 88ac40f6..3273fea0 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Bip39.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Bip39.java @@ -21,7 +21,7 @@ public class Bip39 implements KeystoreMnemonicImport { @Override public String getKeystoreImportDescription() { - return "Import your 12 to 24 word mnemonic and optional passphrase"; + return "Import or generate your 12 to 24 word mnemonic and optional passphrase"; } @Override diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java index 23b6b044..e5aea47d 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java @@ -73,6 +73,9 @@ public class SendController extends WalletFormController implements Initializabl @FXML private ComboBox feeAmountUnit; + @FXML + private FiatLabel fiatFeeAmount; + @FXML private FeeRatesChart feeRatesChart; @@ -115,6 +118,12 @@ public class SendController extends WalletFormController implements Initializabl @Override public void changed(ObservableValue observable, String oldValue, String newValue) { userFeeSet.set(true); + if(newValue.isEmpty()) { + fiatFeeAmount.setText(""); + } else { + setFiatFeeAmount(AppController.getFiatCurrencyExchangeRate(), getFeeValueSats()); + } + setTargetBlocks(getTargetBlocks()); updateTransaction(); } @@ -390,6 +399,7 @@ public class SendController extends WalletFormController implements Initializabl df.setMaximumFractionDigits(8); fee.setText(df.format(feeAmountUnit.getValue().getValue(feeValue))); fee.textProperty().addListener(feeListener); + setFiatFeeAmount(AppController.getFiatCurrencyExchangeRate(), feeValue); } private Integer getTargetBlocks() { @@ -468,6 +478,12 @@ public class SendController extends WalletFormController implements Initializabl } } + private void setFiatFeeAmount(CurrencyRate currencyRate, Long amount) { + if(amount != null && currencyRate != null && currencyRate.isAvailable()) { + fiatFeeAmount.set(currencyRate, amount); + } + } + private long getRecipientDustThreshold() { Address address; try { @@ -569,5 +585,6 @@ public class SendController extends WalletFormController implements Initializabl @Subscribe public void exchangeRatesUpdated(ExchangeRatesUpdatedEvent event) { setFiatAmount(event.getCurrencyRate(), getRecipientValueSats()); + setFiatFeeAmount(event.getCurrencyRate(), getFeeValueSats()); } } diff --git a/src/main/resources/com/sparrowwallet/sparrow/wallet/send.css b/src/main/resources/com/sparrowwallet/sparrow/wallet/send.css index a93c578c..da5d44b9 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/wallet/send.css +++ b/src/main/resources/com/sparrowwallet/sparrow/wallet/send.css @@ -7,11 +7,18 @@ } .amount-field { - -fx-max-width: 150px; + -fx-pref-width: 145px; + -fx-min-width: 145px; + -fx-max-width: 145px; +} + +.amount-unit { + -fx-min-width: 70px; + -fx-max-width: 70px; } #feeRatesChart { - -fx-max-width: 350px; + -fx-max-width: 335px; -fx-max-height: 130px; } diff --git a/src/main/resources/com/sparrowwallet/sparrow/wallet/send.fxml b/src/main/resources/com/sparrowwallet/sparrow/wallet/send.fxml index 8536609b..9e5f479d 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/wallet/send.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/wallet/send.fxml @@ -29,8 +29,8 @@ - - + + @@ -46,7 +46,7 @@ - + @@ -54,7 +54,7 @@ - +