Skip to content

Commit

Permalink
Add warning icon when no sellers available
Browse files Browse the repository at this point in the history
  • Loading branch information
axpoems committed Jan 19, 2025
1 parent 03b0774 commit a3f8718
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ private void quoteSideAmountsChanged(boolean maxAmountChanged) {
.filter(e -> e.getValue() >= requiredReputationScoreForMinAmount || requiredReputationScoreForMinAmount <= MIN_REPUTATION_SCORE)
.count();
String formattedMaxOrFixedAmount = formatAmountWithCode(maxOrFixedQuoteSideAmount);
model.getShouldShowWarningIcon().set(false);
if (model.isCreateOfferMode()) {
// Create offer
if (model.getIsRangeAmountEnabled().get() && !maxAmountChanged) {
Expand All @@ -527,6 +528,7 @@ private void quoteSideAmountsChanged(boolean maxAmountChanged) {

String formattedMinAmount = formatAmountWithCode(minQuoteSideAmount);
if (numPotentialTakersForMinAmount == 0) {
model.getShouldShowWarningIcon().set(true);
model.getAmountLimitInfoOverlayInfo().set(Res.get("bisqEasy.tradeWizard.amount.buyer.limitInfo.overlay.info.noSellers",
formattedMinAmount, requiredReputationScoreForMinAmount) + "\n\n");
} else {
Expand All @@ -539,6 +541,7 @@ private void quoteSideAmountsChanged(boolean maxAmountChanged) {
model.getAmountLimitInfo().set(Res.get("bisqEasy.tradeWizard.amount.buyer.limitInfo", numSellers));

if (numPotentialTakersForMaxOrFixedAmount == 0) {
model.getShouldShowWarningIcon().set(true);
model.getAmountLimitInfoOverlayInfo().set(Res.get("bisqEasy.tradeWizard.amount.buyer.limitInfo.overlay.info.noSellers",
formattedMaxOrFixedAmount, requiredReputationScoreForMaxOrFixedAmount) + "\n\n");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class TradeWizardAmountModel implements Model {
private final StringProperty amountLimitInfoOverlayInfo = new SimpleStringProperty();
private final BooleanProperty shouldShowAmountLimitInfo = new SimpleBooleanProperty();
private final BooleanProperty shouldShowHowToBuildReputationButton = new SimpleBooleanProperty();
private final BooleanProperty shouldShowWarningIcon = new SimpleBooleanProperty();
@Setter
private String amountLimitInfoLink;
@Setter
Expand Down Expand Up @@ -82,6 +83,7 @@ public void reset() {
amountLimitInfoOverlayInfo.set(null);
shouldShowAmountLimitInfo.set(false);
shouldShowHowToBuildReputationButton.set(false);
shouldShowWarningIcon.set(false);
amountLimitInfoLink = null;
linkToWikiText = null;
isCreateOfferMode = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
package bisq.desktop.main.content.bisq_easy.trade_wizard.amount;

import bisq.desktop.common.Browser;
import bisq.desktop.common.Icons;
import bisq.desktop.common.view.View;
import bisq.desktop.components.containers.Spacer;
import bisq.desktop.components.controls.BisqTooltip;
import bisq.desktop.main.content.bisq_easy.components.amount_selection.AmountSelectionController;
import bisq.i18n.Res;
import de.jensd.fx.fontawesome.AwesomeIcon;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
Expand All @@ -40,7 +42,7 @@ public class TradeWizardAmountView extends View<VBox, TradeWizardAmountModel, Tr
private static final String SELECTED_PRICE_MODEL_STYLE_CLASS = "selected-model";

private final AmountSelectionController amountSelectionController;
private final Label amountLimitInfo, amountLimitInfoOverlayInfo, linkToWikiText;
private final Label amountLimitInfo, amountLimitInfoOverlayInfo, linkToWikiText, warningIcon;
private final Hyperlink learnMoreHyperLink, linkToWiki;
@Getter
private final VBox amountLimitInfoOverlay;
Expand All @@ -62,14 +64,19 @@ public TradeWizardAmountView(TradeWizardAmountModel model,
amountBox.setAlignment(Pos.BASELINE_LEFT);
amountBox.getStyleClass().add("amount-box");

warningIcon = new Label();
warningIcon.getStyleClass().add("text-fill-grey-dimmed");
warningIcon.setPadding(new Insets(0, 2.5, 0, 0));
Icons.getIconForLabel(AwesomeIcon.WARNING_SIGN, warningIcon, "1em");

amountLimitInfo = new Label();
amountLimitInfo.getStyleClass().add("trade-wizard-amount-limit-info");

learnMoreHyperLink = new Hyperlink();
learnMoreHyperLink.getStyleClass().add("trade-wizard-amount-limit-info-overlay-link");
learnMoreHyperLink.setMinWidth(Hyperlink.USE_PREF_SIZE);

amountLimitInfoHBox = new HBox(2.5, amountLimitInfo, learnMoreHyperLink);
amountLimitInfoHBox = new HBox(2.5, warningIcon, amountLimitInfo, learnMoreHyperLink);
amountLimitInfoHBox.setAlignment(Pos.CENTER);

// Amount model selection
Expand Down Expand Up @@ -117,6 +124,8 @@ protected void onViewAttached() {
amountModelsBox.managedProperty().bind(model.getShowRangeAmounts());
learnHowToBuildReputation.visibleProperty().bind(model.getShouldShowHowToBuildReputationButton());
learnHowToBuildReputation.managedProperty().bind(model.getShouldShowHowToBuildReputationButton());
warningIcon.visibleProperty().bind(model.getShouldShowWarningIcon());
warningIcon.managedProperty().bind(model.getShouldShowWarningIcon());

isRangeAmountEnabledPin = EasyBind.subscribe(model.getIsRangeAmountEnabled(), isRangeAmountEnabled -> {
fixedAmount.getStyleClass().remove(SELECTED_PRICE_MODEL_STYLE_CLASS);
Expand Down Expand Up @@ -147,6 +156,8 @@ protected void onViewDetached() {
amountModelsBox.managedProperty().unbind();
learnHowToBuildReputation.visibleProperty().unbind();
learnHowToBuildReputation.managedProperty().unbind();
warningIcon.visibleProperty().unbind();
warningIcon.managedProperty().unbind();

isRangeAmountEnabledPin.unsubscribe();

Expand Down

0 comments on commit a3f8718

Please sign in to comment.