Add non-DAO version for fee display

This commit is contained in:
Manfred Karrer 2018-10-28 15:29:49 -05:00
parent b5568b8f1c
commit ac11888ec0
No known key found for this signature in database
GPG Key ID: 401250966A6B2C46
4 changed files with 37 additions and 6 deletions

View File

@ -58,7 +58,7 @@ public class DevEnv {
private static boolean daoActivated = false;
public static boolean isDaoActivated() {
return daoActivated;
return false;
}
public static void setDaoActivated(boolean daoActivated) {

View File

@ -376,6 +376,7 @@ createOffer.warning.sellBelowMarketPrice=You will always get {0}% less than the
createOffer.warning.buyAboveMarketPrice=You will always pay {0}% more than the current market price as the price of your offer will be continuously updated.
createOffer.tradeFee.descriptionBTCOnly=Trade fee
createOffer.tradeFee.descriptionBSQEnabled=Select trade fee currency
createOffer.tradeFee.fiatAndPercent=≈ {0} / {1} of trade amount
# new entries
createOffer.placeOfferButton=Review: Place offer to {0} bitcoin

View File

@ -259,6 +259,13 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel> extends
boolean currencyForMakerFeeBtc = model.getDataModel().isCurrencyForMakerFeeBtc();
tradeFeeInBtcToggle.setSelected(currencyForMakerFeeBtc);
tradeFeeInBsqToggle.setSelected(!currencyForMakerFeeBtc);
if (!DevEnv.isDaoActivated()) {
tradeFeeInBtcToggle.setVisible(false);
tradeFeeInBtcToggle.setManaged(false);
tradeFeeInBsqToggle.setVisible(false);
tradeFeeInBsqToggle.setManaged(false);
}
}
}
@ -785,8 +792,10 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel> extends
private void setIsCurrencyForMakerFeeBtc(boolean isCurrencyForMakerFeeBtc) {
model.setIsCurrencyForMakerFeeBtc(isCurrencyForMakerFeeBtc);
tradeFeeInBtcTextField.setOpacity(isCurrencyForMakerFeeBtc ? 1 : 0.3);
tradeFeeInBsqTextField.setOpacity(isCurrencyForMakerFeeBtc ? 0.3 : 1);
if (DevEnv.isDaoActivated()) {
tradeFeeInBtcTextField.setOpacity(isCurrencyForMakerFeeBtc ? 1 : 0.3);
tradeFeeInBsqTextField.setOpacity(isCurrencyForMakerFeeBtc ? 0.3 : 1);
}
}
private Label createPopoverLabel(String text) {
@ -1343,7 +1352,6 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel> extends
tradeFeeInBsqToggle = new AutoTooltipSlideToggleButton();
tradeFeeInBsqToggle.setText("BSQ");
tradeFeeInBsqToggle.setPadding(new Insets(-9, 5, -9, 5));
//tradeFeeInBsqToggle.setRotate(90);
VBox tradeFeeToggleButtonBox = new VBox();
tradeFeeToggleButtonBox.getChildren().addAll(tradeFeeInBtcToggle, tradeFeeInBsqToggle);

View File

@ -497,13 +497,35 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
Optional<Volume> optionalBtcFeeInFiat = OfferUtil.getFeeInUserFiatCurrency(makerFeeInBtc,
true, preferences, priceFeedService, bsqFormatter);
String btcFeeWithFiatAmount = OfferUtil.getFeeWithFiatAmount(makerFeeInBtc, optionalBtcFeeInFiat, btcFormatter);
tradeFeeInBtcWithFiat.set(btcFeeWithFiatAmount);
if (DevEnv.isDaoActivated()) {
tradeFeeInBtcWithFiat.set(btcFeeWithFiatAmount);
} else {
tradeFeeInBtcWithFiat.set(btcFormatter.formatCoinWithCode(makerFeeAsCoin));
}
Coin makerFeeInBsq = dataModel.getMakerFeeInBsq();
Optional<Volume> optionalBsqFeeInFiat = OfferUtil.getFeeInUserFiatCurrency(makerFeeInBsq,
false, preferences, priceFeedService, bsqFormatter);
String bsqFeeWithFiatAmount = OfferUtil.getFeeWithFiatAmount(makerFeeInBsq, optionalBsqFeeInFiat, bsqFormatter);
tradeFeeInBsqWithFiat.set(bsqFeeWithFiatAmount);
if (DevEnv.isDaoActivated()) {
tradeFeeInBsqWithFiat.set(bsqFeeWithFiatAmount);
} else {
// Before DAO is enabled we show fee as fiat and % in second line
String feeInFiatAsString;
if (optionalBtcFeeInFiat != null && optionalBtcFeeInFiat.isPresent()) {
feeInFiatAsString = btcFormatter.formatVolumeWithCode(optionalBtcFeeInFiat.get());
} else {
feeInFiatAsString = Res.get("shared.na");
}
double amountAsLong = (double) dataModel.getAmount().get().value;
double makerFeeInBtcAsLong = (double) makerFeeInBtc.value;
double percent = makerFeeInBtcAsLong / amountAsLong;
tradeFeeInBsqWithFiat.set(Res.get("createOffer.tradeFee.fiatAndPercent",
feeInFiatAsString,
btcFormatter.formatToPercentWithSymbol(percent)));
}
}
tradeFeeCurrencyCode.set(dataModel.isCurrencyForMakerFeeBtc() ? Res.getBaseCurrencyCode() : "BSQ");
tradeFeeDescription.set(DevEnv.isDaoActivated() ? Res.get("createOffer.tradeFee.descriptionBSQEnabled") :