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

Fix error and improve wording for security deposit #2511

Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,9 @@ createOffer.changePrice=Change price
createOffer.tac=With publishing this offer I agree to trade with any trader who fulfills the conditions as defined in this screen.
createOffer.currencyForFee=Trade fee
createOffer.setDeposit=Set buyer's security deposit (%)
createOffer.setDepositAsBuyer=Set my security deposit as buyer (%)
createOffer.securityDepositInfo=Your buyer''s security deposit will be {0}
createOffer.securityDepositInfoAsBuyer=Your security deposit as buyer will be {0}


####################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel> extends
private FundsTextField totalToPayTextField;
private Label amountDescriptionLabel, priceCurrencyLabel, priceDescriptionLabel, volumeDescriptionLabel,
waitingForFundsLabel, marketBasedPriceLabel, percentagePriceDescription, tradeFeeDescriptionLabel,
resultLabel, tradeFeeInBtcLabel, tradeFeeInBsqLabel, xLabel, fakeXLabel;
resultLabel, tradeFeeInBtcLabel, tradeFeeInBsqLabel, xLabel, fakeXLabel, buyerSecurityDepositLabel;
protected Label amountBtcLabel, volumeCurrencyLabel, minAmountBtcLabel;
private ComboBox<PaymentAccount> paymentAccountsComboBox;
private ComboBox<TradeCurrency> currencyComboBox;
Expand Down Expand Up @@ -578,6 +578,7 @@ private void addBindings() {
totalToPayTextField.textProperty().bind(model.totalToPay);
addressTextField.amountAsCoinProperty().bind(model.getDataModel().getMissingCoin());
buyerSecurityDepositInputTextField.textProperty().bindBidirectional(model.buyerSecurityDeposit);
buyerSecurityDepositLabel.textProperty().bind(model.buyerSecurityDepositLabel);
tradeFeeInBtcLabel.textProperty().bind(model.tradeFeeInBtcWithFiat);
tradeFeeInBsqLabel.textProperty().bind(model.tradeFeeInBsqWithFiat);
tradeFeeDescriptionLabel.textProperty().bind(model.tradeFeeDescription);
Expand Down Expand Up @@ -628,6 +629,7 @@ private void removeBindings() {
totalToPayTextField.textProperty().unbind();
addressTextField.amountAsCoinProperty().unbind();
buyerSecurityDepositInputTextField.textProperty().unbindBidirectional(model.buyerSecurityDeposit);
buyerSecurityDepositLabel.textProperty().unbind();
tradeFeeInBtcLabel.textProperty().unbind();
tradeFeeInBsqLabel.textProperty().unbind();
tradeFeeDescriptionLabel.textProperty().unbind();
Expand Down Expand Up @@ -767,7 +769,7 @@ private void createListeners() {

buyerSecurityDepositInBTCListener = (observable, oldValue, newValue) -> {
if (!newValue.equals("")) {
Label depositInBTCInfo = createPopoverLabel(Res.get("createOffer.securityDepositInfo", newValue));
Label depositInBTCInfo = createPopoverLabel(model.getSecurityDepositPopOverLabel(newValue));
buyerSecurityDepositInfoInputTextField.setContentForInfoPopOver(depositInBTCInfo);
} else {
buyerSecurityDepositInfoInputTextField.setContentForInfoPopOver(null);
Expand Down Expand Up @@ -1127,7 +1129,9 @@ private VBox getBuyerSecurityDepositBox() {
// getEditableValueBox delivers BTC, so we overwrite it with %
buyerSecurityDepositPercentageLabel.setText("%");

VBox depositBox = getTradeInputBox(tuple.first, Res.get("createOffer.setDeposit")).second;
Tuple2<Label, VBox> tradeInputBoxTuple = getTradeInputBox(tuple.first, model.getSecurityDepositLabel());
VBox depositBox = tradeInputBoxTuple.second;
buyerSecurityDepositLabel = tradeInputBoxTuple.first;
depositBox.setMaxWidth(310);

editOfferElements.add(buyerSecurityDepositInputTextField);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
public final StringProperty minAmount = new SimpleStringProperty();
final StringProperty buyerSecurityDeposit = new SimpleStringProperty();
final StringProperty buyerSecurityDepositInBTC = new SimpleStringProperty();
final StringProperty buyerSecurityDepositLabel = new SimpleStringProperty();

// Price in the viewModel is always dependent on fiat/altcoin: Fiat Fiat/BTC, for altcoins we use inverted price.
// The domain (dataModel) uses always the same price model (otherCurrencyBTC)
Expand Down Expand Up @@ -461,7 +462,8 @@ private void createListeners() {
securityDepositAsDoubleListener = (ov, oldValue, newValue) -> {
if (newValue != null) {
buyerSecurityDeposit.set(btcFormatter.formatToPercent((double) newValue));
buyerSecurityDepositInBTC.set(btcFormatter.formatCoinWithCode(dataModel.getBuyerSecurityDepositAsCoin()));
if (dataModel.getAmount().get() != null)
buyerSecurityDepositInBTC.set(btcFormatter.formatCoinWithCode(dataModel.getBuyerSecurityDepositAsCoin()));
} else {
buyerSecurityDeposit.set("");
buyerSecurityDepositInBTC.set("");
Expand Down Expand Up @@ -599,6 +601,7 @@ boolean initWithData(OfferPayload.Direction direction, TradeCurrency tradeCurren
isBuy ? Res.get("shared.buy") : Res.get("shared.sell"));

buyerSecurityDeposit.set(btcFormatter.formatToPercent(dataModel.getBuyerSecurityDeposit().get()));
buyerSecurityDepositLabel.set(getSecurityDepositLabel());

applyMakerFee();
return result;
Expand Down Expand Up @@ -919,6 +922,15 @@ public String getTradeAmount() {
return btcFormatter.formatCoinWithCode(dataModel.getAmount().get());
}

public String getSecurityDepositLabel() {
return dataModel.isBuyOffer() ? Res.get("createOffer.setDepositAsBuyer") : Res.get("createOffer.setDeposit");
}

public String getSecurityDepositPopOverLabel(String depositInBTC) {
return dataModel.isBuyOffer() ? Res.get("createOffer.securityDepositInfoAsBuyer", depositInBTC) :
Res.get("createOffer.securityDepositInfo", depositInBTC);
}

public String getSecurityDepositInfo() {
return btcFormatter.formatCoinWithCode(dataModel.getSecurityDeposit()) +
GUIUtil.getPercentageOfTradeAmount(dataModel.getSecurityDeposit(), dataModel.getAmount().get(), btcFormatter);
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/main/java/bisq/desktop/util/FormBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -1618,7 +1618,7 @@ public static Tuple3<HBox, InfoInputTextField, Label> getNonEditableValueBoxWith
public static Tuple2<Label, VBox> getTradeInputBox(Pane amountValueBox, String descriptionText) {
Label descriptionLabel = new AutoTooltipLabel(descriptionText);
descriptionLabel.setId("input-description-label");
descriptionLabel.setPrefWidth(170);
descriptionLabel.setPrefWidth(190);

VBox box = new VBox();
box.setPadding(new Insets(10, 0, 0, 0));
Expand Down