show fiat fee amount

This commit is contained in:
Craig Raw 2020-08-18 12:54:43 +02:00
parent 198672a06e
commit e93fcf7fbd
4 changed files with 34 additions and 8 deletions

View file

@ -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

View file

@ -73,6 +73,9 @@ public class SendController extends WalletFormController implements Initializabl
@FXML
private ComboBox<BitcoinUnit> 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<? extends String> 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());
}
}

View file

@ -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;
}

View file

@ -29,8 +29,8 @@
<Insets left="25.0" right="25.0" top="25.0" />
</padding>
<columnConstraints>
<ColumnConstraints prefWidth="385" />
<ColumnConstraints prefWidth="225" />
<ColumnConstraints prefWidth="410" />
<ColumnConstraints prefWidth="200" />
<ColumnConstraints prefWidth="140" />
</columnConstraints>
<rowConstraints>
@ -46,7 +46,7 @@
</Field>
<Field text="Amount:">
<TextField fx:id="amount" styleClass="amount-field" />
<ComboBox fx:id="amountUnit">
<ComboBox fx:id="amountUnit" styleClass="amount-unit">
<items>
<FXCollections fx:factory="observableArrayList">
<BitcoinUnit fx:constant="BTC" />
@ -54,7 +54,7 @@
</FXCollections>
</items>
</ComboBox>
<Region style="-fx-pref-width: 20" />
<Label style="-fx-pref-width: 15" />
<FiatLabel fx:id="fiatAmount" />
<Region style="-fx-pref-width: 20" />
<Button fx:id="maxButton" text="Max" onAction="#setMaxInput" />
@ -71,7 +71,7 @@
</Field>
<Field text="Fee:">
<TextField fx:id="fee" styleClass="amount-field"/>
<ComboBox fx:id="feeAmountUnit">
<ComboBox fx:id="feeAmountUnit" styleClass="amount-unit">
<items>
<FXCollections fx:factory="observableArrayList">
<BitcoinUnit fx:constant="BTC" />
@ -79,6 +79,8 @@
</FXCollections>
</items>
</ComboBox>
<Label style="-fx-pref-width: 15" />
<FiatLabel fx:id="fiatFeeAmount" />
</Field>
</Fieldset>
</Form>