reduce vertical spacing and fix issue with custom fee

This commit is contained in:
jmacxx 2021-05-19 11:22:28 -05:00
parent 8221bc54ef
commit 1cf6e76a24
No known key found for this signature in database
GPG key ID: 155297BABFE94A1B
3 changed files with 29 additions and 21 deletions

View file

@ -86,6 +86,7 @@ import javafx.scene.control.Tooltip;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import javafx.geometry.HPos;
import javafx.geometry.Pos;
import javafx.beans.property.BooleanProperty;
@ -189,17 +190,6 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
inputsToggleGroup = new ToggleGroup();
inputsToggleGroupListener = (observable, oldValue, newValue) -> {
useAllInputs.set(newValue == useAllInputsRadioButton);
useCustomFee.setSelected(false);
transactionFeeInputTextField.setEditable(false);
transactionFeeInputTextField.setPromptText(Res.get("funds.withdrawal.useCustomFeeValueInfo"));
transactionFeeInputTextField.setText(String.valueOf(feeService.getTxFeePerVbyte().value));
transactionFeeInputTextField.focusedProperty().addListener(transactionFeeFocusedListener);
feeService.feeUpdateCounterProperty().addListener(transactionFeeChangeListener);
useCustomFee.selectedProperty().addListener(useCustomFeeCheckboxListener);
updateInputSelection();
};
@ -237,7 +227,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
withdrawMemoTextField = addTopLabelInputTextField(gridPane, ++rowIndex,
Res.get("funds.withdrawal.memoLabel", Res.getBaseCurrencyCode())).second;
Tuple3<Label, InputTextField, ToggleButton> customFeeTuple = addTopLabelInputTextFieldSlideToggleButton(gridPane, ++rowIndex,
Tuple3<Label, InputTextField, ToggleButton> customFeeTuple = addTopLabelInputTextFieldSlideToggleButtonRight(gridPane, ++rowIndex,
Res.get("funds.withdrawal.txFee"), Res.get("funds.withdrawal.useCustomFeeValue"));
transactionFeeInputTextField = customFeeTuple.second;
useCustomFee = customFeeTuple.third;
@ -281,9 +271,14 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
}
}
};
transactionFeeChangeListener = (observable, oldValue, newValue) -> transactionFeeInputTextField.setText(String.valueOf(feeService.getTxFeePerVbyte().value));
transactionFeeChangeListener = (observable, oldValue, newValue) -> {
if (!useCustomFee.isSelected()) {
transactionFeeInputTextField.setText(String.valueOf(feeService.getTxFeePerVbyte().value));
}
};
final Button withdrawButton = addButton(gridPane, ++rowIndex, Res.get("funds.withdrawal.withdrawButton"), 15);
final Button withdrawButton = addPrimaryActionButton(gridPane, rowIndex, Res.get("funds.withdrawal.withdrawButton"), 15);
GridPane.setHalignment(withdrawButton, HPos.RIGHT);
withdrawButton.setOnAction(event -> onWithdraw());
@ -740,12 +735,6 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
inputsToggleGroup.selectedToggleProperty().removeListener(inputsToggleGroupListener);
inputsToggleGroup.selectToggle(useCustomInputsRadioButton);
useAllInputs.set(false);
useCustomFee.setSelected(false);
transactionFeeInputTextField.setEditable(false);
transactionFeeInputTextField.setText(String.valueOf(feeService.getTxFeePerVbyte().value));
inputsToggleGroup.selectedToggleProperty().addListener(inputsToggleGroupListener);
}
});

View file

@ -821,6 +821,25 @@ public class FormBuilder {
}
public static Tuple3<Label, InputTextField, ToggleButton> addTopLabelInputTextFieldSlideToggleButtonRight(GridPane gridPane,
int rowIndex,
String title,
String toggleButtonTitle) {
InputTextField inputTextField = new InputTextField();
Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, inputTextField, 0);
ToggleButton toggleButton = new JFXToggleButton();
toggleButton.setText(toggleButtonTitle);
HBox hBox = new HBox();
hBox.getChildren().addAll(topLabelWithVBox.second, toggleButton);
HBox.setMargin(toggleButton, new Insets(9, 0, 0, 0));
gridPane.add(hBox, 0, rowIndex);
GridPane.setMargin(hBox, new Insets(Layout.FLOATING_LABEL_DISTANCE, 0, 0, 0));
return new Tuple3<>(topLabelWithVBox.first, inputTextField, toggleButton);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + InputTextField + Button
///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -25,7 +25,7 @@ public class Layout {
public static final double FIRST_ROW_DISTANCE = 20d;
public static final double COMPACT_FIRST_ROW_DISTANCE = 10d;
public static final double TWICE_FIRST_ROW_DISTANCE = 20d * 2;
public static final double FLOATING_LABEL_DISTANCE = 20d;
public static final double FLOATING_LABEL_DISTANCE = 18d;
public static final double GROUP_DISTANCE = 40d;
public static final double COMPACT_GROUP_DISTANCE = 30d;
public static final double GROUP_DISTANCE_WITHOUT_SEPARATOR = 20d;