From 44ac7f3c0efeb341c0ea7d695d3aab69f25e2185 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 19 Nov 2020 12:33:33 +0200 Subject: [PATCH] toggle fee rate selection on send, dont show zero total rate series --- .../control/MempoolSizeFeeRatesChart.java | 9 +++- .../sparrow/wallet/SendController.java | 18 +++++++- .../sparrowwallet/sparrow/wallet/send.fxml | 43 ++++++++++++++++--- 3 files changed, 62 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/MempoolSizeFeeRatesChart.java b/src/main/java/com/sparrowwallet/sparrow/control/MempoolSizeFeeRatesChart.java index 0285bc25..645c9121 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/MempoolSizeFeeRatesChart.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/MempoolSizeFeeRatesChart.java @@ -6,7 +6,6 @@ import com.sparrowwallet.sparrow.wallet.SendController; import javafx.application.Platform; import javafx.beans.NamedArg; import javafx.collections.FXCollections; -import javafx.geometry.Pos; import javafx.scene.Cursor; import javafx.scene.Node; import javafx.scene.chart.*; @@ -67,6 +66,7 @@ public class MempoolSizeFeeRatesChart extends StackedAreaChart { } categoryAxis.setGapStartAndEnd(false); + categoryAxis.setTickLabelRotation(0); categoryAxis.setOnMouseMoved(mouseEvent -> { String category = categoryAxis.getValueForDisplay(mouseEvent.getX()); if(category != null) { @@ -92,6 +92,7 @@ public class MempoolSizeFeeRatesChart extends StackedAreaChart { for(Long feeRate : SendController.FEE_RATES_RANGE) { XYChart.Series series = new XYChart.Series<>(); series.setName(feeRate + "+ vB"); + long seriesTotalVSize = 0; for(Date date : periodRateSizes.keySet()) { Set rateSizes = periodRateSizes.get(date); @@ -103,10 +104,14 @@ public class MempoolSizeFeeRatesChart extends StackedAreaChart { } series.getData().add(new XYChart.Data<>(dateFormatter.format(date), totalVSize)); + seriesTotalVSize += totalVSize; + } + + if(seriesTotalVSize > 0) { + getData().add(series); } previousFeeRate = feeRate; - getData().add(series); } if(categories.iterator().hasNext()) { diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java index 8c239d4f..06ddbadc 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java @@ -55,6 +55,15 @@ public class SendController extends WalletFormController implements Initializabl @FXML private TabPane paymentTabs; + @FXML + private ToggleGroup feeSelectionToggleGroup; + + @FXML + private ToggleButton targetBlocksToggle; + + @FXML + private ToggleButton mempoolSizeToggle; + @FXML private Field targetBlocksField; @@ -260,7 +269,14 @@ public class SendController extends WalletFormController implements Initializabl mempoolSizeFeeRatesChart.update(mempoolHistogram); } - updateFeeRateSelection(Config.get().getFeeRateSelection()); + FeeRateSelection feeRateSelection = Config.get().getFeeRateSelection(); + updateFeeRateSelection(feeRateSelection); + feeSelectionToggleGroup.selectToggle(feeRateSelection == FeeRateSelection.BLOCK_TARGET ? targetBlocksToggle : mempoolSizeToggle); + feeSelectionToggleGroup.selectedToggleProperty().addListener((observable, oldValue, newValue) -> { + FeeRateSelection newFeeRateSelection = (FeeRateSelection)newValue.getUserData(); + Config.get().setFeeRateSelection(newFeeRateSelection); + EventManager.get().post(new FeeRateSelectionChangedEvent(newFeeRateSelection)); + }); fee.setTextFormatter(new CoinTextFormatter()); fee.textProperty().addListener(feeListener); diff --git a/src/main/resources/com/sparrowwallet/sparrow/wallet/send.fxml b/src/main/resources/com/sparrowwallet/sparrow/wallet/send.fxml index d7814790..4a583d15 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/wallet/send.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/wallet/send.fxml @@ -22,10 +22,12 @@ + +
- + @@ -48,12 +50,43 @@
-
-
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
- + @@ -74,7 +107,7 @@
- +