diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/components/controls/BisqMenuItem.java b/apps/desktop/desktop/src/main/java/bisq/desktop/components/controls/BisqMenuItem.java index c7b281cd72..fb26c938d3 100644 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/components/controls/BisqMenuItem.java +++ b/apps/desktop/desktop/src/main/java/bisq/desktop/components/controls/BisqMenuItem.java @@ -21,6 +21,7 @@ import javafx.geometry.Pos; import javafx.scene.control.Button; import javafx.scene.control.Tooltip; +import javafx.scene.effect.ColorAdjust; import javafx.scene.image.ImageView; public class BisqMenuItem extends Button { @@ -74,6 +75,12 @@ public void setTooltip(String tooltip) { } } + public void applyIconColorAdjustment(ColorAdjust colorAdjust) { + if (colorAdjust != null) { + buttonIcon.setEffect(colorAdjust); + } + } + private void attachListeners() { setOnMouseEntered(e -> updateIcon(activeIcon)); setOnMouseExited(e -> updateIcon(defaultIcon)); diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/TradeWizardController.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/TradeWizardController.java index 1ea43493a4..7c66d022d6 100644 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/TradeWizardController.java +++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/TradeWizardController.java @@ -27,9 +27,8 @@ import bisq.desktop.common.view.Navigation; import bisq.desktop.common.view.NavigationController; import bisq.desktop.main.content.bisq_easy.trade_wizard.amount.TradeWizardAmountController; -import bisq.desktop.main.content.bisq_easy.trade_wizard.btc_payment_method.TradeWizardBitcoinPaymentMethodController; import bisq.desktop.main.content.bisq_easy.trade_wizard.direction.TradeWizardDirectionController; -import bisq.desktop.main.content.bisq_easy.trade_wizard.fiat_payment_method.TradeWizardFiatPaymentMethodController; +import bisq.desktop.main.content.bisq_easy.trade_wizard.payment_methods.TradeWizardPaymentMethodsController; import bisq.desktop.main.content.bisq_easy.trade_wizard.market.TradeWizardMarketController; import bisq.desktop.main.content.bisq_easy.trade_wizard.price.TradeWizardPriceController; import bisq.desktop.main.content.bisq_easy.trade_wizard.review.TradeWizardReviewController; @@ -73,8 +72,7 @@ public InitData(boolean isCreateOfferMode) { private final TradeWizardMarketController tradeWizardMarketController; private final TradeWizardPriceController tradeWizardPriceController; private final TradeWizardAmountController tradeWizardAmountController; - private final TradeWizardBitcoinPaymentMethodController tradeWizardBitcoinPaymentMethodController; - private final TradeWizardFiatPaymentMethodController tradeWizardFiatPaymentMethodController; + private final TradeWizardPaymentMethodsController tradeWizardPaymentMethodsController; private final TradeWizardSelectOfferController tradeWizardSelectOfferController; private final TradeWizardReviewController tradeWizardReviewController; private final EventHandler onKeyPressedHandler = this::onKeyPressed; @@ -99,8 +97,7 @@ public TradeWizardController(ServiceProvider serviceProvider) { tradeWizardMarketController = new TradeWizardMarketController(serviceProvider, this::onNext); tradeWizardPriceController = new TradeWizardPriceController(serviceProvider, view.getRoot()); tradeWizardAmountController = new TradeWizardAmountController(serviceProvider, view.getRoot()); - tradeWizardBitcoinPaymentMethodController = new TradeWizardBitcoinPaymentMethodController(serviceProvider, view.getRoot(), this::onNext); - tradeWizardFiatPaymentMethodController = new TradeWizardFiatPaymentMethodController(serviceProvider, view.getRoot(), this::onNext); + tradeWizardPaymentMethodsController = new TradeWizardPaymentMethodsController(serviceProvider, view.getRoot(), this::onNext); tradeWizardSelectOfferController = new TradeWizardSelectOfferController(serviceProvider, this::onBack, this::onNext, @@ -139,8 +136,7 @@ public void onActivate() { NavigationTarget.TRADE_WIZARD_DIRECTION, NavigationTarget.TRADE_WIZARD_MARKET, NavigationTarget.TRADE_WIZARD_AMOUNT, - NavigationTarget.TRADE_WIZARD_BITCOIN_PAYMENT_METHOD, - NavigationTarget.TRADE_WIZARD_FIAT_PAYMENT_METHOD, + NavigationTarget.TRADE_WIZARD_PAYMENT_METHODS, NavigationTarget.TRADE_WIZARD_TAKE_OFFER_OFFER, NavigationTarget.TRADE_WIZARD_REVIEW_OFFER )); @@ -155,13 +151,12 @@ public void onActivate() { tradeWizardMarketController.setDirection(direction); tradeWizardSelectOfferController.setDirection(direction); tradeWizardAmountController.setDirection(direction); - tradeWizardBitcoinPaymentMethodController.setDirection(direction); - tradeWizardFiatPaymentMethodController.setDirection(direction); + tradeWizardPaymentMethodsController.setDirection(direction); tradeWizardPriceController.setDirection(direction); }); marketPin = EasyBind.subscribe(tradeWizardMarketController.getMarket(), market -> { tradeWizardSelectOfferController.setMarket(market); - tradeWizardFiatPaymentMethodController.setMarket(market); + tradeWizardPaymentMethodsController.setMarket(market); tradeWizardPriceController.setMarket(market); tradeWizardAmountController.setMarket(market); updateNextButtonDisabledState(); @@ -184,8 +179,9 @@ public void onActivate() { isBackButtonHighlighted -> model.getIsBackButtonHighlighted().set(isBackButtonHighlighted)); handleFiatPaymentMethodsUpdate(); - tradeWizardBitcoinPaymentMethodController.getBitcoinPaymentMethods().addListener(bitcoinPaymentMethodsListener); - tradeWizardFiatPaymentMethodController.getFiatPaymentMethods().addListener(fiatPaymentMethodsListener); + tradeWizardPaymentMethodsController.getFiatPaymentMethods().addListener(fiatPaymentMethodsListener); + handleBitcoinPaymentMethodsUpdate(); + tradeWizardPaymentMethodsController.getBitcoinPaymentMethods().addListener(bitcoinPaymentMethodsListener); } @Override @@ -199,8 +195,8 @@ public void onDeactivate() { priceSpecPin.unsubscribe(); selectedBisqEasyOfferPin.unsubscribe(); isBackButtonHighlightedPin.unsubscribe(); - tradeWizardBitcoinPaymentMethodController.getBitcoinPaymentMethods().removeListener(bitcoinPaymentMethodsListener); - tradeWizardFiatPaymentMethodController.getFiatPaymentMethods().removeListener(fiatPaymentMethodsListener); + tradeWizardPaymentMethodsController.getFiatPaymentMethods().removeListener(fiatPaymentMethodsListener); + tradeWizardPaymentMethodsController.getBitcoinPaymentMethods().removeListener(bitcoinPaymentMethodsListener); } @Override @@ -210,8 +206,8 @@ protected void onStartProcessNavigationTarget(NavigationTarget navigationTarget, tradeWizardReviewController.setDataForCreateOffer( tradeWizardDirectionController.getDirection().get(), tradeWizardMarketController.getMarket().get(), - tradeWizardBitcoinPaymentMethodController.getBitcoinPaymentMethods(), - tradeWizardFiatPaymentMethodController.getFiatPaymentMethods(), + tradeWizardPaymentMethodsController.getBitcoinPaymentMethods(), + tradeWizardPaymentMethodsController.getFiatPaymentMethods(), tradeWizardAmountController.getQuoteSideAmountSpec().get(), tradeWizardPriceController.getPriceSpec().get() ); @@ -219,8 +215,8 @@ protected void onStartProcessNavigationTarget(NavigationTarget navigationTarget, } else { tradeWizardReviewController.setDataForTakeOffer(tradeWizardSelectOfferController.getSelectedBisqEasyOffer().get(), tradeWizardAmountController.getQuoteSideAmountSpec().get(), - tradeWizardBitcoinPaymentMethodController.getBitcoinPaymentMethods(), - tradeWizardFiatPaymentMethodController.getFiatPaymentMethods() + tradeWizardPaymentMethodsController.getBitcoinPaymentMethods(), + tradeWizardPaymentMethodsController.getFiatPaymentMethods() ); model.getNextButtonText().set(Res.get("bisqEasy.tradeWizard.review.nextButton.takeOffer")); updateNextButtonDisabledState(); @@ -252,11 +248,8 @@ protected Optional createController(NavigationTarget navig case TRADE_WIZARD_PRICE: { return Optional.of(tradeWizardPriceController); } - case TRADE_WIZARD_BITCOIN_PAYMENT_METHOD: { - return Optional.of(tradeWizardBitcoinPaymentMethodController); - } - case TRADE_WIZARD_FIAT_PAYMENT_METHOD: { - return Optional.of(tradeWizardFiatPaymentMethodController); + case TRADE_WIZARD_PAYMENT_METHODS: { + return Optional.of(tradeWizardPaymentMethodsController); } case TRADE_WIZARD_AMOUNT: { return Optional.of(tradeWizardAmountController); @@ -333,12 +326,9 @@ private boolean validate(boolean calledFromNext) { return tradeWizardPriceController.validate(); } else if (model.getSelectedChildTarget().get() == NavigationTarget.TRADE_WIZARD_AMOUNT) { return tradeWizardAmountController.validate(); - } else if (calledFromNext && model.getSelectedChildTarget().get() == NavigationTarget.TRADE_WIZARD_BITCOIN_PAYMENT_METHOD) { - // For PaymentMethod we tolerate to go back without having one selected - return tradeWizardBitcoinPaymentMethodController.validate(); - } else if (calledFromNext && model.getSelectedChildTarget().get() == NavigationTarget.TRADE_WIZARD_FIAT_PAYMENT_METHOD) { + } else if (calledFromNext && model.getSelectedChildTarget().get() == NavigationTarget.TRADE_WIZARD_PAYMENT_METHODS) { // For PaymentMethod we tolerate to go back without having one selected - return tradeWizardFiatPaymentMethodController.validate(); + return tradeWizardPaymentMethodsController.validate(); } return true; } @@ -365,8 +355,7 @@ private void reset() { tradeWizardMarketController.reset(); tradeWizardPriceController.reset(); tradeWizardAmountController.reset(); - tradeWizardBitcoinPaymentMethodController.reset(); - tradeWizardFiatPaymentMethodController.reset(); + tradeWizardPaymentMethodsController.reset(); tradeWizardSelectOfferController.reset(); tradeWizardReviewController.reset(); @@ -395,14 +384,14 @@ private void setMainButtonsVisibleState(boolean value) { } private void handleFiatPaymentMethodsUpdate() { - ObservableList fiatPaymentMethods = tradeWizardFiatPaymentMethodController.getFiatPaymentMethods(); + ObservableList fiatPaymentMethods = tradeWizardPaymentMethodsController.getFiatPaymentMethods(); tradeWizardSelectOfferController.setFiatPaymentMethods(fiatPaymentMethods); tradeWizardAmountController.setFiatPaymentMethods(fiatPaymentMethods); tradeWizardReviewController.setFiatPaymentMethods(fiatPaymentMethods); } private void handleBitcoinPaymentMethodsUpdate() { - ObservableList bitcoinPaymentMethods = tradeWizardBitcoinPaymentMethodController.getBitcoinPaymentMethods(); + ObservableList bitcoinPaymentMethods = tradeWizardPaymentMethodsController.getBitcoinPaymentMethods(); tradeWizardSelectOfferController.setBitcoinPaymentMethods(bitcoinPaymentMethods); tradeWizardAmountController.setBitcoinPaymentMethods(bitcoinPaymentMethods); tradeWizardReviewController.setBitcoinPaymentMethods(bitcoinPaymentMethods); diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/TradeWizardView.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/TradeWizardView.java index 720fdd1d4b..a0adddc972 100644 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/TradeWizardView.java +++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/TradeWizardView.java @@ -209,8 +209,7 @@ private Triple> getProgressItems() { priceProgressItemLabel = createAndGetProgressLabel(Res.get("bisqEasy.tradeWizard.progress.price")); priceProgressItemLine = getHLine(); Label amount = createAndGetProgressLabel(Res.get("bisqEasy.tradeWizard.progress.amount")); - Label bitcoinPaymentMethod = createAndGetProgressLabel(Res.get("bisqEasy.tradeWizard.progress.bitcoinPaymentMethod")); - Label fiatPaymentMethod = createAndGetProgressLabel(Res.get("bisqEasy.tradeWizard.progress.fiatPaymentMethod")); + Label paymentMethods = createAndGetProgressLabel(Res.get("bisqEasy.tradeWizard.progress.paymentMethods")); takeOfferProgressItem = createAndGetProgressLabel(Res.get("bisqEasy.tradeWizard.progress.takeOffer")); takeOfferProgressLine = getHLine(); Label review = createAndGetProgressLabel(Res.get("bisqEasy.tradeWizard.progress.review")); @@ -231,9 +230,7 @@ private Triple> getProgressItems() { getHLine(), amount, getHLine(), - bitcoinPaymentMethod, - getHLine(), - fiatPaymentMethod, + paymentMethods, takeOfferProgressLine, takeOfferProgressItem, getHLine(), @@ -241,7 +238,7 @@ private Triple> getProgressItems() { Spacer.fillHBox(), closeButton); - return new Triple<>(hBox, closeButton, new ArrayList<>(List.of(direction, market, amount, bitcoinPaymentMethod, fiatPaymentMethod, takeOfferProgressItem, review))); + return new Triple<>(hBox, closeButton, new ArrayList<>(List.of(direction, market, amount, paymentMethods, takeOfferProgressItem, review))); } private Region getHLine() { diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/btc_payment_method/TradeWizardBitcoinPaymentMethodController.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/btc_payment_method/TradeWizardBitcoinPaymentMethodController.java deleted file mode 100644 index 6d018ea78e..0000000000 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/btc_payment_method/TradeWizardBitcoinPaymentMethodController.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.desktop.main.content.bisq_easy.trade_wizard.btc_payment_method; - -import bisq.account.payment_method.BitcoinPaymentMethod; -import bisq.account.payment_method.BitcoinPaymentMethodUtil; -import bisq.account.payment_method.BitcoinPaymentRail; -import bisq.account.payment_method.PaymentMethodUtil; -import bisq.desktop.ServiceProvider; -import bisq.desktop.common.view.Controller; -import bisq.desktop.components.overlay.Popup; -import bisq.i18n.Res; -import bisq.offer.Direction; -import bisq.settings.CookieKey; -import bisq.settings.SettingsService; -import com.google.common.base.Joiner; -import javafx.collections.ObservableList; -import javafx.scene.layout.Region; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; - -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -@Slf4j -public class TradeWizardBitcoinPaymentMethodController implements Controller { - private final TradeWizardBitcoinPaymentMethodModel model; - @Getter - private final TradeWizardBitcoinPaymentMethodView view; - private final SettingsService settingsService; - private final Runnable onNextHandler; - private final Region owner; - - public TradeWizardBitcoinPaymentMethodController(ServiceProvider serviceProvider, Region owner, Runnable onNextHandler) { - settingsService = serviceProvider.getSettingsService(); - this.onNextHandler = onNextHandler; - this.owner = owner; - - model = new TradeWizardBitcoinPaymentMethodModel(); - view = new TradeWizardBitcoinPaymentMethodView(model, this); - } - - public ObservableList getBitcoinPaymentMethods() { - return model.getSelectedBitcoinPaymentMethods(); - } - - public boolean validate() { - if (model.getSelectedBitcoinPaymentMethods().isEmpty()) { - new Popup().invalid(Res.get("bisqEasy.tradeWizard.paymentMethod.warn.noPaymentMethodSelected")) - .owner(owner) - .show(); - return false; - } else { - return true; - } - } - - public void setDirection(Direction direction) { - if (direction != null) { - model.setDirection(direction); - } - } - - public void reset() { - model.reset(); - } - - @Override - public void onActivate() { - List paymentMethods = Stream.of(BitcoinPaymentRail.MAIN_CHAIN, BitcoinPaymentRail.LN) - .map(BitcoinPaymentMethod::fromPaymentRail) - .collect(Collectors.toList()); - model.getBitcoinPaymentMethods().setAll(paymentMethods); - - model.setHeadline(model.getDirection().isBuy() ? - Res.get("bisqEasy.tradeWizard.paymentMethod.btc.headline.buyer") : - Res.get("bisqEasy.tradeWizard.paymentMethod.btc.headline.seller")); - model.getSortedBitcoinPaymentMethods().setComparator(Comparator.comparingInt(o -> o.getPaymentRail().ordinal())); - settingsService.getCookie().asString(CookieKey.CREATE_OFFER_BITCOIN_METHODS) - .ifPresent(names -> { - List.of(names.split(",")).forEach(name -> { - if (name.isEmpty()) { - return; - } - BitcoinPaymentMethod bitcoinPaymentMethod = BitcoinPaymentMethodUtil.getPaymentMethod(name); - maybeAddBitcoinPaymentMethod(bitcoinPaymentMethod); - }); - }); - } - - @Override - public void onDeactivate() { - } - - boolean onTogglePaymentMethod(BitcoinPaymentMethod bitcoinPaymentMethod, boolean isSelected) { - if (isSelected) { - if (model.getSelectedBitcoinPaymentMethods().size() >= 4) { - new Popup().warning(Res.get("bisqEasy.tradeWizard.paymentMethod.warn.maxMethodsReached")).show(); - return false; - } - maybeAddBitcoinPaymentMethod(bitcoinPaymentMethod); - } else { - model.getSelectedBitcoinPaymentMethods().remove(bitcoinPaymentMethod); - setCookie(); - } - return true; - } - - void onRemoveCustomMethod(BitcoinPaymentMethod bitcoinPaymentMethod) { - model.getAddedCustomBitcoinPaymentMethods().remove(bitcoinPaymentMethod); - model.getSelectedBitcoinPaymentMethods().remove(bitcoinPaymentMethod); - model.getBitcoinPaymentMethods().remove(bitcoinPaymentMethod); - setCookie(); - } - - private void maybeAddBitcoinPaymentMethod(BitcoinPaymentMethod bitcoinPaymentMethod) { - if (!model.getSelectedBitcoinPaymentMethods().contains(bitcoinPaymentMethod)) { - model.getSelectedBitcoinPaymentMethods().add(bitcoinPaymentMethod); - setCookie(); - } - if (!model.getBitcoinPaymentMethods().contains(bitcoinPaymentMethod)) { - model.getBitcoinPaymentMethods().add(bitcoinPaymentMethod); - } - } - - private void setCookie() { - settingsService.setCookie(CookieKey.CREATE_OFFER_BITCOIN_METHODS, - Joiner.on(",").join(PaymentMethodUtil.getPaymentMethodNames(model.getSelectedBitcoinPaymentMethods()))); - } -} diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/btc_payment_method/TradeWizardBitcoinPaymentMethodModel.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/btc_payment_method/TradeWizardBitcoinPaymentMethodModel.java deleted file mode 100644 index 6f762c1aeb..0000000000 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/btc_payment_method/TradeWizardBitcoinPaymentMethodModel.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.desktop.main.content.bisq_easy.trade_wizard.btc_payment_method; - -import bisq.account.payment_method.BitcoinPaymentMethod; -import bisq.desktop.common.view.Model; -import bisq.offer.Direction; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import javafx.collections.transformation.SortedList; -import lombok.Getter; -import lombok.Setter; - -@Getter -public class TradeWizardBitcoinPaymentMethodModel implements Model { - @Setter - private Direction direction; - @Setter - private String headline; - private final ObservableList bitcoinPaymentMethods = FXCollections.observableArrayList(); - private final SortedList sortedBitcoinPaymentMethods = new SortedList<>(bitcoinPaymentMethods); - private final ObservableList selectedBitcoinPaymentMethods = FXCollections.observableArrayList(); - private final ObservableList addedCustomBitcoinPaymentMethods = FXCollections.observableArrayList(); - - void reset() { - direction = null; - headline = null; - bitcoinPaymentMethods.clear(); - selectedBitcoinPaymentMethods.clear(); - } -} \ No newline at end of file diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/btc_payment_method/TradeWizardBitcoinPaymentMethodView.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/btc_payment_method/TradeWizardBitcoinPaymentMethodView.java deleted file mode 100644 index b19dd03299..0000000000 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/btc_payment_method/TradeWizardBitcoinPaymentMethodView.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.desktop.main.content.bisq_easy.trade_wizard.btc_payment_method; - -import bisq.account.payment_method.BitcoinPaymentMethod; -import bisq.desktop.common.threading.UIThread; -import bisq.desktop.common.utils.ImageUtil; -import bisq.desktop.common.view.View; -import bisq.desktop.components.containers.Spacer; -import bisq.desktop.components.controls.BisqTooltip; -import bisq.desktop.components.controls.ChipButton; -import bisq.i18n.Res; -import javafx.collections.ListChangeListener; -import javafx.geometry.Insets; -import javafx.geometry.Pos; -import javafx.scene.control.Label; -import javafx.scene.image.ImageView; -import javafx.scene.layout.FlowPane; -import javafx.scene.layout.VBox; -import javafx.scene.text.TextAlignment; -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class TradeWizardBitcoinPaymentMethodView extends View { - private final ListChangeListener paymentMethodListener; - private final FlowPane flowPane; - private final Label headlineLabel; - - public TradeWizardBitcoinPaymentMethodView(TradeWizardBitcoinPaymentMethodModel model, TradeWizardBitcoinPaymentMethodController controller) { - super(new VBox(10), model, controller); - - root.setAlignment(Pos.TOP_CENTER); - - headlineLabel = new Label(); - headlineLabel.getStyleClass().add("bisq-text-headline-2"); - - Label subtitleLabel = new Label(Res.get("bisqEasy.tradeWizard.paymentMethod.btc.subTitle")); - subtitleLabel.setTextAlignment(TextAlignment.CENTER); - subtitleLabel.setAlignment(Pos.CENTER); - subtitleLabel.getStyleClass().add("bisq-text-3"); - subtitleLabel.setWrapText(true); - subtitleLabel.setMaxWidth(600); - - flowPane = new FlowPane(); - flowPane.setAlignment(Pos.CENTER); - flowPane.setVgap(20); - flowPane.setHgap(20); - - VBox.setMargin(headlineLabel, new Insets(-10, 0, 0, 0)); - VBox.setMargin(flowPane, new Insets(20, 90, 25, 90)); - root.getChildren().addAll(Spacer.fillVBox(), headlineLabel, subtitleLabel, flowPane, Spacer.fillVBox()); - - paymentMethodListener = c -> { - c.next(); - fillPaymentMethods(); - }; - } - - @Override - protected void onViewAttached() { - headlineLabel.setText(model.getHeadline()); - - model.getBitcoinPaymentMethods().addListener(paymentMethodListener); - - root.setOnMousePressed(e -> root.requestFocus()); - - fillPaymentMethods(); - } - - @Override - protected void onViewDetached() { - flowPane.getChildren().stream() - .filter(e -> e instanceof ChipButton) - .map(e -> (ChipButton) e) - .forEach(chipToggleButton -> chipToggleButton.setOnAction(null)); - - model.getBitcoinPaymentMethods().removeListener(paymentMethodListener); - - root.setOnMousePressed(null); - } - - private void fillPaymentMethods() { - flowPane.getChildren().clear(); - for (BitcoinPaymentMethod bitcoinPaymentMethod : model.getSortedBitcoinPaymentMethods()) { - // enum name or custom name - ChipButton chipButton = new ChipButton(bitcoinPaymentMethod.getShortDisplayString()); - if (!bitcoinPaymentMethod.getShortDisplayString().equals(bitcoinPaymentMethod.getDisplayString())) { - chipButton.setTooltip(new BisqTooltip(bitcoinPaymentMethod.getDisplayString())); - } - if (model.getSelectedBitcoinPaymentMethods().contains(bitcoinPaymentMethod)) { - chipButton.setSelected(true); - } - chipButton.setOnAction(() -> { - boolean wasAdded = controller.onTogglePaymentMethod(bitcoinPaymentMethod, chipButton.isSelected()); - if (!wasAdded) { - UIThread.runOnNextRenderFrame(() -> chipButton.setSelected(false)); - } - }); - model.getAddedCustomBitcoinPaymentMethods().stream() - .filter(customMethod -> customMethod.equals(bitcoinPaymentMethod)) - .findAny() - .ifPresentOrElse( - customMethod -> { - ImageView closeIcon = chipButton.setRightIcon("remove-white"); - closeIcon.setOnMousePressed(e -> controller.onRemoveCustomMethod(bitcoinPaymentMethod)); - }, - () -> { - // Lookup for an image with the id of the BitcoinPaymentRail enum name (MAIN_CHAIN) - ImageView icon = ImageUtil.getImageViewById(bitcoinPaymentMethod.getName()); - chipButton.setLeftIcon(icon); - }); - flowPane.getChildren().add(chipButton); - } - } -} diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/fiat_payment_method/TradeWizardFiatPaymentMethodController.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsController.java similarity index 58% rename from apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/fiat_payment_method/TradeWizardFiatPaymentMethodController.java rename to apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsController.java index 85ea71d5e4..f965688c68 100644 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/fiat_payment_method/TradeWizardFiatPaymentMethodController.java +++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsController.java @@ -15,12 +15,9 @@ * along with Bisq. If not, see . */ -package bisq.desktop.main.content.bisq_easy.trade_wizard.fiat_payment_method; +package bisq.desktop.main.content.bisq_easy.trade_wizard.payment_methods; -import bisq.account.payment_method.FiatPaymentMethod; -import bisq.account.payment_method.FiatPaymentMethodUtil; -import bisq.account.payment_method.PaymentMethod; -import bisq.account.payment_method.PaymentMethodUtil; +import bisq.account.payment_method.*; import bisq.common.currency.Market; import bisq.common.util.StringUtils; import bisq.desktop.ServiceProvider; @@ -31,6 +28,7 @@ import bisq.settings.CookieKey; import bisq.settings.SettingsService; import com.google.common.base.Joiner; +import javafx.collections.ListChangeListener; import javafx.collections.ObservableList; import javafx.scene.layout.Region; import lombok.Getter; @@ -41,33 +39,43 @@ import java.util.Comparator; import java.util.HashSet; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; @Slf4j -public class TradeWizardFiatPaymentMethodController implements Controller { - private final TradeWizardFiatPaymentMethodModel model; +public class TradeWizardPaymentMethodsController implements Controller { + private static final BitcoinPaymentMethod ON_CHAIN_PAYMENT_METHOD = BitcoinPaymentMethod.fromPaymentRail(BitcoinPaymentRail.MAIN_CHAIN); + private static final BitcoinPaymentMethod LN_PAYMENT_METHOD = BitcoinPaymentMethod.fromPaymentRail(BitcoinPaymentRail.LN); + + private final TradeWizardPaymentMethodsModel model; @Getter - private final TradeWizardFiatPaymentMethodView view; + private final TradeWizardPaymentMethodsView view; private final SettingsService settingsService; private final Runnable onNextHandler; private final Region owner; - private Subscription customMethodPin; + private Subscription customMethodPin, isLNMethodAllowedPin; + private ListChangeListener selectedBitcoinPaymentMethodsListener; - public TradeWizardFiatPaymentMethodController(ServiceProvider serviceProvider, Region owner, Runnable onNextHandler) { + public TradeWizardPaymentMethodsController(ServiceProvider serviceProvider, Region owner, Runnable onNextHandler) { settingsService = serviceProvider.getSettingsService(); this.onNextHandler = onNextHandler; this.owner = owner; - model = new TradeWizardFiatPaymentMethodModel(); - view = new TradeWizardFiatPaymentMethodView(model, this); + model = new TradeWizardPaymentMethodsModel(); + view = new TradeWizardPaymentMethodsView(model, this); } public ObservableList getFiatPaymentMethods() { return model.getSelectedFiatPaymentMethods(); } + public ObservableList getBitcoinPaymentMethods() { + return model.getSelectedBitcoinPaymentMethods(); + } + public boolean validate() { if (getCustomFiatPaymentMethodNameNotEmpty()) { - tryAddCustomPaymentMethodAndNavigateNext(); + tryAddCustomFiatPaymentMethodAndNavigateNext(); return true; } if (model.getSelectedFiatPaymentMethods().isEmpty()) { @@ -84,8 +92,8 @@ public boolean getCustomFiatPaymentMethodNameNotEmpty() { return StringUtils.isNotEmpty(model.getCustomFiatPaymentMethodName().get()); } - public void tryAddCustomPaymentMethodAndNavigateNext() { - if (doAddCustomMethod()) { + public void tryAddCustomFiatPaymentMethodAndNavigateNext() { + if (doAddCustomFiatMethod()) { onNextHandler.run(); } } @@ -114,11 +122,23 @@ public void reset() { @Override public void onActivate() { - model.setHeadline(model.getDirection().isBuy() ? - Res.get("bisqEasy.tradeWizard.paymentMethod.headline.buyer", model.getMarket().get().getQuoteCurrencyCode()) : - Res.get("bisqEasy.tradeWizard.paymentMethod.headline.seller", model.getMarket().get().getQuoteCurrencyCode())); + model.setHeadline(model.getDirection().isBuy() + ? Res.get("bisqEasy.tradeWizard.paymentMethod.headline.buyer", model.getMarket().get().getQuoteCurrencyCode()) + : Res.get("bisqEasy.tradeWizard.paymentMethod.headline.seller", model.getMarket().get().getQuoteCurrencyCode())); model.getCustomFiatPaymentMethodName().set(""); model.getSortedFiatPaymentMethods().setComparator(Comparator.comparing(PaymentMethod::getShortDisplayString)); + + List paymentMethods = Stream.of(BitcoinPaymentRail.MAIN_CHAIN, BitcoinPaymentRail.LN) + .map(BitcoinPaymentMethod::fromPaymentRail) + .collect(Collectors.toList()); + model.getBitcoinPaymentMethods().setAll(paymentMethods); + model.getSelectedBitcoinPaymentMethods().setAll(ON_CHAIN_PAYMENT_METHOD); // By default, always allow on chain + selectedBitcoinPaymentMethodsListener = change -> { + boolean isLNSelected = model.getSelectedBitcoinPaymentMethods().contains(LN_PAYMENT_METHOD); + model.getIsLNMethodAllowed().set(isLNSelected); + }; + model.getSelectedBitcoinPaymentMethods().addListener(selectedBitcoinPaymentMethodsListener); + settingsService.getCookie().asString(CookieKey.CREATE_OFFER_METHODS, getCookieSubKey()) .ifPresent(names -> { List.of(names.split(",")).forEach(name -> { @@ -134,16 +154,30 @@ public void onActivate() { } }); }); + settingsService.getCookie().asString(CookieKey.CREATE_OFFER_BITCOIN_METHODS) + .ifPresent(names -> { + List.of(names.split(",")).forEach(name -> { + if (name.isEmpty()) { + return; + } + BitcoinPaymentMethod bitcoinPaymentMethod = BitcoinPaymentMethodUtil.getPaymentMethod(name); + maybeAddBitcoinPaymentMethod(bitcoinPaymentMethod); + }); + }); customMethodPin = EasyBind.subscribe(model.getCustomFiatPaymentMethodName(), customMethod -> model.getIsAddCustomMethodIconEnabled().set(customMethod != null && !customMethod.isEmpty())); + isLNMethodAllowedPin = EasyBind.subscribe(model.getIsLNMethodAllowed(), isLNAllowed -> + onToggleBitcoinPaymentMethod(LN_PAYMENT_METHOD, isLNAllowed)); } @Override public void onDeactivate() { + model.getSelectedBitcoinPaymentMethods().removeListener(selectedBitcoinPaymentMethodsListener); customMethodPin.unsubscribe(); + isLNMethodAllowedPin.unsubscribe(); } - boolean onTogglePaymentMethod(FiatPaymentMethod fiatPaymentMethod, boolean isSelected) { + boolean onToggleFiatPaymentMethod(FiatPaymentMethod fiatPaymentMethod, boolean isSelected) { if (isSelected) { if (model.getSelectedFiatPaymentMethods().size() >= 4) { new Popup().warning(Res.get("bisqEasy.tradeWizard.paymentMethod.warn.maxMethodsReached")).show(); @@ -152,16 +186,16 @@ boolean onTogglePaymentMethod(FiatPaymentMethod fiatPaymentMethod, boolean isSel maybeAddFiatPaymentMethod(fiatPaymentMethod); } else { model.getSelectedFiatPaymentMethods().remove(fiatPaymentMethod); - setCookie(); + setCreateOfferFiatMethodsCookie(); } return true; } - void onAddCustomMethod() { - doAddCustomMethod(); + void onAddCustomFiatMethod() { + doAddCustomFiatMethod(); } - private boolean doAddCustomMethod() { + private boolean doAddCustomFiatMethod() { if (model.getSelectedFiatPaymentMethods().size() >= 4) { new Popup().warning(Res.get("bisqEasy.tradeWizard.paymentMethod.warn.maxMethodsReached")).show(); return false; @@ -181,7 +215,7 @@ private boolean doAddCustomMethod() { private void maybeAddFiatPaymentMethod(FiatPaymentMethod fiatPaymentMethod) { if (!model.getSelectedFiatPaymentMethods().contains(fiatPaymentMethod)) { model.getSelectedFiatPaymentMethods().add(fiatPaymentMethod); - setCookie(); + setCreateOfferFiatMethodsCookie(); } if (!model.getFiatPaymentMethods().contains(fiatPaymentMethod)) { model.getFiatPaymentMethods().add(fiatPaymentMethod); @@ -208,14 +242,14 @@ private boolean isPredefinedPaymentMethodsContainName(String name) { return new HashSet<>(PaymentMethodUtil.getPaymentMethodNames(model.getFiatPaymentMethods())).contains(name); } - void onRemoveCustomMethod(FiatPaymentMethod fiatPaymentMethod) { + void onRemoveFiatCustomMethod(FiatPaymentMethod fiatPaymentMethod) { model.getAddedCustomFiatPaymentMethods().remove(fiatPaymentMethod); model.getSelectedFiatPaymentMethods().remove(fiatPaymentMethod); model.getFiatPaymentMethods().remove(fiatPaymentMethod); - setCookie(); + setCreateOfferFiatMethodsCookie(); } - private void setCookie() { + private void setCreateOfferFiatMethodsCookie() { settingsService.setCookie(CookieKey.CREATE_OFFER_METHODS, getCookieSubKey(), Joiner.on(",").join(PaymentMethodUtil.getPaymentMethodNames(model.getSelectedFiatPaymentMethods()))); } @@ -223,4 +257,40 @@ private void setCookie() { private String getCookieSubKey() { return model.getMarket().get().getMarketCodes(); } + + private boolean onToggleBitcoinPaymentMethod(BitcoinPaymentMethod bitcoinPaymentMethod, boolean isSelected) { + if (isSelected) { + if (model.getSelectedBitcoinPaymentMethods().size() >= 4) { + new Popup().warning(Res.get("bisqEasy.tradeWizard.paymentMethod.warn.maxMethodsReached")).show(); + return false; + } + maybeAddBitcoinPaymentMethod(bitcoinPaymentMethod); + } else { + model.getSelectedBitcoinPaymentMethods().remove(bitcoinPaymentMethod); + setCreateOfferBitcoinMethodsCookie(); + } + return true; + } + + private void onRemoveCustomBitcoinMethod(BitcoinPaymentMethod bitcoinPaymentMethod) { + model.getAddedCustomBitcoinPaymentMethods().remove(bitcoinPaymentMethod); + model.getSelectedBitcoinPaymentMethods().remove(bitcoinPaymentMethod); + model.getBitcoinPaymentMethods().remove(bitcoinPaymentMethod); + setCreateOfferBitcoinMethodsCookie(); + } + + private void maybeAddBitcoinPaymentMethod(BitcoinPaymentMethod bitcoinPaymentMethod) { + if (!model.getSelectedBitcoinPaymentMethods().contains(bitcoinPaymentMethod)) { + model.getSelectedBitcoinPaymentMethods().add(bitcoinPaymentMethod); + setCreateOfferBitcoinMethodsCookie(); + } + if (!model.getBitcoinPaymentMethods().contains(bitcoinPaymentMethod)) { + model.getBitcoinPaymentMethods().add(bitcoinPaymentMethod); + } + } + + private void setCreateOfferBitcoinMethodsCookie() { + settingsService.setCookie(CookieKey.CREATE_OFFER_BITCOIN_METHODS, + Joiner.on(",").join(PaymentMethodUtil.getPaymentMethodNames(model.getSelectedBitcoinPaymentMethods()))); + } } diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/fiat_payment_method/TradeWizardFiatPaymentMethodModel.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsModel.java similarity index 76% rename from apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/fiat_payment_method/TradeWizardFiatPaymentMethodModel.java rename to apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsModel.java index 23d18a489b..de0605e0d8 100644 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/fiat_payment_method/TradeWizardFiatPaymentMethodModel.java +++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsModel.java @@ -15,8 +15,9 @@ * along with Bisq. If not, see . */ -package bisq.desktop.main.content.bisq_easy.trade_wizard.fiat_payment_method; +package bisq.desktop.main.content.bisq_easy.trade_wizard.payment_methods; +import bisq.account.payment_method.BitcoinPaymentMethod; import bisq.account.payment_method.FiatPaymentMethod; import bisq.common.currency.Market; import bisq.desktop.common.view.Model; @@ -29,7 +30,7 @@ import lombok.Setter; @Getter -public class TradeWizardFiatPaymentMethodModel implements Model { +public class TradeWizardPaymentMethodsModel implements Model { @Setter private Direction direction; @Setter @@ -38,9 +39,13 @@ public class TradeWizardFiatPaymentMethodModel implements Model { private final SortedList sortedFiatPaymentMethods = new SortedList<>(fiatPaymentMethods); private final ObservableList selectedFiatPaymentMethods = FXCollections.observableArrayList(); private final ObservableList addedCustomFiatPaymentMethods = FXCollections.observableArrayList(); + private final ObservableList bitcoinPaymentMethods = FXCollections.observableArrayList(); + private final ObservableList selectedBitcoinPaymentMethods = FXCollections.observableArrayList(); + private final ObservableList addedCustomBitcoinPaymentMethods = FXCollections.observableArrayList(); private final StringProperty customFiatPaymentMethodName = new SimpleStringProperty(""); private final BooleanProperty isPaymentMethodsEmpty = new SimpleBooleanProperty(); private final BooleanProperty isAddCustomMethodIconEnabled = new SimpleBooleanProperty(); + private final BooleanProperty isLNMethodAllowed = new SimpleBooleanProperty(); private final ObjectProperty market = new SimpleObjectProperty<>(); void reset() { @@ -49,9 +54,11 @@ void reset() { fiatPaymentMethods.clear(); selectedFiatPaymentMethods.clear(); addedCustomFiatPaymentMethods.clear(); + bitcoinPaymentMethods.clear(); + selectedBitcoinPaymentMethods.clear(); customFiatPaymentMethodName.set(""); isPaymentMethodsEmpty.set(false); isAddCustomMethodIconEnabled.set(false); market.set(null); } -} \ No newline at end of file +} diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/fiat_payment_method/TradeWizardFiatPaymentMethodView.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsView.java similarity index 69% rename from apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/fiat_payment_method/TradeWizardFiatPaymentMethodView.java rename to apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsView.java index a59fbcbcd7..0025424a42 100644 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/fiat_payment_method/TradeWizardFiatPaymentMethodView.java +++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsView.java @@ -15,7 +15,7 @@ * along with Bisq. If not, see . */ -package bisq.desktop.main.content.bisq_easy.trade_wizard.fiat_payment_method; +package bisq.desktop.main.content.bisq_easy.trade_wizard.payment_methods; import bisq.account.payment_method.FiatPaymentMethod; import bisq.desktop.common.threading.UIThread; @@ -30,9 +30,11 @@ import javafx.collections.ListChangeListener; import javafx.geometry.Insets; import javafx.geometry.Pos; +import javafx.scene.control.CheckBox; import javafx.scene.control.Label; import javafx.scene.image.ImageView; import javafx.scene.layout.FlowPane; +import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.scene.text.TextAlignment; import lombok.extern.slf4j.Slf4j; @@ -40,15 +42,16 @@ import org.fxmisc.easybind.Subscription; @Slf4j -public class TradeWizardFiatPaymentMethodView extends View { +public class TradeWizardPaymentMethodsView extends View { private final MaterialTextField custom; - private final ListChangeListener paymentMethodListener; - private final FlowPane flowPane; + private final ListChangeListener fiatPaymentMethodListener; + private final FlowPane fiatMethodsFlowPane; private final Label headlineLabel, nonFoundLabel; private final BisqIconButton addButton; + private final CheckBox allowLNMethodSwitch; private Subscription addCustomMethodIconEnabledPin; - public TradeWizardFiatPaymentMethodView(TradeWizardFiatPaymentMethodModel model, TradeWizardFiatPaymentMethodController controller) { + public TradeWizardPaymentMethodsView(TradeWizardPaymentMethodsModel model, TradeWizardPaymentMethodsController controller) { super(new VBox(10), model, controller); root.setAlignment(Pos.TOP_CENTER); @@ -67,10 +70,10 @@ public TradeWizardFiatPaymentMethodView(TradeWizardFiatPaymentMethodModel model, nonFoundLabel.getStyleClass().add("bisq-text-6"); nonFoundLabel.setAlignment(Pos.CENTER); - flowPane = new FlowPane(); - flowPane.setAlignment(Pos.CENTER); - flowPane.setVgap(20); - flowPane.setHgap(20); + fiatMethodsFlowPane = new FlowPane(); + fiatMethodsFlowPane.setAlignment(Pos.CENTER); + fiatMethodsFlowPane.setVgap(20); + fiatMethodsFlowPane.setHgap(20); custom = new MaterialTextField(Res.get("bisqEasy.tradeWizard.paymentMethod.customMethod"), Res.get("bisqEasy.tradeWizard.paymentMethod.customMethod.prompt")); @@ -82,13 +85,21 @@ public TradeWizardFiatPaymentMethodView(TradeWizardFiatPaymentMethodModel model, addButton.setAlignment(Pos.CENTER); custom.setMaxWidth(300); + Label allowLNNetworkMethodLabel = new Label(Res.get("bisqEasy.tradeWizard.paymentMethods.allowLN")); + allowLNMethodSwitch = new CheckBox(); + HBox allowLNHBox = new HBox(10, allowLNMethodSwitch, allowLNNetworkMethodLabel); + allowLNHBox.getStyleClass().add("offerbook-subheader-checkbox"); + allowLNHBox.setAlignment(Pos.CENTER); + VBox.setMargin(headlineLabel, new Insets(-10, 0, 0, 0)); - VBox.setMargin(flowPane, new Insets(20, 60, 25, 60)); - root.getChildren().addAll(Spacer.fillVBox(), headlineLabel, subtitleLabel, nonFoundLabel, flowPane, custom, Spacer.fillVBox()); + VBox.setMargin(fiatMethodsFlowPane, new Insets(20, 60, 10, 60)); + VBox.setMargin(allowLNHBox, new Insets(20, 0, 0, 0)); + root.getChildren().addAll(Spacer.fillVBox(), headlineLabel, subtitleLabel, nonFoundLabel, fiatMethodsFlowPane, + custom, allowLNHBox, Spacer.fillVBox()); - paymentMethodListener = c -> { + fiatPaymentMethodListener = c -> { c.next(); - fillPaymentMethods(); + fillFiatPaymentMethods(); }; } @@ -98,21 +109,22 @@ protected void onViewAttached() { custom.textProperty().bindBidirectional(model.getCustomFiatPaymentMethodName()); nonFoundLabel.visibleProperty().bind(model.getIsPaymentMethodsEmpty()); nonFoundLabel.managedProperty().bind(model.getIsPaymentMethodsEmpty()); - flowPane.visibleProperty().bind(model.getIsPaymentMethodsEmpty().not()); - flowPane.managedProperty().bind(model.getIsPaymentMethodsEmpty().not()); + fiatMethodsFlowPane.visibleProperty().bind(model.getIsPaymentMethodsEmpty().not()); + fiatMethodsFlowPane.managedProperty().bind(model.getIsPaymentMethodsEmpty().not()); addButton.disableProperty().bind(model.getIsAddCustomMethodIconEnabled().not()); + allowLNMethodSwitch.selectedProperty().bindBidirectional(model.getIsLNMethodAllowed()); addCustomMethodIconEnabledPin = EasyBind.subscribe(model.getIsAddCustomMethodIconEnabled(), enabled -> { custom.setIcon(enabled ? "add" : "add-white"); addButton.setOpacity(enabled ? 1 : 0.15); }); - model.getFiatPaymentMethods().addListener(paymentMethodListener); + model.getFiatPaymentMethods().addListener(fiatPaymentMethodListener); - addButton.setOnAction(e -> controller.onAddCustomMethod()); + addButton.setOnAction(e -> controller.onAddCustomFiatMethod()); root.setOnMousePressed(e -> root.requestFocus()); - fillPaymentMethods(); + fillFiatPaymentMethods(); } @Override @@ -120,25 +132,26 @@ protected void onViewDetached() { custom.textProperty().unbindBidirectional(model.getCustomFiatPaymentMethodName()); nonFoundLabel.visibleProperty().unbind(); nonFoundLabel.managedProperty().unbind(); - flowPane.visibleProperty().unbind(); - flowPane.managedProperty().unbind(); + fiatMethodsFlowPane.visibleProperty().unbind(); + fiatMethodsFlowPane.managedProperty().unbind(); addButton.disableProperty().unbind(); + allowLNMethodSwitch.selectedProperty().unbindBidirectional(model.getIsLNMethodAllowed()); - flowPane.getChildren().stream() + fiatMethodsFlowPane.getChildren().stream() .filter(e -> e instanceof ChipButton) .map(e -> (ChipButton) e) .forEach(chipToggleButton -> chipToggleButton.setOnAction(null)); addCustomMethodIconEnabledPin.unsubscribe(); - model.getFiatPaymentMethods().removeListener(paymentMethodListener); + model.getFiatPaymentMethods().removeListener(fiatPaymentMethodListener); addButton.setOnAction(null); root.setOnMousePressed(null); } - private void fillPaymentMethods() { - flowPane.getChildren().clear(); + private void fillFiatPaymentMethods() { + fiatMethodsFlowPane.getChildren().clear(); for (FiatPaymentMethod fiatPaymentMethod : model.getSortedFiatPaymentMethods()) { // enum name or custom name ChipButton chipButton = new ChipButton(fiatPaymentMethod.getShortDisplayString()); @@ -149,7 +162,7 @@ private void fillPaymentMethods() { chipButton.setSelected(true); } chipButton.setOnAction(() -> { - boolean wasAdded = controller.onTogglePaymentMethod(fiatPaymentMethod, chipButton.isSelected()); + boolean wasAdded = controller.onToggleFiatPaymentMethod(fiatPaymentMethod, chipButton.isSelected()); if (!wasAdded) { UIThread.runOnNextRenderFrame(() -> chipButton.setSelected(false)); } @@ -160,14 +173,14 @@ private void fillPaymentMethods() { .ifPresentOrElse( customMethod -> { ImageView closeIcon = chipButton.setRightIcon("remove-white"); - closeIcon.setOnMousePressed(e -> controller.onRemoveCustomMethod(fiatPaymentMethod)); + closeIcon.setOnMousePressed(e -> controller.onRemoveFiatCustomMethod(fiatPaymentMethod)); }, () -> { // Lookup for an image with the id of the enum name (REVOLUT) ImageView icon = ImageUtil.getImageViewById(fiatPaymentMethod.getName()); chipButton.setLeftIcon(icon); }); - flowPane.getChildren().add(chipButton); + fiatMethodsFlowPane.getChildren().add(chipButton); } } } diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/chat/message_container/list/message_box/MyTextMessageBox.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/chat/message_container/list/message_box/MyTextMessageBox.java index 1e8f637092..a4f2b55bfe 100644 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/chat/message_container/list/message_box/MyTextMessageBox.java +++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/chat/message_container/list/message_box/MyTextMessageBox.java @@ -92,6 +92,7 @@ public MyTextMessageBox(ChatMessageListItem toggleReaction.execute(reactionItem)); + + ColorAdjust colorAdjust = new ColorAdjust(); + colorAdjust.setBrightness(-0.1); + applyIconColorAdjustment(colorAdjust); } private ActiveReactionMenuItem(String iconId) { diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/chat/message_container/list/reactions_box/ReactMenuBox.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/chat/message_container/list/reactions_box/ReactMenuBox.java index 66320d921b..f63141a90d 100644 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/chat/message_container/list/reactions_box/ReactMenuBox.java +++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/chat/message_container/list/reactions_box/ReactMenuBox.java @@ -26,6 +26,7 @@ import javafx.collections.ObservableList; import javafx.css.PseudoClass; import javafx.scene.Node; +import javafx.scene.effect.ColorAdjust; import lombok.Getter; import java.util.ArrayList; @@ -89,6 +90,10 @@ private ReactionMenuItem(ReactionItem reactionItem, ToggleReaction toggleReactio getStyleClass().add("reaction-menu-item"); setOnAction(e -> toggleReaction.execute(reactionItem)); setIsReactionSelected(reactionItem.getSelected().get()); + + ColorAdjust colorAdjust = new ColorAdjust(); + colorAdjust.setBrightness(-0.1); + applyIconColorAdjustment(colorAdjust); } private ReactionMenuItem(String iconId) { diff --git a/apps/desktop/desktop/src/main/resources/css/base.css b/apps/desktop/desktop/src/main/resources/css/base.css index be35169c8b..e803610eeb 100644 --- a/apps/desktop/desktop/src/main/resources/css/base.css +++ b/apps/desktop/desktop/src/main/resources/css/base.css @@ -55,6 +55,8 @@ -bisq2-green-dim-80: #11220e; -bisq2-green-dim-90: #081107; + -bisq2-green-desaturated: #2c372b; /* -bisq2-green; saturation -70; lightness -60 */ + -bisq2-yellow: #d0831f; -bisq2-yellow-dim-10: #bb751b; -bisq2-yellow-dim-20: #a66818; @@ -132,6 +134,9 @@ -fx-mid-text-color, -fx-dark-text-color ); + + -bisq2-my-bubble-message: -bisq2-green-desaturated; + -bisq2-peer-bubble-message: -bisq-dark-grey-40; } /* Avoid color artefacts at antialias */ diff --git a/apps/desktop/desktop/src/main/resources/css/chat.css b/apps/desktop/desktop/src/main/resources/css/chat.css index e1564637ac..15b5f9af2f 100644 --- a/apps/desktop/desktop/src/main/resources/css/chat.css +++ b/apps/desktop/desktop/src/main/resources/css/chat.css @@ -162,7 +162,7 @@ /* Peer Message Background */ .chat-message-bg-peer-message, .chat-peer-offer-message-bg { - -fx-background-color: -bisq-dark-grey-40; + -fx-background-color: -bisq2-peer-bubble-message; -fx-background-radius: 8; } @@ -222,7 +222,7 @@ /* My Message Background */ .chat-message-bg-my-message, .chat-my-offer-message-bg { - -fx-background-color: #2c372b; /* -bisq2-green; saturation -70; lightness -60 */ + -fx-background-color: -bisq2-my-bubble-message; -fx-background-radius: 8; } @@ -561,7 +561,6 @@ -fx-font-size: 10; -fx-text-fill: -bisq-white; -fx-font-family: "IBM Plex Sans SemiBold"; - -fx-background-color: -bisq-dark-grey-40; -fx-background-radius: 15; -fx-padding: 6; } @@ -572,3 +571,11 @@ -fx-border-radius: 15; -fx-padding: 5 !important; } + +.my-text-message-box-active-reactions .button.bisq-menu-item.active-reaction-menu-item { + -fx-background-color: -bisq2-my-bubble-message; +} + +.peer-text-message-box-active-reactions .button.bisq-menu-item.active-reaction-menu-item { + -fx-background-color: -bisq2-peer-bubble-message; +} diff --git a/bisq-easy/src/main/java/bisq/bisq_easy/NavigationTarget.java b/bisq-easy/src/main/java/bisq/bisq_easy/NavigationTarget.java index 8f9033ee02..6da0aa51b2 100644 --- a/bisq-easy/src/main/java/bisq/bisq_easy/NavigationTarget.java +++ b/bisq-easy/src/main/java/bisq/bisq_easy/NavigationTarget.java @@ -55,8 +55,7 @@ public enum NavigationTarget { TRADE_WIZARD_MARKET(TRADE_WIZARD, false), TRADE_WIZARD_PRICE(TRADE_WIZARD, false), TRADE_WIZARD_AMOUNT(TRADE_WIZARD, false), - TRADE_WIZARD_BITCOIN_PAYMENT_METHOD(TRADE_WIZARD, false), - TRADE_WIZARD_FIAT_PAYMENT_METHOD(TRADE_WIZARD, false), + TRADE_WIZARD_PAYMENT_METHODS(TRADE_WIZARD, false), TRADE_WIZARD_TAKE_OFFER_OFFER(TRADE_WIZARD, false), TRADE_WIZARD_REVIEW_OFFER(TRADE_WIZARD, false), diff --git a/i18n/src/main/resources/bisq_easy.properties b/i18n/src/main/resources/bisq_easy.properties index 1954fd4d59..903deb53e8 100644 --- a/i18n/src/main/resources/bisq_easy.properties +++ b/i18n/src/main/resources/bisq_easy.properties @@ -56,8 +56,7 @@ bisqEasy.tradeWizard.progress.direction=Buy/Sell bisqEasy.tradeWizard.progress.market=Currency bisqEasy.tradeWizard.progress.price=Price bisqEasy.tradeWizard.progress.amount=Amount -bisqEasy.tradeWizard.progress.bitcoinPaymentMethod=BTC payment -bisqEasy.tradeWizard.progress.fiatPaymentMethod=Fiat payment +bisqEasy.tradeWizard.progress.paymentMethods=Payment methods bisqEasy.tradeWizard.progress.takeOffer=Select offer bisqEasy.tradeWizard.progress.review=Review @@ -153,17 +152,10 @@ bisqEasy.component.amount.baseSide.tooltip.bestOfferPrice=This is the Bitcoin am bisqEasy.component.amount.baseSide.tooltip.buyer.btcAmount=This is the Bitcoin amount to receive bisqEasy.component.amount.baseSide.tooltip.seller.btcAmount=This is the Bitcoin amount to spend bisqEasy.component.amount.baseSide.tooltip.taker.offerPrice=with the offer price: {0} -################################################################################ -# Create offer / Bitcoin payment method -################################################################################ - -bisqEasy.tradeWizard.paymentMethod.btc.headline.buyer=How do you want to send Bitcoin -bisqEasy.tradeWizard.paymentMethod.btc.headline.seller=How do you want to receive Bitcoin -bisqEasy.tradeWizard.paymentMethod.btc.subTitle=Select one or more payment methods ################################################################################ -# Create offer / Fiat payment method +# Create offer / Payment methods ################################################################################ bisqEasy.tradeWizard.paymentMethod.headline.buyer=How do you want to transfer the {0} @@ -178,6 +170,7 @@ bisqEasy.tradeWizard.paymentMethod.warn.maxMethodsReached=You cannot add more th bisqEasy.tradeWizard.paymentMethod.warn.tooLong=A custom payment method name must not be longer than 20 characters. bisqEasy.tradeWizard.paymentMethod.warn.customNameMatchesPredefinedMethod=The name of your custom payment method must not be the same as one of the predefined. bisqEasy.tradeWizard.paymentMethod.warn.noPaymentMethodSelected=Please choose at least one payment method +bisqEasy.tradeWizard.paymentMethods.allowLN=Allow Lightning Network settlement method for this offer ################################################################################