Skip to content

Commit

Permalink
Merge pull request #3063 from axpoems/imp-amount-selection
Browse files Browse the repository at this point in the history
Improvements in amount selection
  • Loading branch information
HenrikJannsen authored Dec 25, 2024
2 parents e49176b + 905729a commit 2397880
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ public class AmountSelectionController implements Controller {
private Subscription maxOrFixedBaseAmountFromModelPin, maxOrFixedBaseAmountFromCompPin, maxOrFixedQuoteAmountFromCompPin,
maxOrFixedBaseSideAmountValidPin, maxOrFixedQuoteSideAmountValidPin, minBaseAmountFromModelPin,
minBaseAmountFromCompPin, minQuoteAmountFromCompPin, minBaseSideAmountValidPin,
minQuoteSideAmountValidPin,

priceFromCompPin, minRangeCustomValuePin, maxRangeCustomValuePin;
minQuoteSideAmountValidPin, priceFromCompPin, minRangeCustomValuePin, maxRangeCustomValuePin, isRangeAmountEnabledPin;

public AmountSelectionController(ServiceProvider serviceProvider,
boolean useQuoteCurrencyForMinMaxRange) {
Expand Down Expand Up @@ -231,7 +229,6 @@ public void onActivate() {
model.getMaxRangeBaseSideValue().set(null);
model.getMinRangeQuoteSideValue().set(null);
model.getMaxRangeQuoteSideValue().set(null);
model.getDescription().set(Res.get("bisqEasy.tradeWizard.amount.description", model.getMarket().getQuoteCurrencyCode()));
applyInitialRangeValues();

model.getMaxOrFixedBaseSideAmount().addListener(maxOrFixedBaseSideAmountFromModelListener);
Expand Down Expand Up @@ -360,6 +357,14 @@ public void onActivate() {
minBaseSideAmountValidPin = subscribeToAmountValidity(minBaseSideAmountInput, this::setMinBaseFromQuote);
maxOrFixedQuoteSideAmountValidPin = subscribeToAmountValidity(maxOrFixedQuoteSideAmountInput, this::setMaxOrFixedQuoteFromBase);
minQuoteSideAmountValidPin = subscribeToAmountValidity(minQuoteSideAmountInput, this::setMinQuoteFromBase);

isRangeAmountEnabledPin = EasyBind.subscribe(model.getIsRangeAmountEnabled(), isRangeAmountEnabled ->
model.getDescription().set(
Res.get(isRangeAmountEnabled
? "bisqEasy.tradeWizard.amount.description.range"
: "bisqEasy.tradeWizard.amount.description.fixed"
, model.getMarket().getQuoteCurrencyCode())));

model.getMaxOrFixedAmountSliderValue().addListener(maxOrFixedSliderListener);
model.getMinAmountSliderValue().addListener(minSliderListener);
}
Expand All @@ -386,6 +391,7 @@ public void onDeactivate() {
minBaseSideAmountValidPin.unsubscribe();
maxOrFixedQuoteSideAmountValidPin.unsubscribe();
minQuoteSideAmountValidPin.unsubscribe();
isRangeAmountEnabledPin.unsubscribe();
model.setLeftMarkerQuoteSideValue(null);
model.setRightMarkerQuoteSideValue(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ public class AmountSelectionView extends View<VBox, AmountSelectionModel, Amount

// rest of the component
description = new Label();
description.getStyleClass().add("description");
description.setMouseTransparent(true);

Pane amountInputVBox = new Pane(quoteAmountSelectionHBox, baseAmountSelectionHBox);
Expand Down Expand Up @@ -312,14 +311,19 @@ protected void onViewDetached() {
}

private void onInputTextFieldFocus(boolean isOtherFocused, boolean focus) {
description.getStyleClass().clear();
if (focus) {
selectionLine.setPrefWidth(0);
selectionLine.setOpacity(1);
Transitions.animateWidth(selectionLine, AMOUNT_BOX_WIDTH + 40);
description.getStyleClass().add("description-focused");
} else if (!isOtherFocused) {
// If switching between the 2 fields we want to avoid to get the fadeout called that's why
// we do the check with !other.get()
Transitions.fadeOut(selectionLine, 200);
description.getStyleClass().add("description");
} else {
description.getStyleClass().add("description-focused");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,14 @@ public void onActivate() {
applyAmountSpec();

if (model.isCreateOfferMode()) {
Optional<PriceQuote> marketPriceQuote = getMarketPriceQuote();
if (model.getPriceQuote().get() != null && marketPriceQuote.isPresent()
&& !model.getPriceQuote().get().equals(marketPriceQuote.get())) {
model.getPriceTooltip().set(Res.get("bisqEasy.component.amount.baseSide.tooltip.btcAmount.selectedPrice"));
} else {
model.getPriceTooltip().set(Res.get("bisqEasy.component.amount.baseSide.tooltip.btcAmount.marketPrice"));
}
model.getPriceTooltip().set(Res.get("bisqEasy.component.amount.baseSide.tooltip.btcAmount.marketPrice"));
// Optional<PriceQuote> marketPriceQuote = getMarketPriceQuote();
// if (model.getPriceQuote().get() != null && marketPriceQuote.isPresent()
// && !model.getPriceQuote().get().equals(marketPriceQuote.get())) {
// model.getPriceTooltip().set(Res.get("bisqEasy.component.amount.baseSide.tooltip.btcAmount.selectedPrice"));
// } else {
// model.getPriceTooltip().set(Res.get("bisqEasy.component.amount.baseSide.tooltip.btcAmount.marketPrice"));
// }
} else {
// Use best price of matching offer if any match found, otherwise market price.
Optional<String> bestOffersPriceTooltip = findBestOfferQuote()
Expand Down
15 changes: 12 additions & 3 deletions apps/desktop/desktop/src/main/resources/css/bisq_easy.css
Original file line number Diff line number Diff line change
Expand Up @@ -745,14 +745,23 @@
-fx-alignment: center;
}

.amount-selection .description {
-fx-fill: -fx-mid-text-color;
-fx-text-fill: -fx-mid-text-color;
.amount-selection .description,
.amount-selection .description-focused {
-fx-font-size: 1em;
-fx-font-family: "IBM Plex Sans Light";
-fx-wrap-text: true;
}

.amount-selection .description {
-fx-fill: -fx-mid-text-color;
-fx-text-fill: -fx-mid-text-color;
}

.amount-selection .description-focused {
-fx-fill: -bisq2-green;
-fx-text-fill: -bisq2-green;
}

.description-and-amount-box {
-fx-padding: 8 20 8 20;
}
Expand Down
5 changes: 2 additions & 3 deletions i18n/src/main/resources/bisq_easy.properties
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,8 @@ bisqEasy.tradeWizard.amount.headline.buyer=How much do you want to spend?
bisqEasy.tradeWizard.amount.headline.seller=How much do you want to receive?
bisqEasy.tradeWizard.amount.amountModel.fixedAmount=Fixed amount
bisqEasy.tradeWizard.amount.amountModel.rangeAmount=Range amount
bisqEasy.tradeWizard.amount.description={0} amount to trade
bisqEasy.component.amount.minRangeValue=Min
bisqEasy.component.amount.maxRangeValue=Max
bisqEasy.tradeWizard.amount.description.fixed={0} amount to trade
bisqEasy.tradeWizard.amount.description.range=Range of {0} amount to trade. MIN-MAX
bisqEasy.component.amount.baseSide.tooltip.btcAmount.marketPrice=This is the Bitcoin amount with current market price.
bisqEasy.component.amount.baseSide.tooltip.btcAmount.selectedPrice=This is the Bitcoin amount with your selected price.
bisqEasy.component.amount.baseSide.tooltip.buyerInfo=Sellers may ask for a higher price as they have costs for acquiring reputation.\n\
Expand Down

0 comments on commit 2397880

Please sign in to comment.