mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-20 10:22:18 +01:00
Use correct currency pair for altcoins
This commit is contained in:
parent
6b69c5ee59
commit
e3c8c25a49
@ -741,8 +741,7 @@ public class MainViewModel implements ViewModel {
|
||||
(code, marketPrice) -> {
|
||||
double marketPriceAsDouble = (double) marketPrice;
|
||||
if (marketPriceAsDouble > 0) {
|
||||
String postFix = CurrencyUtil.isCryptoCurrency(code) ? " BTC/" + code : " " + code + "/BTC";
|
||||
return formatter.formatMarketPrice(marketPriceAsDouble, code) + postFix;
|
||||
return formatter.formatMarketPrice(marketPriceAsDouble, code) + " " + formatter.getCurrencyPair(code);
|
||||
} else {
|
||||
return "N/A";
|
||||
}
|
||||
@ -809,8 +808,7 @@ public class MainViewModel implements ViewModel {
|
||||
priceString = "N/A";
|
||||
item.setIsPriceAvailable(false);
|
||||
}
|
||||
String postFix = CurrencyUtil.isCryptoCurrency(code) ? "BTC/" + code : code + "/BTC";
|
||||
item.setDisplayString(priceString + " " + postFix);
|
||||
item.setDisplayString(priceString + " " + formatter.getCurrencyPair(code));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ public class MarketsChartsView extends ActivatableViewAndModel<VBox, MarketsChar
|
||||
String code = tradeCurrency.getCode();
|
||||
String tradeCurrencyName = tradeCurrency.getName();
|
||||
areaChart.setTitle("Offer book for " + tradeCurrencyName);
|
||||
priceColumnLabel.set("Price (" + code + "/BTC)");
|
||||
priceColumnLabel.set("Price (" + formatter.getCurrencyPair(code) + ")");
|
||||
volumeColumnLabel.set("Volume (" + code + ")");
|
||||
xAxis.setLabel(priceColumnLabel.get());
|
||||
xAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(xAxis, "", ""));
|
||||
|
@ -41,10 +41,12 @@ import io.bitsquare.gui.main.overlays.windows.OfferDetailsWindow;
|
||||
import io.bitsquare.gui.main.overlays.windows.QRCodeWindow;
|
||||
import io.bitsquare.gui.main.portfolio.PortfolioView;
|
||||
import io.bitsquare.gui.main.portfolio.openoffer.OpenOffersView;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.FormBuilder;
|
||||
import io.bitsquare.gui.util.GUIUtil;
|
||||
import io.bitsquare.gui.util.Layout;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.locale.CurrencyUtil;
|
||||
import io.bitsquare.locale.TradeCurrency;
|
||||
import io.bitsquare.payment.PaymentAccount;
|
||||
import io.bitsquare.trade.offer.Offer;
|
||||
@ -122,6 +124,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
private EventHandler<ActionEvent> currencyComboBoxSelectionHandler;
|
||||
private int gridRow = 0;
|
||||
private final Preferences preferences;
|
||||
private BSFormatter formatter;
|
||||
private ChangeListener<String> tradeCurrencyCodeListener;
|
||||
private ImageView qrCodeImageView;
|
||||
private HBox fundingHBox;
|
||||
@ -130,6 +133,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
private Subscription balanceSubscription;
|
||||
private List<Node> editOfferElements = new ArrayList<>();
|
||||
private boolean isActivated;
|
||||
private Label xLabel;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -137,12 +141,13 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private CreateOfferView(CreateOfferViewModel model, Navigation navigation, OfferDetailsWindow offerDetailsWindow, Preferences preferences) {
|
||||
private CreateOfferView(CreateOfferViewModel model, Navigation navigation, OfferDetailsWindow offerDetailsWindow, Preferences preferences, BSFormatter formatter) {
|
||||
super(model);
|
||||
|
||||
this.navigation = navigation;
|
||||
this.offerDetailsWindow = offerDetailsWindow;
|
||||
this.preferences = preferences;
|
||||
this.formatter = formatter;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -441,7 +446,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
|
||||
private void addBindings() {
|
||||
amountBtcLabel.textProperty().bind(model.btcCode);
|
||||
priceCurrencyLabel.textProperty().bind(createStringBinding(() -> model.tradeCurrencyCode.get() + "/" + model.btcCode.get(), model.btcCode, model.tradeCurrencyCode));
|
||||
priceCurrencyLabel.textProperty().bind(createStringBinding(() -> formatter.getCurrencyPair(model.tradeCurrencyCode.get()), model.btcCode, model.tradeCurrencyCode));
|
||||
fixedPriceTextField.disableProperty().bind(model.dataModel.useMarketBasedPrice);
|
||||
priceCurrencyLabel.disableProperty().bind(model.dataModel.useMarketBasedPrice);
|
||||
marketBasedPriceTextField.disableProperty().bind(model.dataModel.useMarketBasedPrice.not());
|
||||
@ -449,7 +454,13 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
marketBasedPriceLabel.prefWidthProperty().bind(priceCurrencyLabel.widthProperty());
|
||||
volumeCurrencyLabel.textProperty().bind(model.tradeCurrencyCode);
|
||||
minAmountBtcLabel.textProperty().bind(model.btcCode);
|
||||
priceDescriptionLabel.textProperty().bind(createStringBinding(() -> BSResources.get("createOffer.amountPriceBox.priceDescription", model.tradeCurrencyCode.get()), model.tradeCurrencyCode));
|
||||
priceDescriptionLabel.textProperty().bind(createStringBinding(() -> {
|
||||
String currencyCode = model.tradeCurrencyCode.get();
|
||||
return CurrencyUtil.isCryptoCurrency(currencyCode) ?
|
||||
BSResources.get("createOffer.amountPriceBox.priceDescriptionAltcoin", currencyCode) :
|
||||
BSResources.get("createOffer.amountPriceBox.priceDescriptionFiat", currencyCode);
|
||||
}, model.tradeCurrencyCode));
|
||||
xLabel.textProperty().bind(createStringBinding(() -> CurrencyUtil.isCryptoCurrency(model.tradeCurrencyCode.get()) ? "/" : "x", model.tradeCurrencyCode));
|
||||
volumeDescriptionLabel.textProperty().bind(createStringBinding(model.volumeDescriptionLabel::get, model.tradeCurrencyCode, model.volumeDescriptionLabel));
|
||||
amountTextField.textProperty().bindBidirectional(model.amount);
|
||||
minAmountTextField.textProperty().bindBidirectional(model.minAmount);
|
||||
@ -500,6 +511,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
volumeCurrencyLabel.textProperty().unbind();
|
||||
minAmountBtcLabel.textProperty().unbind();
|
||||
priceDescriptionLabel.textProperty().unbind();
|
||||
xLabel.textProperty().unbind();
|
||||
volumeDescriptionLabel.textProperty().unbind();
|
||||
amountTextField.textProperty().unbindBidirectional(model.amount);
|
||||
minAmountTextField.textProperty().unbindBidirectional(model.minAmount);
|
||||
@ -962,7 +974,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
VBox amountBox = amountInputBoxTuple.second;
|
||||
|
||||
// x
|
||||
Label xLabel = new Label("x");
|
||||
xLabel = new Label();
|
||||
xLabel.setFont(Font.font("Helvetica-Bold", 20));
|
||||
xLabel.setPadding(new Insets(14, 3, 0, 3));
|
||||
|
||||
@ -973,7 +985,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
editOfferElements.add(fixedPriceTextField);
|
||||
priceCurrencyLabel = priceValueCurrencyBoxTuple.third;
|
||||
editOfferElements.add(priceCurrencyLabel);
|
||||
Tuple2<Label, VBox> priceInputBoxTuple = getTradeInputBox(priceValueCurrencyBox, BSResources.get("createOffer.amountPriceBox.priceDescription"));
|
||||
Tuple2<Label, VBox> priceInputBoxTuple = getTradeInputBox(priceValueCurrencyBox, "");
|
||||
priceDescriptionLabel = priceInputBoxTuple.first;
|
||||
editOfferElements.add(priceDescriptionLabel);
|
||||
VBox priceBox = priceInputBoxTuple.second;
|
||||
|
@ -33,6 +33,7 @@ import io.bitsquare.gui.main.funds.withdrawal.WithdrawalView;
|
||||
import io.bitsquare.gui.main.offer.OfferView;
|
||||
import io.bitsquare.gui.main.overlays.popups.Popup;
|
||||
import io.bitsquare.gui.main.overlays.windows.OfferDetailsWindow;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.Layout;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.locale.CryptoCurrency;
|
||||
@ -66,6 +67,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||
|
||||
private final Navigation navigation;
|
||||
private final OfferDetailsWindow offerDetailsWindow;
|
||||
private BSFormatter formatter;
|
||||
|
||||
private ComboBox<TradeCurrency> currencyComboBox;
|
||||
private ComboBox<PaymentMethod> paymentMethodComboBox;
|
||||
@ -85,11 +87,12 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
OfferBookView(OfferBookViewModel model, Navigation navigation, OfferDetailsWindow offerDetailsWindow) {
|
||||
OfferBookView(OfferBookViewModel model, Navigation navigation, OfferDetailsWindow offerDetailsWindow, BSFormatter formatter) {
|
||||
super(model);
|
||||
|
||||
this.navigation = navigation;
|
||||
this.offerDetailsWindow = offerDetailsWindow;
|
||||
this.formatter = formatter;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -233,7 +236,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||
String tradeCurrencyCode = model.tradeCurrencyCode.get();
|
||||
boolean showAllTradeCurrencies = model.showAllTradeCurrenciesProperty.get();
|
||||
priceColumn.setText(!showAllTradeCurrencies ?
|
||||
"Price in " + tradeCurrencyCode + "/BTC" :
|
||||
"Price in " + formatter.getCurrencyPair(tradeCurrencyCode) :
|
||||
"Price");
|
||||
return !showAllTradeCurrencies ?
|
||||
"Amount in " + tradeCurrencyCode + " (Min.)" :
|
||||
|
@ -46,6 +46,7 @@ import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.GUIUtil;
|
||||
import io.bitsquare.gui.util.Layout;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.locale.CurrencyUtil;
|
||||
import io.bitsquare.payment.PaymentAccount;
|
||||
import io.bitsquare.trade.offer.Offer;
|
||||
import io.bitsquare.user.Preferences;
|
||||
@ -167,7 +168,10 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
|
||||
spinner.setProgress(-1);
|
||||
|
||||
volumeCurrencyLabel.setText(model.dataModel.getCurrencyCode());
|
||||
priceDescriptionLabel.setText(BSResources.get("createOffer.amountPriceBox.priceDescription", model.dataModel.getCurrencyCode()));
|
||||
String currencyCode = model.dataModel.getCurrencyCode();
|
||||
priceDescriptionLabel.setText(CurrencyUtil.isCryptoCurrency(currencyCode) ?
|
||||
BSResources.get("createOffer.amountPriceBox.priceDescriptionAltcoin", currencyCode) :
|
||||
BSResources.get("createOffer.amountPriceBox.priceDescriptionFiat", currencyCode));
|
||||
volumeDescriptionLabel.setText(model.volumeDescriptionLabel.get());
|
||||
|
||||
if (model.getPossiblePaymentAccounts().size() > 1) {
|
||||
|
@ -218,7 +218,11 @@ public class BSFormatter {
|
||||
}
|
||||
|
||||
public String formatPriceWithCode(Fiat fiat) {
|
||||
return formatFiatWithCode(fiat) + "/BTC";
|
||||
if (fiat != null) {
|
||||
return formatFiat(fiat) + " " + getCurrencyPair(fiat.getCurrencyCode());
|
||||
} else {
|
||||
return "N/A";
|
||||
}
|
||||
}
|
||||
|
||||
private Fiat parseToFiat(String input, String currencyCode) {
|
||||
@ -507,4 +511,10 @@ public class BSFormatter {
|
||||
return decimalFormat.format(bytes / mb) + " MB";
|
||||
}
|
||||
|
||||
public String getCurrencyPair(String currencyCode) {
|
||||
if (CurrencyUtil.isCryptoCurrency(currencyCode))
|
||||
return "BTC/" + currencyCode;
|
||||
else
|
||||
return currencyCode + "/BTC";
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,8 @@ createOffer.minAmount.prompt=Enter min. amount
|
||||
|
||||
createOffer.amountPriceBox.title=Create your offer
|
||||
createOffer.amountPriceBox.amountDescription=Amount of bitcoin to {0}
|
||||
createOffer.amountPriceBox.priceDescription=Price per bitcoin in {0}
|
||||
createOffer.amountPriceBox.priceDescriptionFiat=Price per bitcoin in {0}
|
||||
createOffer.amountPriceBox.priceDescriptionAltcoin=Price per {0} in bitcoin
|
||||
createOffer.amountPriceBox.buy.volumeDescription=Amount in {0} to spend
|
||||
createOffer.amountPriceBox.sell.volumeDescription=Amount in {0} to receive
|
||||
createOffer.amountPriceBox.minAmountDescription=Minimum amount of bitcoin
|
||||
|
Loading…
Reference in New Issue
Block a user