Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace checkbox to reserve necessary funds with slider #1478

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
import javafx.geometry.VPos;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
Expand Down Expand Up @@ -137,7 +136,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
private TextField currencyTextField;
private AddressTextField addressTextField;
private BalanceTextField balanceTextField;
private CheckBox reserveExactAmountCheckbox;
private ToggleButton reserveExactAmountSlider;
private ToggleButton buyerAsTakerWithoutDepositSlider;
private FundsTextField totalToPayTextField;
private Label amountDescriptionLabel, priceCurrencyLabel, priceDescriptionLabel, volumeDescriptionLabel,
Expand Down Expand Up @@ -176,6 +175,8 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
@Setter
private OfferView.OfferActionHandler offerActionHandler;

private int heightAdjustment = -5;


///////////////////////////////////////////////////////////////////////////////////////////
// Constructor, lifecycle
Expand Down Expand Up @@ -436,7 +437,7 @@ private void onShowPayFundsScreen() {
qrCodeImageView.setVisible(true);
balanceTextField.setVisible(true);
cancelButton2.setVisible(true);
reserveExactAmountCheckbox.setVisible(true);
reserveExactAmountSlider.setVisible(true);
}

private void updateOfferElementsStyle() {
Expand Down Expand Up @@ -958,7 +959,7 @@ private void addGridPane() {
}

private void addPaymentGroup() {
paymentTitledGroupBg = addTitledGroupBg(gridPane, gridRow, 1, Res.get("offerbook.createOffer"));
paymentTitledGroupBg = addTitledGroupBg(gridPane, gridRow, 1, Res.get("offerbook.createOffer"), heightAdjustment);
GridPane.setColumnSpan(paymentTitledGroupBg, 2);

HBox paymentGroupBox = new HBox();
Expand All @@ -976,7 +977,7 @@ private void addPaymentGroup() {

GridPane.setRowIndex(paymentGroupBox, gridRow);
GridPane.setColumnSpan(paymentGroupBox, 2);
GridPane.setMargin(paymentGroupBox, new Insets(Layout.FIRST_ROW_DISTANCE, 0, 0, 0));
GridPane.setMargin(paymentGroupBox, new Insets(Layout.FIRST_ROW_DISTANCE + heightAdjustment, 0, 0, 0));
gridPane.getChildren().add(paymentGroupBox);

tradingAccountBoxTuple.first.setMinWidth(800);
Expand Down Expand Up @@ -1012,7 +1013,7 @@ public TradeCurrency fromString(String s) {

private void addAmountPriceGroup() {
amountTitledGroupBg = addTitledGroupBg(gridPane, ++gridRow, 2,
Res.get("createOffer.setAmountPrice"), 25);
Res.get("createOffer.setAmountPrice"), 25 + heightAdjustment);
GridPane.setColumnSpan(amountTitledGroupBg, 2);

addAmountPriceFields();
Expand All @@ -1021,7 +1022,7 @@ private void addAmountPriceGroup() {

private void addOptionsGroup() {
setDepositTitledGroupBg = addTitledGroupBg(gridPane, ++gridRow, 2,
Res.get("shared.advancedOptions"), Layout.COMPACT_GROUP_DISTANCE);
Res.get("shared.advancedOptions"), 25 + heightAdjustment);

securityDepositAndFeeBox = new HBox();
securityDepositAndFeeBox.setSpacing(40);
Expand Down Expand Up @@ -1136,15 +1137,15 @@ private VBox getSecurityDepositBox() {
private void addFundingGroup() {
// don't increase gridRow as we removed button when this gets visible
payFundsTitledGroupBg = addTitledGroupBg(gridPane, gridRow, 3,
Res.get("createOffer.fundsBox.title"), 25);
Res.get("createOffer.fundsBox.title"), 20 + heightAdjustment);
payFundsTitledGroupBg.getStyleClass().add("last");
GridPane.setColumnSpan(payFundsTitledGroupBg, 2);
payFundsTitledGroupBg.setVisible(false);

totalToPayTextField = addFundsTextfield(gridPane, gridRow,
Res.get("shared.totalsNeeded"), Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE);
totalToPayTextField.setVisible(false);
GridPane.setMargin(totalToPayTextField, new Insets(65, 10, 0, 0));
GridPane.setMargin(totalToPayTextField, new Insets(60 + heightAdjustment, 10, 0, 0));

qrCodeImageView = new ImageView();
qrCodeImageView.setVisible(false);
Expand All @@ -1170,15 +1171,15 @@ private void addFundingGroup() {
Res.get("shared.tradeWalletBalance"));
balanceTextField.setVisible(false);

reserveExactAmountCheckbox = FormBuilder.addLabelCheckBox(gridPane, ++gridRow,
Res.get("shared.reserveExactAmount"));

GridPane.setHalignment(reserveExactAmountCheckbox, HPos.LEFT);

reserveExactAmountCheckbox.setVisible(false);
reserveExactAmountCheckbox.setSelected(preferences.getSplitOfferOutput());
reserveExactAmountCheckbox.setOnAction(event -> {
boolean selected = reserveExactAmountCheckbox.isSelected();

reserveExactAmountSlider = FormBuilder.addSlideToggleButton(gridPane, ++gridRow, Res.get("shared.reserveExactAmount"), heightAdjustment);
GridPane.setHalignment(reserveExactAmountSlider, HPos.LEFT);
GridPane.setMargin(reserveExactAmountSlider, new Insets(-5, 0, -5, 0));
reserveExactAmountSlider.setPadding(new Insets(0, 0, 0, 0));
reserveExactAmountSlider.setVisible(false);
reserveExactAmountSlider.setSelected(preferences.getSplitOfferOutput());
reserveExactAmountSlider.setOnAction(event -> {
boolean selected = reserveExactAmountSlider.isSelected();
if (selected != preferences.getSplitOfferOutput()) {
preferences.setSplitOfferOutput(selected);
model.dataModel.setReserveExactAmount(selected);
Expand Down Expand Up @@ -1338,7 +1339,7 @@ private void addAmountPriceFields() {
firstRowHBox.getChildren().addAll(amountBox, xLabel, percentagePriceBox, resultLabel, volumeBox);
GridPane.setColumnSpan(firstRowHBox, 2);
GridPane.setRowIndex(firstRowHBox, gridRow);
GridPane.setMargin(firstRowHBox, new Insets(40, 10, 0, 0));
GridPane.setMargin(firstRowHBox, new Insets(40 + heightAdjustment, 10, 0, 0));
gridPane.getChildren().add(firstRowHBox);
}

Expand Down
Loading