Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OfferBook: Show min-max range for amount and volume #4225

Merged
merged 1 commit into from
May 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import bisq.desktop.main.offer.SellOfferView;
import bisq.desktop.main.offer.offerbook.OfferBookListItem;
import bisq.desktop.util.CurrencyListItem;
import bisq.desktop.util.DisplayUtils;
import bisq.desktop.util.GUIUtil;

import bisq.core.locale.CurrencyUtil;
Expand Down Expand Up @@ -216,7 +217,7 @@ protected void activate() {
tradeCurrencySubscriber = EasyBind.subscribe(model.selectedTradeCurrencyProperty,
tradeCurrency -> {
String code = tradeCurrency.getCode();
volumeColumnLabel.set(Res.get("shared.amountWithCur", code));
volumeColumnLabel.set(Res.get("offerbook.volume", code));
xAxis.setTickLabelFormatter(new StringConverter<>() {
int cryptoPrecision = 3;

Expand Down Expand Up @@ -499,9 +500,7 @@ public TableCell<OfferListItem, OfferListItem> call(TableColumn<OfferListItem, O
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if (offer != null && offer.getPrice() != null) {
setText("");
setGraphic(new ColoredDecimalPlacesWithZerosText(model.getVolume(offer),
model.getMaxNumberOfPriceZeroDecimalsToColorize(offer)));
renderCellContentRange();
model.priceFeedService.updateCounterProperty().removeListener(listener);
}
}
Expand All @@ -517,9 +516,7 @@ public void updateItem(final OfferListItem offerListItem, boolean empty) {
model.priceFeedService.updateCounterProperty().addListener(listener);
setText(Res.get("shared.na"));
} else {
setText("");
setGraphic(new ColoredDecimalPlacesWithZerosText(model.getVolume(offer),
model.getMaxNumberOfPriceZeroDecimalsToColorize(offer)));
renderCellContentRange();
}
} else {
model.priceFeedService.updateCounterProperty().removeListener(listener);
Expand All @@ -528,12 +525,25 @@ public void updateItem(final OfferListItem offerListItem, boolean empty) {
setGraphic(null);
}
}

/**
* Renders cell content, if it has a single value or a range.
* Should not be called for empty cells
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment really needed? Maybe naming renderCellContent() is enough as it is private method in very specific context.

*/
private void renderCellContentRange() {
String volumeRange = DisplayUtils.formatVolume(offer, true, 2);

setText("");
setGraphic(new ColoredDecimalPlacesWithZerosText(volumeRange,
model.getMaxNumberOfPriceZeroDecimalsToColorize(offer)));
}

};
}
});

// amount
TableColumn<OfferListItem, OfferListItem> amountColumn = new AutoTooltipTableColumn<>(Res.get("shared.amountWithCur", Res.getBaseCurrencyCode()));
TableColumn<OfferListItem, OfferListItem> amountColumn = new AutoTooltipTableColumn<>(Res.get("shared.BTCMinMax"));
amountColumn.setMinWidth(115);
amountColumn.setSortable(false);
amountColumn.getStyleClass().add("number-column");
Expand All @@ -547,8 +557,8 @@ public TableCell<OfferListItem, OfferListItem> call(TableColumn<OfferListItem, O
public void updateItem(final OfferListItem offerListItem, boolean empty) {
super.updateItem(offerListItem, empty);
if (offerListItem != null && !empty) {
setGraphic(new ColoredDecimalPlacesWithZerosText(formatter.formatCoin(offerListItem.offer.getAmount(),
4), GUIUtil.AMOUNT_DECIMALS_WITH_ZEROS));
String amountRange = DisplayUtils.formatAmount(offerListItem.offer, formatter);
setGraphic(new ColoredDecimalPlacesWithZerosText(amountRange, GUIUtil.AMOUNT_DECIMALS_WITH_ZEROS));
} else {
setGraphic(null);
}
Expand Down