mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 23:06:39 +01:00
Add information icon to buyer security deposit showing the deposit amount in BTC
This commit is contained in:
parent
cffa42a7a2
commit
279b38bf2e
5 changed files with 52 additions and 28 deletions
|
@ -417,6 +417,7 @@ 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.securityDepositInfo=Your buyer''s security deposit will be {0}
|
||||
|
||||
|
||||
####################################################################
|
||||
|
|
|
@ -157,25 +157,27 @@ public class InfoInputTextField extends AnchorPane {
|
|||
|
||||
private void setActionHandlers(Node node) {
|
||||
|
||||
currentIcon.setManaged(true);
|
||||
currentIcon.setVisible(true);
|
||||
if (node != null) {
|
||||
currentIcon.setManaged(true);
|
||||
currentIcon.setVisible(true);
|
||||
|
||||
// As we don't use binding here we need to recreate it on mouse over to reflect the current state
|
||||
currentIcon.setOnMouseEntered(e -> {
|
||||
hidePopover = false;
|
||||
showPopOver(node);
|
||||
});
|
||||
currentIcon.setOnMouseExited(e -> {
|
||||
if (popover != null)
|
||||
popover.hide();
|
||||
hidePopover = true;
|
||||
UserThread.runAfter(() -> {
|
||||
if (hidePopover) {
|
||||
// As we don't use binding here we need to recreate it on mouse over to reflect the current state
|
||||
currentIcon.setOnMouseEntered(e -> {
|
||||
hidePopover = false;
|
||||
showPopOver(node);
|
||||
});
|
||||
currentIcon.setOnMouseExited(e -> {
|
||||
if (popover != null)
|
||||
popover.hide();
|
||||
hidePopover = false;
|
||||
}
|
||||
}, 250, TimeUnit.MILLISECONDS);
|
||||
});
|
||||
hidePopover = true;
|
||||
UserThread.runAfter(() -> {
|
||||
if (hidePopover) {
|
||||
popover.hide();
|
||||
hidePopover = false;
|
||||
}
|
||||
}, 250, TimeUnit.MILLISECONDS);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void showPopOver(Node node) {
|
||||
|
|
|
@ -727,7 +727,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs
|
|||
return buyerSecurityDeposit;
|
||||
}
|
||||
|
||||
private Coin getBuyerSecurityDepositAsCoin() {
|
||||
protected Coin getBuyerSecurityDepositAsCoin() {
|
||||
Coin percentOfAmountAsCoin = CoinUtil.getPercentOfAmountAsCoin(buyerSecurityDeposit.get(), amount.get());
|
||||
return getBoundedBuyerSecurityDepositAsCoin(percentOfAmountAsCoin);
|
||||
}
|
||||
|
|
|
@ -136,8 +136,9 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel> extends
|
|||
private BusyAnimation waitingForFundsSpinner;
|
||||
private AutoTooltipButton nextButton, cancelButton1, cancelButton2, placeOfferButton;
|
||||
private Button priceTypeToggleButton;
|
||||
private InputTextField buyerSecurityDepositInputTextField, fixedPriceTextField, marketBasedPriceTextField;
|
||||
protected InputTextField amountTextField, minAmountTextField, volumeTextField;
|
||||
private InputTextField fixedPriceTextField;
|
||||
private InputTextField marketBasedPriceTextField;
|
||||
protected InputTextField amountTextField, minAmountTextField, volumeTextField, buyerSecurityDepositInputTextField;
|
||||
private TextField currencyTextField;
|
||||
private AddressTextField addressTextField;
|
||||
private BalanceTextField balanceTextField;
|
||||
|
@ -161,7 +162,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel> extends
|
|||
priceAsPercentageFocusedListener, getShowWalletFundedNotificationListener,
|
||||
tradeFeeInBtcToggleListener, tradeFeeInBsqToggleListener, tradeFeeVisibleListener;
|
||||
private ChangeListener<String> tradeCurrencyCodeListener, errorMessageListener,
|
||||
marketPriceMarginListener, volumeListener;
|
||||
marketPriceMarginListener, volumeListener, buyerSecurityDepositInBTCListener;
|
||||
private ChangeListener<Number> marketPriceAvailableListener;
|
||||
private EventHandler<ActionEvent> currencyComboBoxSelectionHandler, paymentAccountsComboBoxSelectionHandler;
|
||||
private OfferView.CloseHandler closeHandler;
|
||||
|
@ -169,7 +170,8 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel> extends
|
|||
protected int gridRow = 0;
|
||||
private final List<Node> editOfferElements = new ArrayList<>();
|
||||
private boolean clearXchangeWarningDisplayed, isActivated;
|
||||
private InfoInputTextField marketBasedPriceInfoInputTextField, volumeInfoInputTextField;
|
||||
private InfoInputTextField marketBasedPriceInfoInputTextField, volumeInfoInputTextField,
|
||||
buyerSecurityDepositInfoInputTextField;
|
||||
private AutoTooltipSlideToggleButton tradeFeeInBtcToggle, tradeFeeInBsqToggle;
|
||||
private Text xIcon, fakeXIcon;
|
||||
|
||||
|
@ -761,6 +763,15 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel> extends
|
|||
}
|
||||
};
|
||||
|
||||
buyerSecurityDepositInBTCListener = (observable, oldValue, newValue) -> {
|
||||
if (!newValue.equals("")) {
|
||||
Label depositInBTCInfo = createPopoverLabel(Res.get("createOffer.securityDepositInfo", newValue));
|
||||
buyerSecurityDepositInfoInputTextField.setContentForInfoPopOver(depositInBTCInfo);
|
||||
} else {
|
||||
buyerSecurityDepositInfoInputTextField.setContentForInfoPopOver(null);
|
||||
}
|
||||
};
|
||||
|
||||
volumeListener = (observable, oldValue, newValue) -> {
|
||||
if (!newValue.equals("") && CurrencyUtil.isFiatCurrency(model.tradeCurrencyCode.get())) {
|
||||
volumeInfoInputTextField.setContentForPrivacyPopOver(createPopoverLabel(Res.get("offerbook.info.roundedFiatVolume")));
|
||||
|
@ -860,6 +871,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel> extends
|
|||
model.marketPriceMargin.addListener(marketPriceMarginListener);
|
||||
model.volume.addListener(volumeListener);
|
||||
model.isTradeFeeVisible.addListener(tradeFeeVisibleListener);
|
||||
model.buyerSecurityDepositInBTC.addListener(buyerSecurityDepositInBTCListener);
|
||||
|
||||
tradeFeeInBtcToggle.selectedProperty().addListener(tradeFeeInBtcToggleListener);
|
||||
tradeFeeInBsqToggle.selectedProperty().addListener(tradeFeeInBsqToggleListener);
|
||||
|
@ -892,6 +904,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel> extends
|
|||
model.marketPriceMargin.removeListener(marketPriceMarginListener);
|
||||
model.volume.removeListener(volumeListener);
|
||||
model.isTradeFeeVisible.removeListener(tradeFeeVisibleListener);
|
||||
model.buyerSecurityDepositInBTC.removeListener(buyerSecurityDepositInBTCListener);
|
||||
tradeFeeInBtcToggle.selectedProperty().removeListener(tradeFeeInBtcToggleListener);
|
||||
tradeFeeInBsqToggle.selectedProperty().removeListener(tradeFeeInBsqToggleListener);
|
||||
|
||||
|
@ -1099,9 +1112,10 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel> extends
|
|||
}
|
||||
|
||||
private VBox getBuyerSecurityDepositBox() {
|
||||
Tuple3<HBox, InputTextField, Label> tuple = getEditableValueBox(
|
||||
Tuple3<HBox, InfoInputTextField, Label> tuple = getEditableValueBoxWithInfo(
|
||||
Res.get("createOffer.securityDeposit.prompt"));
|
||||
buyerSecurityDepositInputTextField = tuple.second;
|
||||
buyerSecurityDepositInfoInputTextField = tuple.second;
|
||||
buyerSecurityDepositInputTextField = buyerSecurityDepositInfoInputTextField.getInputTextField();
|
||||
Label buyerSecurityDepositPercentageLabel = tuple.third;
|
||||
// getEditableValueBox delivers BTC, so we overwrite it with %
|
||||
buyerSecurityDepositPercentageLabel.setText("%");
|
||||
|
|
|
@ -105,6 +105,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
public final StringProperty amount = new SimpleStringProperty();
|
||||
public final StringProperty minAmount = new SimpleStringProperty();
|
||||
final StringProperty buyerSecurityDeposit = new SimpleStringProperty();
|
||||
final StringProperty buyerSecurityDepositInBTC = 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)
|
||||
|
@ -420,10 +421,13 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
|
||||
|
||||
amountAsCoinListener = (ov, oldValue, newValue) -> {
|
||||
if (newValue != null)
|
||||
if (newValue != null) {
|
||||
amount.set(btcFormatter.formatCoin(newValue));
|
||||
else
|
||||
buyerSecurityDepositInBTC.set(btcFormatter.formatCoinWithCode(dataModel.getBuyerSecurityDepositAsCoin()));
|
||||
} else {
|
||||
amount.set("");
|
||||
buyerSecurityDepositInBTC.set("");
|
||||
}
|
||||
|
||||
applyMakerFee();
|
||||
};
|
||||
|
@ -455,10 +459,13 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
};
|
||||
|
||||
securityDepositAsDoubleListener = (ov, oldValue, newValue) -> {
|
||||
if (newValue != null)
|
||||
if (newValue != null) {
|
||||
buyerSecurityDeposit.set(btcFormatter.formatToPercent((double) newValue));
|
||||
else
|
||||
buyerSecurityDepositInBTC.set(btcFormatter.formatCoinWithCode(dataModel.getBuyerSecurityDepositAsCoin()));
|
||||
} else {
|
||||
buyerSecurityDeposit.set("");
|
||||
buyerSecurityDepositInBTC.set("");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue