From a99114cc6fdb69a5c877c18c93675a019b5f0b00 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 21 Sep 2020 09:06:01 +0200 Subject: [PATCH] dynamic blockchain form updating, minor tweaks --- .../sparrow/control/DynamicForm.java | 24 +++++++++++++++++++ .../sparrow/control/DynamicUpdate.java | 5 ++++ .../sparrow/control/WelcomeDialog.java | 4 ++-- .../transaction/HeadersController.java | 21 ++++++++++++++-- .../com/sparrowwallet/sparrow/darktheme.css | 9 +++---- .../sparrow/notificationpopup.css | 4 ++-- .../sparrow/transaction/headers.fxml | 5 ++-- 7 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/sparrowwallet/sparrow/control/DynamicForm.java create mode 100644 src/main/java/com/sparrowwallet/sparrow/control/DynamicUpdate.java diff --git a/src/main/java/com/sparrowwallet/sparrow/control/DynamicForm.java b/src/main/java/com/sparrowwallet/sparrow/control/DynamicForm.java new file mode 100644 index 00000000..da3f73b1 --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/control/DynamicForm.java @@ -0,0 +1,24 @@ +package com.sparrowwallet.sparrow.control; + +import tornadofx.control.Form; + +public class DynamicForm extends Form { + private DynamicUpdate dynamicUpdate; + + public DynamicForm() { + super(); + } + + public void setDynamicUpdate(DynamicUpdate dynamicUpdate) { + this.dynamicUpdate = dynamicUpdate; + } + + @Override + protected void layoutChildren() { + if(dynamicUpdate != null) { + dynamicUpdate.update(); + } + + super.layoutChildren(); + } +} diff --git a/src/main/java/com/sparrowwallet/sparrow/control/DynamicUpdate.java b/src/main/java/com/sparrowwallet/sparrow/control/DynamicUpdate.java new file mode 100644 index 00000000..5a93bf8e --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/control/DynamicUpdate.java @@ -0,0 +1,5 @@ +package com.sparrowwallet.sparrow.control; + +public interface DynamicUpdate { + void update(); +} diff --git a/src/main/java/com/sparrowwallet/sparrow/control/WelcomeDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/WelcomeDialog.java index 65a17fe7..81c850df 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/WelcomeDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/WelcomeDialog.java @@ -15,8 +15,8 @@ import org.controlsfx.control.ToggleSwitch; public class WelcomeDialog extends Dialog { private static final String[] ELECTRUM_SERVERS = new String[]{ "ElectrumX (Recommended)", "https://github.com/spesmilo/electrumx", - "electrs (Experimental)", "https://github.com/romanz/electrs", - "esplora-electrs (Experimental)", "https://github.com/Blockstream/electrs"}; + "electrs", "https://github.com/romanz/electrs", + "esplora-electrs", "https://github.com/Blockstream/electrs"}; private final HostServices hostServices; diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java index 8ff2f99f..bd3500f1 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java @@ -49,7 +49,7 @@ import java.time.*; import java.util.*; import java.util.stream.Collectors; -public class HeadersController extends TransactionFormController implements Initializable { +public class HeadersController extends TransactionFormController implements Initializable, DynamicUpdate { private static final Logger log = LoggerFactory.getLogger(HeadersController.class); public static final String LOCKTIME_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static final String BLOCK_TIMESTAMP_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss ZZZ"; @@ -121,7 +121,7 @@ public class HeadersController extends TransactionFormController implements Init private CopyableLabel feeRate; @FXML - private Form blockchainForm; + private DynamicForm blockchainForm; @FXML private Label blockStatus; @@ -410,6 +410,8 @@ public class HeadersController extends TransactionFormController implements Init EventManager.get().post(new RequestOpenWalletsEvent()); } + + blockchainForm.setDynamicUpdate(this); } private void updateType() { @@ -493,6 +495,8 @@ public class HeadersController extends TransactionFormController implements Init indicator = (ConfirmationProgressIndicator)blockStatus.getGraphic(); indicator.setConfirmations(confirmations); } + } else { + blockStatus.setGraphic(null); } } @@ -779,6 +783,19 @@ public class HeadersController extends TransactionFormController implements Init } } + @Override + public void update() { + BlockTransaction blockTransaction = headersForm.getBlockTransaction(); + Sha256Hash txId = headersForm.getTransaction().getTxId(); + if(headersForm.getSigningWallet() != null && headersForm.getSigningWallet().getTransactions().containsKey(txId)) { + blockTransaction = headersForm.getSigningWallet().getTransactions().get(txId); + } + + if(blockTransaction != null && AppController.getCurrentBlockHeight() != null) { + updateBlockchainForm(blockTransaction, AppController.getCurrentBlockHeight()); + } + } + @Subscribe public void transactionChanged(TransactionChangedEvent event) { if(headersForm.getTransaction().equals(event.getTransaction())) { diff --git a/src/main/resources/com/sparrowwallet/sparrow/darktheme.css b/src/main/resources/com/sparrowwallet/sparrow/darktheme.css index bcfc034c..046c49f2 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/darktheme.css +++ b/src/main/resources/com/sparrowwallet/sparrow/darktheme.css @@ -74,7 +74,7 @@ } .chart .default-color0.chart-series-line { - -fx-stroke: rgba(125, 128, 139, 0.6); + -fx-stroke: rgba(135, 138, 149, 0.6); } .chart .chart-bar { @@ -114,10 +114,11 @@ .root .script-hash { -fx-fill: #d19a66 } .root .script-signature { -fx-fill: #98c379 } .root .script-pubkey { -fx-fill: #c678dd } -.root .script-redeem { -fx-fill: #e06c75 } -.root .script-other { -fx-fill: #b6bdca } +.root .script-redeem { -fx-fill: derive(#e06c75, 20%) } +.root .script-other { -fx-fill: #c8ccd4 } .root #txhex { + -fx-background-color: derive(-fx-control-inner-background, -50%); color-0: #e06c75; color-1: #e5c07b; color-2: #d19a66; @@ -126,7 +127,7 @@ color-5: #56b6c2; color-6: #c678dd; color-7: #be5046; - color-8: #000000; + color-8: #c8ccd4; color-grey: #565c64; } diff --git a/src/main/resources/com/sparrowwallet/sparrow/notificationpopup.css b/src/main/resources/com/sparrowwallet/sparrow/notificationpopup.css index b80e9499..9cfcc69c 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/notificationpopup.css +++ b/src/main/resources/com/sparrowwallet/sparrow/notificationpopup.css @@ -9,14 +9,14 @@ .notification-bar > .pane .label.title { -fx-font-size: 15px; - -fx-text-fill: #292929; + -fx-text-fill: -fx-text-inner-color; -fx-padding: 5 0 0 68; -fx-translate-y: 10; } .notification-bar > .pane .label { -fx-font-size: 1em; - -fx-text-fill: #292929; + -fx-text-fill: -fx-text-inner-color; -fx-alignment: top-left; -fx-padding: 0 0 0 10; -fx-graphic-text-gap: 8; diff --git a/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.fxml b/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.fxml index 81324ab6..74395247 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/transaction/headers.fxml @@ -24,6 +24,7 @@ + @@ -131,7 +132,7 @@ -
+
- +