mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-20 10:22:18 +01:00
Use inverted price for altcoins, remove invert button
This commit is contained in:
parent
e522fed5d1
commit
789090cf62
@ -117,7 +117,12 @@ public final class Preferences implements Persistable {
|
||||
private TradeCurrency preferredTradeCurrency;
|
||||
private long nonTradeTxFeePerKB = FeePolicy.getNonTradeFeePerKb().value;
|
||||
private double maxPriceDistanceInPercent;
|
||||
|
||||
// Need to keep it for backward compatibility. Not used anymore from v0.4.9 on.
|
||||
// TODO Can be removed once we don't support old versions anymore.
|
||||
@Deprecated
|
||||
private boolean useInvertedMarketPrice;
|
||||
|
||||
private boolean useStickyMarketPrice = false;
|
||||
private boolean usePercentageBasedPrice = false;
|
||||
private Map<String, String> peerTagMap = new HashMap<>();
|
||||
@ -127,7 +132,6 @@ public final class Preferences implements Persistable {
|
||||
// Observable wrappers
|
||||
transient private final StringProperty btcDenominationProperty = new SimpleStringProperty(btcDenomination);
|
||||
transient private final BooleanProperty useAnimationsProperty = new SimpleBooleanProperty(useAnimations);
|
||||
transient private final BooleanProperty useInvertedMarketPriceProperty = new SimpleBooleanProperty(useInvertedMarketPrice);
|
||||
transient private final ObservableList<FiatCurrency> fiatCurrenciesAsObservable = FXCollections.observableArrayList();
|
||||
transient private final ObservableList<CryptoCurrency> cryptoCurrenciesAsObservable = FXCollections.observableArrayList();
|
||||
transient private final ObservableList<TradeCurrency> tradeCurrenciesAsObservable = FXCollections.observableArrayList();
|
||||
@ -148,7 +152,6 @@ public final class Preferences implements Persistable {
|
||||
if (persisted != null) {
|
||||
setBtcDenomination(persisted.btcDenomination);
|
||||
setUseAnimations(persisted.useAnimations);
|
||||
setUseInvertedMarketPrice(persisted.useInvertedMarketPrice);
|
||||
|
||||
setFiatCurrencies(persisted.fiatCurrencies);
|
||||
fiatCurrencies = new ArrayList<>(fiatCurrenciesAsObservable);
|
||||
@ -221,10 +224,6 @@ public final class Preferences implements Persistable {
|
||||
staticUseAnimations = useAnimations;
|
||||
storage.queueUpForSave(2000);
|
||||
});
|
||||
useInvertedMarketPriceProperty.addListener((ov) -> {
|
||||
useInvertedMarketPrice = useInvertedMarketPriceProperty.get();
|
||||
storage.queueUpForSave(2000);
|
||||
});
|
||||
fiatCurrenciesAsObservable.addListener((Observable ov) -> {
|
||||
fiatCurrencies.clear();
|
||||
fiatCurrencies.addAll(fiatCurrenciesAsObservable);
|
||||
@ -265,10 +264,6 @@ public final class Preferences implements Persistable {
|
||||
this.useAnimationsProperty.set(useAnimations);
|
||||
}
|
||||
|
||||
public void setUseInvertedMarketPrice(boolean useInvertedMarketPrice) {
|
||||
this.useInvertedMarketPriceProperty.set(useInvertedMarketPrice);
|
||||
}
|
||||
|
||||
public void setBitcoinNetwork(BitcoinNetwork bitcoinNetwork) {
|
||||
if (this.bitcoinNetwork != bitcoinNetwork)
|
||||
bitsquareEnvironment.saveBitcoinNetwork(bitcoinNetwork);
|
||||
@ -375,11 +370,6 @@ public final class Preferences implements Persistable {
|
||||
storage.queueUpForSave();
|
||||
}
|
||||
|
||||
public boolean flipUseInvertedMarketPrice() {
|
||||
setUseInvertedMarketPrice(!getUseInvertedMarketPrice());
|
||||
return getUseInvertedMarketPrice();
|
||||
}
|
||||
|
||||
public void setUseStickyMarketPrice(boolean useStickyMarketPrice) {
|
||||
this.useStickyMarketPrice = useStickyMarketPrice;
|
||||
storage.queueUpForSave();
|
||||
@ -431,19 +421,10 @@ public final class Preferences implements Persistable {
|
||||
return useAnimationsProperty;
|
||||
}
|
||||
|
||||
|
||||
public static boolean useAnimations() {
|
||||
return staticUseAnimations;
|
||||
}
|
||||
|
||||
public boolean getUseInvertedMarketPrice() {
|
||||
return useInvertedMarketPriceProperty.get();
|
||||
}
|
||||
|
||||
public BooleanProperty useInvertedMarketPriceProperty() {
|
||||
return useInvertedMarketPriceProperty;
|
||||
}
|
||||
|
||||
public BitcoinNetwork getBitcoinNetwork() {
|
||||
return bitcoinNetwork;
|
||||
}
|
||||
|
@ -174,6 +174,11 @@ bg color of non edit textFields: fafafa
|
||||
-fx-cursor: hand;
|
||||
}
|
||||
|
||||
.copy-icon-disputes {
|
||||
-fx-text-fill: white;
|
||||
-fx-cursor: hand;
|
||||
}
|
||||
|
||||
.copy-icon:hover {
|
||||
-fx-text-fill: black;
|
||||
}
|
||||
|
@ -158,8 +158,8 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||
PriceFeed.Type type = model.typeProperty.get();
|
||||
return type != null ? "Market price (" + type.name + ")" : "";
|
||||
},
|
||||
model.marketPriceCurrency, model.typeProperty));
|
||||
HBox.setMargin(marketPriceBox.third, new Insets(0, 0, 0, 0));
|
||||
model.marketPriceCurrencyCode, model.typeProperty));
|
||||
HBox.setMargin(marketPriceBox.third, new Insets(0, 15, 0, 0));
|
||||
|
||||
|
||||
Tuple2<TextField, VBox> availableBalanceBox = getBalanceBox("Available balance");
|
||||
@ -293,23 +293,10 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||
buttonCell.setId("price-feed-combo");
|
||||
priceComboBox.setButtonCell(buttonCell);
|
||||
|
||||
|
||||
final ImageView invertIcon = new ImageView();
|
||||
invertIcon.setId("invert");
|
||||
final Button invertIconButton = new Button("", invertIcon);
|
||||
invertIconButton.setPadding(new Insets(0, 0, 0, 0));
|
||||
invertIconButton.setFocusTraversable(false);
|
||||
invertIconButton.setStyle("-fx-background-color: transparent;");
|
||||
HBox.setMargin(invertIconButton, new Insets(2, 0, 0, 0));
|
||||
invertIconButton.setOnAction(e -> model.preferences.flipUseInvertedMarketPrice());
|
||||
|
||||
HBox hBox = new HBox();
|
||||
hBox.getChildren().setAll(priceComboBox, invertIconButton);
|
||||
|
||||
Label label = new Label(text);
|
||||
label.setId("nav-balance-label");
|
||||
label.setTextAlignment(TextAlignment.CENTER);
|
||||
label.setPadding(new Insets(0, 8, 0, 3));
|
||||
label.setPadding(new Insets(0, 10, 0, 10));
|
||||
|
||||
final ImageView btcAverageIcon = new ImageView();
|
||||
btcAverageIcon.setId("btcaverage");
|
||||
@ -317,7 +304,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||
btcAverageIconButton.setPadding(new Insets(-1, 0, -1, 0));
|
||||
btcAverageIconButton.setFocusTraversable(false);
|
||||
btcAverageIconButton.setStyle("-fx-background-color: transparent;");
|
||||
HBox.setMargin(btcAverageIconButton, new Insets(-1, 28, 0, 0));
|
||||
HBox.setMargin(btcAverageIconButton, new Insets(-1, 10, 0, 0));
|
||||
btcAverageIconButton.setOnAction(e -> Utilities.openWebPage("https://bitcoinaverage.com"));
|
||||
btcAverageIconButton.visibleProperty().bind(model.isFiatCurrencyPriceFeedSelected);
|
||||
btcAverageIconButton.managedProperty().bind(model.isFiatCurrencyPriceFeedSelected);
|
||||
@ -329,7 +316,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||
poloniexIconButton.setPadding(new Insets(-3, 0, -3, 0));
|
||||
poloniexIconButton.setFocusTraversable(false);
|
||||
poloniexIconButton.setStyle("-fx-background-color: transparent;");
|
||||
HBox.setMargin(poloniexIconButton, new Insets(1, 28, 0, 0));
|
||||
HBox.setMargin(poloniexIconButton, new Insets(1, 10, 0, 0));
|
||||
poloniexIconButton.setOnAction(e -> Utilities.openWebPage("https://poloniex.com"));
|
||||
poloniexIconButton.visibleProperty().bind(model.isCryptoCurrencyPriceFeedSelected);
|
||||
poloniexIconButton.managedProperty().bind(model.isCryptoCurrencyPriceFeedSelected);
|
||||
@ -340,12 +327,12 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||
|
||||
HBox hBox2 = new HBox();
|
||||
hBox2.getChildren().setAll(label, spacer, btcAverageIconButton, poloniexIconButton);
|
||||
hBox2.prefWidthProperty().bind(hBox.widthProperty());
|
||||
hBox2.prefWidthProperty().bind(priceComboBox.widthProperty());
|
||||
|
||||
VBox vBox = new VBox();
|
||||
vBox.setSpacing(3);
|
||||
vBox.setPadding(new Insets(11, 0, 0, 0));
|
||||
vBox.getChildren().addAll(hBox, hBox2);
|
||||
vBox.getChildren().addAll(priceComboBox, hBox2);
|
||||
return new Tuple3<>(priceComboBox, label, vBox);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class MainViewModel implements ViewModel {
|
||||
final StringProperty btcSplashSyncIconId = new SimpleStringProperty();
|
||||
final StringProperty marketPrice = new SimpleStringProperty("N/A");
|
||||
final StringProperty marketPriceInverted = new SimpleStringProperty("N/A");
|
||||
final StringProperty marketPriceCurrency = new SimpleStringProperty("");
|
||||
final StringProperty marketPriceCurrencyCode = new SimpleStringProperty("");
|
||||
final ObjectProperty<PriceFeed.Type> typeProperty = new SimpleObjectProperty<>(PriceFeed.Type.LAST);
|
||||
final ObjectProperty<PriceFeedComboBoxItem> selectedPriceFeedComboBoxItemProperty = new SimpleObjectProperty<>();
|
||||
final BooleanProperty isFiatCurrencyPriceFeedSelected = new SimpleBooleanProperty(true);
|
||||
@ -738,14 +738,16 @@ public class MainViewModel implements ViewModel {
|
||||
marketPrice.set("N/A");
|
||||
marketPriceInverted.set("N/A");
|
||||
});
|
||||
marketPriceCurrency.bind(priceFeed.currencyCodeProperty());
|
||||
marketPriceCurrencyCode.bind(priceFeed.currencyCodeProperty());
|
||||
typeProperty.bind(priceFeed.typeProperty());
|
||||
|
||||
marketPriceBinding = EasyBind.combine(
|
||||
marketPriceCurrency, marketPrice, marketPriceInverted, preferences.useInvertedMarketPriceProperty(),
|
||||
(marketPriceCurrency, marketPrice, marketPriceInverted, useInvertedMarketPrice) ->
|
||||
(useInvertedMarketPrice ? marketPriceInverted : marketPrice) +
|
||||
(useInvertedMarketPrice ? " BTC/" + marketPriceCurrency : " " + marketPriceCurrency + "/BTC"));
|
||||
marketPriceCurrencyCode, marketPrice, marketPriceInverted,
|
||||
(marketPriceCurrencyCode, marketPrice, marketPriceInverted) -> {
|
||||
boolean useInvertedMarketPrice = CurrencyUtil.isCryptoCurrency(marketPriceCurrencyCode);
|
||||
return (useInvertedMarketPrice ? marketPriceInverted : marketPrice) +
|
||||
(useInvertedMarketPrice ? " BTC/" + marketPriceCurrencyCode : " " + marketPriceCurrencyCode + "/BTC");
|
||||
});
|
||||
|
||||
marketPriceBinding.subscribe((observable, oldValue, newValue) -> {
|
||||
if (newValue != null && !newValue.equals(oldValue)) {
|
||||
@ -793,7 +795,7 @@ public class MainViewModel implements ViewModel {
|
||||
priceFeedComboBoxItems.stream().forEach(item -> {
|
||||
String currencyCode = item.currencyCode;
|
||||
MarketPrice marketPrice = priceFeed.getMarketPrice(currencyCode);
|
||||
boolean useInvertedMarketPrice = preferences.getUseInvertedMarketPrice();
|
||||
boolean useInvertedMarketPrice = CurrencyUtil.isCryptoCurrency(currencyCode);
|
||||
String priceString;
|
||||
String currencyPairString = useInvertedMarketPrice ? "BTC/" + currencyCode : currencyCode + "/BTC";
|
||||
if (marketPrice != null) {
|
||||
@ -816,7 +818,7 @@ public class MainViewModel implements ViewModel {
|
||||
|
||||
public void setPriceFeedComboBoxItem(PriceFeedComboBoxItem item) {
|
||||
if (!preferences.getUseStickyMarketPrice()) {
|
||||
Optional<PriceFeedComboBoxItem> itemOptional = findPriceFeedComboBoxItem(priceFeed.currencyCodeProperty().get());
|
||||
Optional<PriceFeedComboBoxItem> itemOptional = findPriceFeedComboBoxItem(item.currencyCode);
|
||||
if (itemOptional.isPresent())
|
||||
selectedPriceFeedComboBoxItemProperty.set(itemOptional.get());
|
||||
else
|
||||
|
@ -717,7 +717,7 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
|
||||
|
||||
// Need to set it here otherwise style is not correct
|
||||
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY, "16.0");
|
||||
copyIcon.getStyleClass().add("copy-icon");
|
||||
copyIcon.getStyleClass().add("copy-icon-disputes");
|
||||
|
||||
// TODO There are still some cell rendering issues on updates
|
||||
setGraphic(messageAnchorPane);
|
||||
|
Loading…
Reference in New Issue
Block a user