dynamic blockchain form updating, minor tweaks

This commit is contained in:
Craig Raw 2020-09-21 09:06:01 +02:00
parent ea36c63ebb
commit a99114cc6f
7 changed files with 60 additions and 12 deletions

View file

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

View file

@ -0,0 +1,5 @@
package com.sparrowwallet.sparrow.control;
public interface DynamicUpdate {
void update();
}

View file

@ -15,8 +15,8 @@ import org.controlsfx.control.ToggleSwitch;
public class WelcomeDialog extends Dialog<Mode> {
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;

View file

@ -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())) {

View file

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

View file

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

View file

@ -24,6 +24,7 @@
<?import com.sparrowwallet.sparrow.control.SignaturesProgressBar?>
<?import javafx.scene.control.ProgressBar?>
<?import javafx.scene.control.Tooltip?>
<?import com.sparrowwallet.sparrow.control.DynamicForm?>
<GridPane hgap="10.0" vgap="10.0" styleClass="tx-pane" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.transaction.HeadersController" stylesheets="@headers.css, @transaction.css, @../general.css">
<padding>
@ -131,7 +132,7 @@
<Separator GridPane.columnIndex="0" GridPane.rowIndex="5" GridPane.columnSpan="2" styleClass="form-separator"/>
<Form fx:id="blockchainForm" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="6">
<DynamicForm fx:id="blockchainForm" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="6">
<Fieldset text="Blockchain" inputGrow="SOMETIMES">
<Field text="Status:">
<Label fx:id="blockStatus" contentDisplay="RIGHT" graphicTextGap="5" />
@ -146,7 +147,7 @@
<IdLabel fx:id="blockHash" />
</Field>
</Fieldset>
</Form>
</DynamicForm>
<Form fx:id="signingWalletForm" GridPane.columnIndex="0" GridPane.rowIndex="6">
<Fieldset text="Signatures" inputGrow="SOMETIMES">