mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 23:06:39 +01:00
Show minimum security deposit in create offer dialog when used
In the past we allowed the user to enter a percentage of the trade amount although it wasn't used if the minimum security deposit was higher.
This commit is contained in:
parent
9ec10cf0e9
commit
4377a10007
4 changed files with 38 additions and 3 deletions
|
@ -481,6 +481,7 @@ 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}
|
||||
createOffer.minSecurityDepositUsed=Min. buyer security deposit is used
|
||||
|
||||
|
||||
####################################################################
|
||||
|
|
|
@ -713,4 +713,8 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs
|
|||
return GUIUtil.isBootstrappedOrShowPopup(p2PService) &&
|
||||
GUIUtil.canCreateOrTakeOfferOrShowPopup(user, navigation);
|
||||
}
|
||||
|
||||
public boolean isMinBuyerSecurityDeposit() {
|
||||
return !getBuyerSecurityDepositAsCoin().isGreaterThan(Restrictions.getMinBuyerSecurityDepositAsCoin());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,7 +144,8 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
|||
private FundsTextField totalToPayTextField;
|
||||
private Label amountDescriptionLabel, priceCurrencyLabel, priceDescriptionLabel, volumeDescriptionLabel,
|
||||
waitingForFundsLabel, marketBasedPriceLabel, percentagePriceDescription, tradeFeeDescriptionLabel,
|
||||
resultLabel, tradeFeeInBtcLabel, tradeFeeInBsqLabel, xLabel, fakeXLabel, buyerSecurityDepositLabel;
|
||||
resultLabel, tradeFeeInBtcLabel, tradeFeeInBsqLabel, xLabel, fakeXLabel, buyerSecurityDepositLabel,
|
||||
buyerSecurityDepositPercentageLabel;
|
||||
protected Label amountBtcLabel, volumeCurrencyLabel, minAmountBtcLabel;
|
||||
private ComboBox<PaymentAccount> paymentAccountsComboBox;
|
||||
private ComboBox<TradeCurrency> currencyComboBox;
|
||||
|
@ -159,7 +160,8 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
|||
private ChangeListener<Boolean> amountFocusedListener, minAmountFocusedListener, volumeFocusedListener,
|
||||
buyerSecurityDepositFocusedListener, priceFocusedListener, placeOfferCompletedListener,
|
||||
priceAsPercentageFocusedListener, getShowWalletFundedNotificationListener,
|
||||
tradeFeeInBtcToggleListener, tradeFeeInBsqToggleListener, tradeFeeVisibleListener;
|
||||
tradeFeeInBtcToggleListener, tradeFeeInBsqToggleListener, tradeFeeVisibleListener,
|
||||
isMinBuyerSecurityDepositListener;
|
||||
private ChangeListener<String> tradeCurrencyCodeListener, errorMessageListener,
|
||||
marketPriceMarginListener, volumeListener, buyerSecurityDepositInBTCListener;
|
||||
private ChangeListener<Number> marketPriceAvailableListener;
|
||||
|
@ -825,6 +827,18 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
|||
tradeFeeInBsqToggle.setVisible(newValue);
|
||||
}
|
||||
};
|
||||
|
||||
isMinBuyerSecurityDepositListener = ((observable, oldValue, newValue) -> {
|
||||
if (newValue) {
|
||||
// show BTC
|
||||
buyerSecurityDepositPercentageLabel.setText(Res.getBaseCurrencyCode());
|
||||
buyerSecurityDepositInputTextField.setDisable(true);
|
||||
} else {
|
||||
// show %
|
||||
buyerSecurityDepositPercentageLabel.setText("%");
|
||||
buyerSecurityDepositInputTextField.setDisable(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setIsCurrencyForMakerFeeBtc(boolean isCurrencyForMakerFeeBtc) {
|
||||
|
@ -862,6 +876,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
|||
model.volume.addListener(volumeListener);
|
||||
model.isTradeFeeVisible.addListener(tradeFeeVisibleListener);
|
||||
model.buyerSecurityDepositInBTC.addListener(buyerSecurityDepositInBTCListener);
|
||||
model.isMinBuyerSecurityDeposit.addListener(isMinBuyerSecurityDepositListener);
|
||||
|
||||
tradeFeeInBtcToggle.selectedProperty().addListener(tradeFeeInBtcToggleListener);
|
||||
tradeFeeInBsqToggle.selectedProperty().addListener(tradeFeeInBsqToggleListener);
|
||||
|
@ -897,6 +912,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
|||
model.buyerSecurityDepositInBTC.removeListener(buyerSecurityDepositInBTCListener);
|
||||
tradeFeeInBtcToggle.selectedProperty().removeListener(tradeFeeInBtcToggleListener);
|
||||
tradeFeeInBsqToggle.selectedProperty().removeListener(tradeFeeInBsqToggleListener);
|
||||
model.isMinBuyerSecurityDeposit.removeListener(isMinBuyerSecurityDepositListener);
|
||||
|
||||
// focus out
|
||||
amountTextField.focusedProperty().removeListener(amountFocusedListener);
|
||||
|
@ -1105,7 +1121,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
|||
Res.get("createOffer.securityDeposit.prompt"));
|
||||
buyerSecurityDepositInfoInputTextField = tuple.second;
|
||||
buyerSecurityDepositInputTextField = buyerSecurityDepositInfoInputTextField.getInputTextField();
|
||||
Label buyerSecurityDepositPercentageLabel = tuple.third;
|
||||
buyerSecurityDepositPercentageLabel = tuple.third;
|
||||
// getEditableValueBox delivers BTC, so we overwrite it with %
|
||||
buyerSecurityDepositPercentageLabel.setText("%");
|
||||
|
||||
|
|
|
@ -148,6 +148,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
final BooleanProperty showPayFundsScreenDisplayed = new SimpleBooleanProperty();
|
||||
private final BooleanProperty showTransactionPublishedScreen = new SimpleBooleanProperty();
|
||||
final BooleanProperty isWaitingForFunds = new SimpleBooleanProperty();
|
||||
final BooleanProperty isMinBuyerSecurityDeposit = new SimpleBooleanProperty();
|
||||
|
||||
final ObjectProperty<InputValidator.ValidationResult> amountValidationResult = new SimpleObjectProperty<>();
|
||||
final ObjectProperty<InputValidator.ValidationResult> minAmountValidationResult = new SimpleObjectProperty<>();
|
||||
|
@ -300,6 +301,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
dataModel.calculateVolume();
|
||||
dataModel.calculateTotalToPay();
|
||||
}
|
||||
updateBuyerSecurityDeposit();
|
||||
updateButtonDisableState();
|
||||
}
|
||||
};
|
||||
|
@ -1202,6 +1204,18 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
isWaitingForFunds.set(!waitingForFundsText.get().isEmpty());
|
||||
}
|
||||
|
||||
private void updateBuyerSecurityDeposit() {
|
||||
isMinBuyerSecurityDeposit.set(dataModel.isMinBuyerSecurityDeposit());
|
||||
|
||||
if (dataModel.isMinBuyerSecurityDeposit()) {
|
||||
buyerSecurityDepositLabel.set(Res.get("createOffer.minSecurityDepositUsed"));
|
||||
buyerSecurityDeposit.set(btcFormatter.formatCoin(Restrictions.getMinBuyerSecurityDepositAsCoin()));
|
||||
} else {
|
||||
buyerSecurityDepositLabel.set(getSecurityDepositLabel());
|
||||
buyerSecurityDeposit.set(FormattingUtils.formatToPercent(dataModel.getBuyerSecurityDeposit().get()));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateButtonDisableState() {
|
||||
log.debug("updateButtonDisableState");
|
||||
boolean inputDataValid = isBtcInputValid(amount.get()).isValid &&
|
||||
|
|
Loading…
Add table
Reference in a new issue