mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-20 10:22:18 +01:00
Ui improvements
This commit is contained in:
parent
aab64c6f84
commit
daa41d222a
@ -382,7 +382,7 @@ public class TradeManager {
|
||||
}
|
||||
|
||||
public boolean isBuyer(Offer offer) {
|
||||
// If I am the offerer, the offer direction is taken, otherwise the mirrored direction
|
||||
// If I am the offerer, we use the offer direction, otherwise the mirrored direction
|
||||
if (isMyOffer(offer))
|
||||
return offer.getDirection() == Offer.Direction.BUY;
|
||||
else
|
||||
|
@ -25,7 +25,7 @@
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="-10.0"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" halignment="RIGHT" minWidth="160.0" maxWidth="160"/>
|
||||
<ColumnConstraints hgrow="SOMETIMES" halignment="RIGHT" minWidth="160.0"/>
|
||||
<ColumnConstraints hgrow="ALWAYS" minWidth="300.0"/>
|
||||
</columnConstraints>
|
||||
</GridPane>
|
||||
|
@ -156,7 +156,12 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||
@Override
|
||||
protected void activate() {
|
||||
currencyComboBox.setItems(model.getTradeCurrencies());
|
||||
currencyComboBox.getSelectionModel().select(model.getSelectedTradeCurrency());
|
||||
|
||||
if (model.showAllTradeCurrenciesProperty.get())
|
||||
currencyComboBox.getSelectionModel().select(0);
|
||||
else
|
||||
currencyComboBox.getSelectionModel().select(model.getSelectedTradeCurrency());
|
||||
|
||||
currencyComboBox.setVisibleRowCount(Math.min(currencyComboBox.getItems().size(), 25));
|
||||
paymentMethodComboBox.setItems(model.getPaymentMethods());
|
||||
paymentMethodComboBox.getSelectionModel().select(0);
|
||||
@ -168,12 +173,17 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||
priceColumn.textProperty().bind(createStringBinding(
|
||||
() -> !model.showAllTradeCurrenciesProperty.get() ?
|
||||
"Price in " + model.tradeCurrencyCode.get() + "/BTC" :
|
||||
"Price (mixed currencies)",
|
||||
"Price",
|
||||
model.tradeCurrencyCode,
|
||||
model.showAllTradeCurrenciesProperty));
|
||||
|
||||
volumeColumn.textProperty().bind(createStringBinding(
|
||||
() -> "Amount in " + model.tradeCurrencyCode.get() + " (Min.)", model.tradeCurrencyCode));
|
||||
() -> !model.showAllTradeCurrenciesProperty.get() ?
|
||||
"Amount in " + model.tradeCurrencyCode.get() + " (Min.)" :
|
||||
"Amount (Min.)",
|
||||
model.tradeCurrencyCode,
|
||||
model.showAllTradeCurrenciesProperty));
|
||||
|
||||
model.getOfferList().comparatorProperty().bind(tableView.comparatorProperty());
|
||||
|
||||
|
||||
@ -455,7 +465,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||
|
||||
if (newItem != null && !empty) {
|
||||
final Offer offer = newItem.getOffer();
|
||||
|
||||
boolean myOffer = model.isMyOffer(offer);
|
||||
TableRow tableRow = getTableRow();
|
||||
if (tableRow != null) {
|
||||
isPaymentAccountValidForOffer = model.isPaymentAccountValidForOffer(offer);
|
||||
@ -464,7 +474,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||
isTradable = isPaymentAccountValidForOffer && hasMatchingArbitrator &&
|
||||
hasSameProtocolVersion;
|
||||
|
||||
tableRow.setOpacity(isTradable ? 1 : 0.4);
|
||||
tableRow.setOpacity(isTradable || myOffer ? 1 : 0.4);
|
||||
|
||||
if (isTradable) {
|
||||
// set first row button as default
|
||||
@ -475,26 +485,27 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||
tableRow.setOnMouseClicked(e ->
|
||||
onShowInfo(isPaymentAccountValidForOffer, hasMatchingArbitrator,
|
||||
hasSameProtocolVersion));
|
||||
|
||||
//TODO
|
||||
//tableRow.setTooltip(new Tooltip(""));
|
||||
}
|
||||
}
|
||||
|
||||
String title;
|
||||
if (isTradable) {
|
||||
if (model.isMyOffer(offer)) {
|
||||
iconView.setId("image-remove");
|
||||
title = "Remove";
|
||||
button.setOnAction(e -> onRemoveOpenOffer(offer));
|
||||
} else {
|
||||
iconView.setId(offer.getDirection() == Offer.Direction.SELL ? "image-buy" : "image-sell");
|
||||
title = model.getDirectionLabel(offer);
|
||||
button.setOnAction(e -> onTakeOffer(offer));
|
||||
}
|
||||
if (myOffer) {
|
||||
iconView.setId("image-remove");
|
||||
title = "Remove";
|
||||
button.setOnAction(e -> onRemoveOpenOffer(offer));
|
||||
} else {
|
||||
title = "Not matching";
|
||||
iconView.setId(null);
|
||||
button.setOnAction(e -> onShowInfo(isPaymentAccountValidForOffer, hasMatchingArbitrator, hasSameProtocolVersion));
|
||||
iconView.setId(offer.getDirection() == Offer.Direction.SELL ? "image-buy" : "image-sell");
|
||||
title = model.getDirectionLabel(offer);
|
||||
button.setOnAction(e -> onTakeOffer(offer));
|
||||
}
|
||||
|
||||
if (!isTradable)
|
||||
button.setOnAction(e -> onShowInfo(isPaymentAccountValidForOffer, hasMatchingArbitrator, hasSameProtocolVersion));
|
||||
|
||||
|
||||
button.setText(title);
|
||||
setGraphic(button);
|
||||
} else {
|
||||
|
@ -42,6 +42,7 @@ import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.transformation.FilteredList;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@ -121,10 +122,10 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||
offerBookListItems.addListener(listChangeListener);
|
||||
offerBook.fillOfferBookListItems();
|
||||
filterList();
|
||||
if (isTabSelected)
|
||||
marketPriceFeed.setCurrencyCode(tradeCurrencyCode.get());
|
||||
setMarketPriceFeedCurrency();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
btcCode.unbind();
|
||||
@ -139,6 +140,15 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||
allTradeCurrencies.addAll(preferences.getTradeCurrenciesAsObservable());
|
||||
}
|
||||
|
||||
private void setMarketPriceFeedCurrency() {
|
||||
if (isTabSelected) {
|
||||
if (showAllTradeCurrenciesProperty.get())
|
||||
marketPriceFeed.setCurrencyCode(CurrencyUtil.getDefaultTradeCurrency().getCode());
|
||||
else
|
||||
marketPriceFeed.setCurrencyCode(tradeCurrencyCode.get());
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -149,8 +159,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||
|
||||
void onTabSelected(boolean isSelected) {
|
||||
this.isTabSelected = isSelected;
|
||||
if (isTabSelected)
|
||||
marketPriceFeed.setCurrencyCode(tradeCurrencyCode.get());
|
||||
setMarketPriceFeedCurrency();
|
||||
}
|
||||
|
||||
|
||||
@ -164,9 +173,10 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||
if (!showAllTradeCurrenciesProperty.get()) {
|
||||
this.selectedTradeCurrency = tradeCurrency;
|
||||
tradeCurrencyCode.set(code);
|
||||
marketPriceFeed.setCurrencyCode(code);
|
||||
}
|
||||
|
||||
setMarketPriceFeedCurrency();
|
||||
|
||||
filterList();
|
||||
}
|
||||
|
||||
@ -231,8 +241,14 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||
}
|
||||
|
||||
String getVolume(OfferBookListItem item) {
|
||||
return (item != null) ? formatter.formatFiat(item.getOffer().getOfferVolume()) +
|
||||
" (" + formatter.formatFiat(item.getOffer().getMinOfferVolume()) + ")" : "";
|
||||
Fiat offerVolume = item.getOffer().getOfferVolume();
|
||||
Fiat minOfferVolume = item.getOffer().getMinOfferVolume();
|
||||
if (showAllTradeCurrenciesProperty.get())
|
||||
return (item != null) ? formatter.formatFiatWithCode(offerVolume) +
|
||||
" (" + formatter.formatFiatWithCode(minOfferVolume) + ")" : "";
|
||||
else
|
||||
return (item != null) ? formatter.formatFiat(offerVolume) +
|
||||
" (" + formatter.formatFiat(minOfferVolume) + ")" : "";
|
||||
}
|
||||
|
||||
String getPaymentMethod(OfferBookListItem item) {
|
||||
|
@ -100,7 +100,7 @@ public class OfferDetailsPopup extends Popup {
|
||||
this.dontShowAgainId = dontShowAgainId;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public OfferDetailsPopup onPlaceOffer(Consumer<Offer> placeOfferHandler) {
|
||||
this.placeOfferHandlerOptional = Optional.of(placeOfferHandler);
|
||||
return this;
|
||||
@ -116,6 +116,7 @@ public class OfferDetailsPopup extends Popup {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Protected
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -137,15 +138,23 @@ public class OfferDetailsPopup extends Popup {
|
||||
rows++;
|
||||
|
||||
addTitledGroupBg(gridPane, ++rowIndex, rows, "Offer");
|
||||
addLabelTextField(gridPane, rowIndex, "Offer type:", formatter.getOfferDirection(offer.getDirection()), Layout.FIRST_ROW_DISTANCE);
|
||||
addLabelTextField(gridPane, ++rowIndex, "Currency:", offer.getCurrencyCode());
|
||||
addLabelTextField(gridPane, ++rowIndex, "Price:", formatter.formatFiat(offer.getPrice()) + " " + offer.getCurrencyCode() + "/" + "BTC");
|
||||
|
||||
if (takeOfferHandlerOptional.isPresent())
|
||||
addLabelTextField(gridPane, rowIndex, "Offer type:", formatter.getDirectionForTaker(offer.getDirection()), Layout.FIRST_ROW_DISTANCE);
|
||||
else
|
||||
addLabelTextField(gridPane, rowIndex, "Offer type:", formatter.getOfferDirection(offer.getDirection()), Layout.FIRST_ROW_DISTANCE);
|
||||
|
||||
if (takeOfferHandlerOptional.isPresent()) {
|
||||
addLabelTextField(gridPane, ++rowIndex, "Trade amount:", formatter.formatCoinWithCode(tradeAmount));
|
||||
} else {
|
||||
addLabelTextField(gridPane, ++rowIndex, "Amount:", formatter.formatCoinWithCode(offer.getAmount()));
|
||||
addLabelTextField(gridPane, ++rowIndex, "Min. amount:", formatter.formatCoinWithCode(offer.getMinAmount()));
|
||||
}
|
||||
|
||||
addLabelTextField(gridPane, ++rowIndex, "Price:", formatter.formatFiat(offer.getPrice()) + " " + offer.getCurrencyCode() + "/" + "BTC");
|
||||
|
||||
addLabelTextField(gridPane, ++rowIndex, "Currency:", offer.getCurrencyCode());
|
||||
|
||||
if (offer.isMyOffer(keyRing) && user.getPaymentAccount(offer.getOffererPaymentAccountId()) != null)
|
||||
addLabelTextField(gridPane, ++rowIndex, "Payment account:", user.getPaymentAccount(offer.getOffererPaymentAccountId()).getAccountName());
|
||||
else
|
||||
|
@ -49,7 +49,7 @@ import static io.bitsquare.gui.util.FormBuilder.addCheckBox;
|
||||
public class Popup {
|
||||
protected final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
protected final static double DEFAULT_WIDTH = 500;
|
||||
protected final static double DEFAULT_WIDTH = 600;
|
||||
protected int rowIndex = -1;
|
||||
protected String headLine;
|
||||
protected String message;
|
||||
|
@ -24,6 +24,7 @@ import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.payment.PaymentAccountContractData;
|
||||
import io.bitsquare.trade.Contract;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
import io.bitsquare.trade.offer.Offer;
|
||||
import javafx.beans.property.IntegerProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
@ -46,6 +47,7 @@ public class TradeDetailsPopup extends Popup {
|
||||
|
||||
private final BSFormatter formatter;
|
||||
private final DisputeManager disputeManager;
|
||||
private TradeManager tradeManager;
|
||||
private Trade trade;
|
||||
private ChangeListener<Number> changeListener;
|
||||
private TextArea textArea;
|
||||
@ -56,9 +58,10 @@ public class TradeDetailsPopup extends Popup {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public TradeDetailsPopup(BSFormatter formatter, DisputeManager disputeManager) {
|
||||
public TradeDetailsPopup(BSFormatter formatter, DisputeManager disputeManager, TradeManager tradeManager) {
|
||||
this.formatter = formatter;
|
||||
this.disputeManager = disputeManager;
|
||||
this.tradeManager = tradeManager;
|
||||
}
|
||||
|
||||
public TradeDetailsPopup show(Trade trade) {
|
||||
@ -104,10 +107,16 @@ public class TradeDetailsPopup extends Popup {
|
||||
|
||||
int rows = 5;
|
||||
addTitledGroupBg(gridPane, ++rowIndex, rows, "Trade");
|
||||
addLabelTextField(gridPane, rowIndex, "Trade type:", formatter.getDirectionBothSides(offer.getDirection()), Layout.FIRST_ROW_DISTANCE);
|
||||
addLabelTextField(gridPane, ++rowIndex, "Currency:", offer.getCurrencyCode());
|
||||
addLabelTextField(gridPane, ++rowIndex, "Price:", formatter.formatFiat(offer.getPrice()) + " " + offer.getCurrencyCode());
|
||||
|
||||
boolean myOffer = tradeManager.isMyOffer(offer);
|
||||
if (tradeManager.isBuyer(offer))
|
||||
addLabelTextField(gridPane, rowIndex, "Trade type:", formatter.getDirectionForBuyer(myOffer), Layout.FIRST_ROW_DISTANCE);
|
||||
else
|
||||
addLabelTextField(gridPane, rowIndex, "Trade type:", formatter.getDirectionForSeller(myOffer), Layout.FIRST_ROW_DISTANCE);
|
||||
|
||||
addLabelTextField(gridPane, ++rowIndex, "Trade amount:", formatter.formatCoinWithCode(trade.getTradeAmount()));
|
||||
addLabelTextField(gridPane, ++rowIndex, "Price:", formatter.formatPriceWithCode(offer.getPrice()));
|
||||
addLabelTextField(gridPane, ++rowIndex, "Currency:", offer.getCurrencyCode());
|
||||
addLabelTextField(gridPane, ++rowIndex, "Payment method:", BSResources.get(offer.getPaymentMethod().getId()));
|
||||
|
||||
rows = 4;
|
||||
|
@ -205,6 +205,7 @@ public class BuyerStep2View extends TradeStepView {
|
||||
if (preferences.showAgain(key) && !BitsquareApp.DEV_MODE) {
|
||||
new Popup().headLine("Confirmation")
|
||||
.message("Did you transfer the payment to your trading partner?")
|
||||
.width(700)
|
||||
.dontShowAgainId(key, preferences)
|
||||
.actionButtonText("Yes I have started the payment")
|
||||
.closeButtonText("No")
|
||||
|
@ -226,6 +226,7 @@ public class SellerStep3View extends TradeStepView {
|
||||
.message("Did you receive the payment from your trading partner?\n\n" +
|
||||
"Please note that as soon you have confirmed the locked bitcoin will be released.\n" +
|
||||
"There is no way to reverse a bitcoin payment.")
|
||||
.width(700)
|
||||
.dontShowAgainId(key, preferences)
|
||||
.actionButtonText("Yes I have received the payment")
|
||||
.closeButtonText("No")
|
||||
|
@ -400,6 +400,18 @@ public class BSFormatter {
|
||||
return direction == Offer.Direction.BUY ? "Offerer as bitcoin buyer / Taker as bitcoin seller" : "Offerer as bitcoin seller / Taker as bitcoin buyer";
|
||||
}
|
||||
|
||||
public String getDirectionForBuyer(boolean isMyOffer) {
|
||||
return isMyOffer ? "You are buying bitcoin as offerer / Taker is selling bitcoin" : "You are buying bitcoin as taker / Offerer is selling bitcoin";
|
||||
}
|
||||
|
||||
public String getDirectionForSeller(boolean isMyOffer) {
|
||||
return isMyOffer ? "You are selling bitcoin as offerer / Taker is buying bitcoin" : "You are selling bitcoin as taker / Offerer is buying bitcoin";
|
||||
}
|
||||
|
||||
public String getDirectionForTaker(Offer.Direction direction) {
|
||||
return direction == Offer.Direction.BUY ? "You are selling bitcoin (take an offer for buying bitcoin)" : "You are buying bitcoin (take an offer for selling bitcoin)";
|
||||
}
|
||||
|
||||
public String getOfferDirection(Offer.Direction direction) {
|
||||
return direction == Offer.Direction.BUY ? "Offer for buying bitcoin" : "Offer for selling bitcoin";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user