From d52bade085605b5c0030bafaf2ae0ca9724b0b90 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Fri, 16 Apr 2021 10:53:05 +0200 Subject: [PATCH] various minor ui improvements --- .../sparrow/wallet/PaymentController.java | 9 +++++++-- .../sparrow/wallet/ReceiveController.java | 5 +++++ .../com/sparrowwallet/sparrow/general.css | 4 ++++ .../com/sparrowwallet/sparrow/wallet/payment.fxml | 14 +++++++++++--- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java index f57905ca..b7aaa9bc 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java @@ -110,7 +110,7 @@ public class PaymentController extends WalletFormController implements Initializ } revalidate(amount, amountListener); - maxButton.setDisable(!isValidRecipientAddress()); + maxButton.setDisable(!isValidAddressAndLabel()); sendController.updateTransaction(); if(validationSupport != null) { @@ -119,6 +119,7 @@ public class PaymentController extends WalletFormController implements Initializ }); label.textProperty().addListener((observable, oldValue, newValue) -> { + maxButton.setDisable(!isValidAddressAndLabel()); sendController.getCreateButton().setDisable(sendController.getWalletTransaction() == null || newValue == null || newValue.isEmpty() || sendController.isInsufficientFeeRate()); sendController.updateTransaction(); }); @@ -136,7 +137,7 @@ public class PaymentController extends WalletFormController implements Initializ } }); - maxButton.setDisable(!isValidRecipientAddress()); + maxButton.setDisable(!isValidAddressAndLabel()); sendController.utxoLabelSelectionProperty().addListener((observable, oldValue, newValue) -> { maxButton.setText("Max" + newValue); }); @@ -175,6 +176,10 @@ public class PaymentController extends WalletFormController implements Initializ } } + private boolean isValidAddressAndLabel() { + return isValidRecipientAddress() && !label.getText().isEmpty(); + } + private Address getRecipientAddress() throws InvalidAddressException { return Address.fromString(address.getText()); } diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/ReceiveController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/ReceiveController.java index 8e1cb2bb..8bb22336 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/ReceiveController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/ReceiveController.java @@ -125,14 +125,19 @@ public class ReceiveController extends WalletFormController implements Initializ if(AppServices.isConnected() && currentOutputs.isEmpty()) { lastUsed.setText("Never"); lastUsed.setGraphic(getUnusedGlyph()); + address.getStyleClass().remove("error"); } else if(!currentOutputs.isEmpty()) { long count = currentOutputs.size(); BlockTransactionHashIndex lastUsedReference = currentOutputs.stream().skip(count - 1).findFirst().get(); lastUsed.setText(lastUsedReference.getHeight() <= 0 ? "Unconfirmed Transaction" : DATE_FORMAT.format(lastUsedReference.getDate())); lastUsed.setGraphic(getWarningGlyph()); + if(!address.getStyleClass().contains("error")) { + address.getStyleClass().add("error"); + } } else { lastUsed.setText("Unknown"); lastUsed.setGraphic(null); + address.getStyleClass().remove("error"); } } diff --git a/src/main/resources/com/sparrowwallet/sparrow/general.css b/src/main/resources/com/sparrowwallet/sparrow/general.css index 6d510fa4..c5445bba 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/general.css +++ b/src/main/resources/com/sparrowwallet/sparrow/general.css @@ -15,6 +15,10 @@ -fx-pref-height: 25px; } +.form .fieldset:horizontal .input-container { + -fx-alignment: center-left; +} + .form .input-container { -fx-spacing: 2; } diff --git a/src/main/resources/com/sparrowwallet/sparrow/wallet/payment.fxml b/src/main/resources/com/sparrowwallet/sparrow/wallet/payment.fxml index 0bf93efd..2d19e81d 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/wallet/payment.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/wallet/payment.fxml @@ -31,10 +31,18 @@
- + + + + + - + + + + + @@ -54,7 +62,7 @@
-
+