mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +00:00
toggle fee rate selection on send, dont show zero total rate series
This commit is contained in:
parent
2b55b5feb3
commit
44ac7f3c0e
3 changed files with 62 additions and 8 deletions
|
@ -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<String, Number> {
|
|||
}
|
||||
|
||||
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<String, Number> {
|
|||
for(Long feeRate : SendController.FEE_RATES_RANGE) {
|
||||
XYChart.Series<String, Number> series = new XYChart.Series<>();
|
||||
series.setName(feeRate + "+ vB");
|
||||
long seriesTotalVSize = 0;
|
||||
|
||||
for(Date date : periodRateSizes.keySet()) {
|
||||
Set<MempoolRateSize> rateSizes = periodRateSizes.get(date);
|
||||
|
@ -103,10 +104,14 @@ public class MempoolSizeFeeRatesChart extends StackedAreaChart<String, Number> {
|
|||
}
|
||||
|
||||
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()) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -22,10 +22,12 @@
|
|||
<?import com.sparrowwallet.sparrow.control.FiatLabel?>
|
||||
<?import org.controlsfx.glyphfont.Glyph?>
|
||||
<?import com.sparrowwallet.sparrow.control.MempoolSizeFeeRatesChart?>
|
||||
<?import org.controlsfx.control.SegmentedButton?>
|
||||
<?import com.sparrowwallet.sparrow.wallet.FeeRateSelection?>
|
||||
|
||||
<BorderPane stylesheets="@send.css, @wallet.css, @../script.css, @../general.css" styleClass="wallet-pane" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.wallet.SendController">
|
||||
<center>
|
||||
<VBox spacing="10">
|
||||
<VBox>
|
||||
<GridPane styleClass="send-form" hgap="10.0" vgap="10.0">
|
||||
<padding>
|
||||
<Insets left="25.0" right="25.0" top="25.0" />
|
||||
|
@ -48,12 +50,43 @@
|
|||
<TabPane fx:id="paymentTabs" side="RIGHT" styleClass="initial" />
|
||||
</center>
|
||||
</BorderPane>
|
||||
<Form GridPane.columnIndex="0" GridPane.rowIndex="1">
|
||||
<Fieldset inputGrow="SOMETIMES" text="Fee">
|
||||
<Form styleClass="title-form" GridPane.columnIndex="0" GridPane.rowIndex="1">
|
||||
<Fieldset inputGrow="ALWAYS" text="Fee"/>
|
||||
</Form>
|
||||
<HBox GridPane.columnIndex="1" GridPane.rowIndex="1" GridPane.columnSpan="2" GridPane.halignment="RIGHT" alignment="CENTER_RIGHT">
|
||||
<padding>
|
||||
<Insets right="10.0" />
|
||||
</padding>
|
||||
<SegmentedButton>
|
||||
<toggleGroup>
|
||||
<ToggleGroup fx:id="feeSelectionToggleGroup" />
|
||||
</toggleGroup>
|
||||
<buttons>
|
||||
<ToggleButton fx:id="targetBlocksToggle" text="Target Blocks" toggleGroup="$feeSelectionToggleGroup">
|
||||
<tooltip>
|
||||
<Tooltip text="Determine fee via estimated number of blocks"/>
|
||||
</tooltip>
|
||||
<userData>
|
||||
<FeeRateSelection fx:constant="BLOCK_TARGET"/>
|
||||
</userData>
|
||||
</ToggleButton>
|
||||
<ToggleButton fx:id="mempoolSizeToggle" text="Mempool Size" toggleGroup="$feeSelectionToggleGroup">
|
||||
<tooltip>
|
||||
<Tooltip text="Determine fee via current mempool size"/>
|
||||
</tooltip>
|
||||
<userData>
|
||||
<FeeRateSelection fx:constant="MEMPOOL_SIZE"/>
|
||||
</userData>
|
||||
</ToggleButton>
|
||||
</buttons>
|
||||
</SegmentedButton>
|
||||
</HBox>
|
||||
<Form GridPane.columnIndex="0" GridPane.rowIndex="2">
|
||||
<Fieldset inputGrow="SOMETIMES">
|
||||
<Field fx:id="targetBlocksField" text="Block target">
|
||||
<Slider fx:id="targetBlocks" snapToTicks="true" showTickLabels="true" showTickMarks="true" />
|
||||
</Field>
|
||||
<Field fx:id="feeRangeField" text="Range:">
|
||||
<Field fx:id="feeRangeField" text="Rate Range:">
|
||||
<Slider fx:id="feeRange" snapToTicks="false" showTickLabels="true" showTickMarks="true" />
|
||||
</Field>
|
||||
<Field fx:id="feeRateField" text="Rate:">
|
||||
|
@ -74,7 +107,7 @@
|
|||
</Field>
|
||||
</Fieldset>
|
||||
</Form>
|
||||
<AnchorPane GridPane.columnIndex="1" GridPane.rowIndex="1" GridPane.columnSpan="2">
|
||||
<AnchorPane GridPane.columnIndex="1" GridPane.rowIndex="2" GridPane.columnSpan="2">
|
||||
<BlockTargetFeeRatesChart fx:id="blockTargetFeeRatesChart" styleClass="feeRatesChart" legendVisible="false" AnchorPane.topAnchor="10" AnchorPane.leftAnchor="20" animated="false">
|
||||
<xAxis>
|
||||
<CategoryAxis side="BOTTOM" />
|
||||
|
|
Loading…
Reference in a new issue