This commit is contained in:
Manfred Karrer 2019-03-07 16:36:54 -05:00
commit 1292f77daa
No known key found for this signature in database
GPG Key ID: 401250966A6B2C46
5 changed files with 26 additions and 7 deletions

View File

@ -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}
####################################################################

View File

@ -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;
@ -578,6 +578,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel> extends
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);
@ -628,6 +629,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel> extends
totalToPayTextField.textProperty().unbind();
addressTextField.amountAsCoinProperty().unbind();
buyerSecurityDepositInputTextField.textProperty().unbindBidirectional(model.buyerSecurityDeposit);
buyerSecurityDepositLabel.textProperty().unbind();
tradeFeeInBtcLabel.textProperty().unbind();
tradeFeeInBsqLabel.textProperty().unbind();
tradeFeeDescriptionLabel.textProperty().unbind();
@ -767,7 +769,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel> extends
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);
@ -1127,7 +1129,9 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel> extends
// 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);

View File

@ -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)
@ -461,7 +462,8 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
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("");
@ -599,6 +601,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
isBuy ? Res.get("shared.buy") : Res.get("shared.sell"));
buyerSecurityDeposit.set(btcFormatter.formatToPercent(dataModel.getBuyerSecurityDeposit().get()));
buyerSecurityDepositLabel.set(getSecurityDepositLabel());
applyMakerFee();
return result;
@ -919,6 +922,15 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
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);

View File

@ -292,8 +292,9 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
}
public String getTradeFee() {
if (trade != null && dataModel.getOffer() != null) {
if (dataModel.getOffer().isCurrencyForMakerFeeBtc() && trade.getTradeAmount() != null) {
if (trade != null && dataModel.getOffer() != null && trade.getTradeAmount() != null) {
if (dataModel.isMaker() && dataModel.getOffer().isCurrencyForMakerFeeBtc() ||
!dataModel.isMaker() && dataModel.getTrade().isCurrencyForTakerFeeBtc()) {
Coin tradeFeeInBTC = dataModel.getTradeFeeInBTC();
String percentage = GUIUtil.getPercentageOfTradeAmount(tradeFeeInBTC, trade.getTradeAmount(), btcFormatter);
return btcFormatter.formatCoinWithCode(tradeFeeInBTC) + percentage;

View File

@ -1618,7 +1618,7 @@ public class FormBuilder {
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));