From c345fc7c86c260a226d79bc051e95fb4cbda7d81 Mon Sep 17 00:00:00 2001
From: axpoems <145597137+axpoems@users.noreply.github.com>
Date: Fri, 19 Jul 2024 05:46:43 +0200
Subject: [PATCH 1/9] Refactor: rename fiat payment methods to payment methods
---
.../content/bisq_easy/trade_wizard/TradeWizardController.java | 2 +-
.../TradeWizardFiatPaymentMethodController.java | 2 +-
.../TradeWizardFiatPaymentMethodModel.java | 2 +-
.../TradeWizardFiatPaymentMethodView.java | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
rename apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/{fiat_payment_method => payment_methods}/TradeWizardFiatPaymentMethodController.java (99%)
rename apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/{fiat_payment_method => payment_methods}/TradeWizardFiatPaymentMethodModel.java (96%)
rename apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/{fiat_payment_method => payment_methods}/TradeWizardFiatPaymentMethodView.java (98%)
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..859dfcfb8d 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
@@ -29,7 +29,7 @@
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.TradeWizardFiatPaymentMethodController;
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;
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/TradeWizardFiatPaymentMethodController.java
similarity index 99%
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/TradeWizardFiatPaymentMethodController.java
index 85ea71d5e4..4842f0f50e 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/TradeWizardFiatPaymentMethodController.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.account.payment_method.FiatPaymentMethodUtil;
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/TradeWizardFiatPaymentMethodModel.java
similarity index 96%
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/TradeWizardFiatPaymentMethodModel.java
index 23d18a489b..66e8e8c005 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/TradeWizardFiatPaymentMethodModel.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.common.currency.Market;
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/TradeWizardFiatPaymentMethodView.java
similarity index 98%
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/TradeWizardFiatPaymentMethodView.java
index a59fbcbcd7..46b8345ebd 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/TradeWizardFiatPaymentMethodView.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;
From ea8024cc84e24e42ca57f942d7bec32d3cbbe69c Mon Sep 17 00:00:00 2001
From: axpoems <145597137+axpoems@users.noreply.github.com>
Date: Fri, 19 Jul 2024 06:11:45 +0200
Subject: [PATCH 2/9] Merge Btc methods with fiat methods
---
...radeWizardFiatPaymentMethodController.java | 73 ++++++++++++--
.../TradeWizardFiatPaymentMethodModel.java | 9 +-
.../TradeWizardFiatPaymentMethodView.java | 98 +++++++++++++++----
3 files changed, 150 insertions(+), 30 deletions(-)
diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodController.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodController.java
index 4842f0f50e..4c785927ba 100644
--- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodController.java
+++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodController.java
@@ -17,10 +17,7 @@
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;
@@ -41,6 +38,8 @@
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 {
@@ -65,6 +64,10 @@ public ObservableList getFiatPaymentMethods() {
return model.getSelectedFiatPaymentMethods();
}
+ public ObservableList getBitcoinPaymentMethods() {
+ return model.getSelectedBitcoinPaymentMethods();
+ }
+
public boolean validate() {
if (getCustomFiatPaymentMethodNameNotEmpty()) {
tryAddCustomPaymentMethodAndNavigateNext();
@@ -119,6 +122,13 @@ public void onActivate() {
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.getSortedBitcoinPaymentMethods().setComparator(Comparator.comparingInt(o -> o.getPaymentRail().ordinal()));
+
settingsService.getCookie().asString(CookieKey.CREATE_OFFER_METHODS, getCookieSubKey())
.ifPresent(names -> {
List.of(names.split(",")).forEach(name -> {
@@ -134,6 +144,16 @@ 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()));
}
@@ -152,7 +172,7 @@ boolean onTogglePaymentMethod(FiatPaymentMethod fiatPaymentMethod, boolean isSel
maybeAddFiatPaymentMethod(fiatPaymentMethod);
} else {
model.getSelectedFiatPaymentMethods().remove(fiatPaymentMethod);
- setCookie();
+ setCreateOfferFiatMethodsCookie();
}
return true;
}
@@ -181,7 +201,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);
@@ -212,10 +232,10 @@ void onRemoveCustomMethod(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 +243,41 @@ private void setCookie() {
private String getCookieSubKey() {
return model.getMarket().get().getMarketCodes();
}
+
+ // Bitcoin Payment Methods
+ 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);
+ setCreateOfferBitcoinMethodsCookie();
+ }
+ return true;
+ }
+
+ void onRemoveCustomMethod(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/payment_methods/TradeWizardFiatPaymentMethodModel.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodModel.java
index 66e8e8c005..8c59d692aa 100644
--- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodModel.java
+++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodModel.java
@@ -17,6 +17,7 @@
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;
@@ -38,6 +39,10 @@ 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 SortedList sortedBitcoinPaymentMethods = new SortedList<>(bitcoinPaymentMethods);
+ 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();
@@ -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/payment_methods/TradeWizardFiatPaymentMethodView.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodView.java
index 46b8345ebd..361195047b 100644
--- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodView.java
+++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodView.java
@@ -17,6 +17,7 @@
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.desktop.common.threading.UIThread;
import bisq.desktop.common.utils.ImageUtil;
@@ -42,8 +43,9 @@
@Slf4j
public class TradeWizardFiatPaymentMethodView extends View {
private final MaterialTextField custom;
- private final ListChangeListener paymentMethodListener;
- private final FlowPane flowPane;
+ private final ListChangeListener fiatPaymentMethodListener;
+ private final ListChangeListener bitcoinPaymentMethodListener;
+ private final FlowPane fiatMethodsFlowPane, bitcoinMethodsFlowPane;
private final Label headlineLabel, nonFoundLabel;
private final BisqIconButton addButton;
private Subscription addCustomMethodIconEnabledPin;
@@ -67,10 +69,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 +84,25 @@ public TradeWizardFiatPaymentMethodView(TradeWizardFiatPaymentMethodModel model,
addButton.setAlignment(Pos.CENTER);
custom.setMaxWidth(300);
+ bitcoinMethodsFlowPane = new FlowPane();
+ bitcoinMethodsFlowPane.setAlignment(Pos.CENTER);
+ bitcoinMethodsFlowPane.setVgap(20);
+ bitcoinMethodsFlowPane.setHgap(20);
+
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, 25, 60));
+ VBox.setMargin(bitcoinMethodsFlowPane, new Insets(10, 60, 10, 60));
+ root.getChildren().addAll(Spacer.fillVBox(), headlineLabel, subtitleLabel, nonFoundLabel, fiatMethodsFlowPane,
+ custom, bitcoinMethodsFlowPane, Spacer.fillVBox());
+
+ fiatPaymentMethodListener = c -> {
+ c.next();
+ fillFiatPaymentMethods();
+ };
- paymentMethodListener = c -> {
+ bitcoinPaymentMethodListener = c -> {
c.next();
- fillPaymentMethods();
+ fillBitcoinPaymentMethods();
};
}
@@ -98,8 +112,8 @@ 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());
addCustomMethodIconEnabledPin = EasyBind.subscribe(model.getIsAddCustomMethodIconEnabled(), enabled -> {
@@ -107,12 +121,14 @@ protected void onViewAttached() {
addButton.setOpacity(enabled ? 1 : 0.15);
});
- model.getFiatPaymentMethods().addListener(paymentMethodListener);
+ model.getFiatPaymentMethods().addListener(fiatPaymentMethodListener);
+ model.getBitcoinPaymentMethods().addListener(bitcoinPaymentMethodListener);
addButton.setOnAction(e -> controller.onAddCustomMethod());
root.setOnMousePressed(e -> root.requestFocus());
- fillPaymentMethods();
+ fillFiatPaymentMethods();
+ fillBitcoinPaymentMethods();
}
@Override
@@ -120,25 +136,31 @@ 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();
- flowPane.getChildren().stream()
+ fiatMethodsFlowPane.getChildren().stream()
+ .filter(e -> e instanceof ChipButton)
+ .map(e -> (ChipButton) e)
+ .forEach(chipToggleButton -> chipToggleButton.setOnAction(null));
+
+ bitcoinMethodsFlowPane.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);
+ model.getBitcoinPaymentMethods().removeListener(bitcoinPaymentMethodListener);
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());
@@ -167,7 +189,41 @@ private void fillPaymentMethods() {
ImageView icon = ImageUtil.getImageViewById(fiatPaymentMethod.getName());
chipButton.setLeftIcon(icon);
});
- flowPane.getChildren().add(chipButton);
+ fiatMethodsFlowPane.getChildren().add(chipButton);
+ }
+ }
+
+ private void fillBitcoinPaymentMethods() {
+ bitcoinMethodsFlowPane.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);
+ });
+ bitcoinMethodsFlowPane.getChildren().add(chipButton);
}
}
}
From 2af8fae042956b3564497daa0f6b8e3d66ffe7a0 Mon Sep 17 00:00:00 2001
From: axpoems <145597137+axpoems@users.noreply.github.com>
Date: Fri, 19 Jul 2024 06:31:15 +0200
Subject: [PATCH 3/9] Remove Btc methods step in create offer wizzard
---
.../trade_wizard/TradeWizardController.java | 23 +--
.../trade_wizard/TradeWizardView.java | 5 +-
...eWizardBitcoinPaymentMethodController.java | 147 ------------------
.../TradeWizardBitcoinPaymentMethodModel.java | 46 ------
.../TradeWizardBitcoinPaymentMethodView.java | 130 ----------------
.../java/bisq/bisq_easy/NavigationTarget.java | 1 -
6 files changed, 7 insertions(+), 345 deletions(-)
delete mode 100644 apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/btc_payment_method/TradeWizardBitcoinPaymentMethodController.java
delete mode 100644 apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/btc_payment_method/TradeWizardBitcoinPaymentMethodModel.java
delete mode 100644 apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/btc_payment_method/TradeWizardBitcoinPaymentMethodView.java
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 859dfcfb8d..8833ef5b24 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,7 +27,6 @@
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.payment_methods.TradeWizardFiatPaymentMethodController;
import bisq.desktop.main.content.bisq_easy.trade_wizard.market.TradeWizardMarketController;
@@ -73,7 +72,6 @@ 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 TradeWizardSelectOfferController tradeWizardSelectOfferController;
private final TradeWizardReviewController tradeWizardReviewController;
@@ -99,7 +97,6 @@ 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);
tradeWizardSelectOfferController = new TradeWizardSelectOfferController(serviceProvider,
this::onBack,
@@ -139,7 +136,6 @@ 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_TAKE_OFFER_OFFER,
NavigationTarget.TRADE_WIZARD_REVIEW_OFFER
@@ -155,7 +151,6 @@ public void onActivate() {
tradeWizardMarketController.setDirection(direction);
tradeWizardSelectOfferController.setDirection(direction);
tradeWizardAmountController.setDirection(direction);
- tradeWizardBitcoinPaymentMethodController.setDirection(direction);
tradeWizardFiatPaymentMethodController.setDirection(direction);
tradeWizardPriceController.setDirection(direction);
});
@@ -184,8 +179,9 @@ public void onActivate() {
isBackButtonHighlighted -> model.getIsBackButtonHighlighted().set(isBackButtonHighlighted));
handleFiatPaymentMethodsUpdate();
- tradeWizardBitcoinPaymentMethodController.getBitcoinPaymentMethods().addListener(bitcoinPaymentMethodsListener);
tradeWizardFiatPaymentMethodController.getFiatPaymentMethods().addListener(fiatPaymentMethodsListener);
+ handleBitcoinPaymentMethodsUpdate();
+ tradeWizardFiatPaymentMethodController.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);
+ tradeWizardFiatPaymentMethodController.getBitcoinPaymentMethods().removeListener(bitcoinPaymentMethodsListener);
}
@Override
@@ -210,7 +206,7 @@ protected void onStartProcessNavigationTarget(NavigationTarget navigationTarget,
tradeWizardReviewController.setDataForCreateOffer(
tradeWizardDirectionController.getDirection().get(),
tradeWizardMarketController.getMarket().get(),
- tradeWizardBitcoinPaymentMethodController.getBitcoinPaymentMethods(),
+ tradeWizardFiatPaymentMethodController.getBitcoinPaymentMethods(),
tradeWizardFiatPaymentMethodController.getFiatPaymentMethods(),
tradeWizardAmountController.getQuoteSideAmountSpec().get(),
tradeWizardPriceController.getPriceSpec().get()
@@ -219,7 +215,7 @@ protected void onStartProcessNavigationTarget(NavigationTarget navigationTarget,
} else {
tradeWizardReviewController.setDataForTakeOffer(tradeWizardSelectOfferController.getSelectedBisqEasyOffer().get(),
tradeWizardAmountController.getQuoteSideAmountSpec().get(),
- tradeWizardBitcoinPaymentMethodController.getBitcoinPaymentMethods(),
+ tradeWizardFiatPaymentMethodController.getBitcoinPaymentMethods(),
tradeWizardFiatPaymentMethodController.getFiatPaymentMethods()
);
model.getNextButtonText().set(Res.get("bisqEasy.tradeWizard.review.nextButton.takeOffer"));
@@ -252,9 +248,6 @@ protected Optional extends Controller> 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);
}
@@ -333,9 +326,6 @@ 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) {
// For PaymentMethod we tolerate to go back without having one selected
return tradeWizardFiatPaymentMethodController.validate();
@@ -365,7 +355,6 @@ private void reset() {
tradeWizardMarketController.reset();
tradeWizardPriceController.reset();
tradeWizardAmountController.reset();
- tradeWizardBitcoinPaymentMethodController.reset();
tradeWizardFiatPaymentMethodController.reset();
tradeWizardSelectOfferController.reset();
tradeWizardReviewController.reset();
@@ -402,7 +391,7 @@ private void handleFiatPaymentMethodsUpdate() {
}
private void handleBitcoinPaymentMethodsUpdate() {
- ObservableList bitcoinPaymentMethods = tradeWizardBitcoinPaymentMethodController.getBitcoinPaymentMethods();
+ ObservableList bitcoinPaymentMethods = tradeWizardFiatPaymentMethodController.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..3e6bdc0ca0 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,7 +209,6 @@ 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"));
takeOfferProgressItem = createAndGetProgressLabel(Res.get("bisqEasy.tradeWizard.progress.takeOffer"));
takeOfferProgressLine = getHLine();
@@ -231,8 +230,6 @@ private Triple> getProgressItems() {
getHLine(),
amount,
getHLine(),
- bitcoinPaymentMethod,
- getHLine(),
fiatPaymentMethod,
takeOfferProgressLine,
takeOfferProgressItem,
@@ -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, fiatPaymentMethod, 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/bisq-easy/src/main/java/bisq/bisq_easy/NavigationTarget.java b/bisq-easy/src/main/java/bisq/bisq_easy/NavigationTarget.java
index 8f9033ee02..7cd7fec846 100644
--- a/bisq-easy/src/main/java/bisq/bisq_easy/NavigationTarget.java
+++ b/bisq-easy/src/main/java/bisq/bisq_easy/NavigationTarget.java
@@ -55,7 +55,6 @@ 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_TAKE_OFFER_OFFER(TRADE_WIZARD, false),
TRADE_WIZARD_REVIEW_OFFER(TRADE_WIZARD, false),
From d1d2f5bbe93b67618ccbd4ef21f27cfdb2420a88 Mon Sep 17 00:00:00 2001
From: axpoems <145597137+axpoems@users.noreply.github.com>
Date: Fri, 19 Jul 2024 06:56:46 +0200
Subject: [PATCH 4/9] Refactor: rename fiat payment method to payment methods
---
.../trade_wizard/TradeWizardController.java | 36 +++++++++----------
... TradeWizardPaymentMethodsController.java} | 12 +++----
...va => TradeWizardPaymentMethodsModel.java} | 2 +-
...ava => TradeWizardPaymentMethodsView.java} | 4 +--
4 files changed, 27 insertions(+), 27 deletions(-)
rename apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/{TradeWizardFiatPaymentMethodController.java => TradeWizardPaymentMethodsController.java} (96%)
rename apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/{TradeWizardFiatPaymentMethodModel.java => TradeWizardPaymentMethodsModel.java} (97%)
rename apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/{TradeWizardFiatPaymentMethodView.java => TradeWizardPaymentMethodsView.java} (97%)
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 8833ef5b24..c909b2b85f 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
@@ -28,7 +28,7 @@
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.direction.TradeWizardDirectionController;
-import bisq.desktop.main.content.bisq_easy.trade_wizard.payment_methods.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;
@@ -72,7 +72,7 @@ public InitData(boolean isCreateOfferMode) {
private final TradeWizardMarketController tradeWizardMarketController;
private final TradeWizardPriceController tradeWizardPriceController;
private final TradeWizardAmountController tradeWizardAmountController;
- private final TradeWizardFiatPaymentMethodController tradeWizardFiatPaymentMethodController;
+ private final TradeWizardPaymentMethodsController tradeWizardPaymentMethodsController;
private final TradeWizardSelectOfferController tradeWizardSelectOfferController;
private final TradeWizardReviewController tradeWizardReviewController;
private final EventHandler onKeyPressedHandler = this::onKeyPressed;
@@ -97,7 +97,7 @@ public TradeWizardController(ServiceProvider serviceProvider) {
tradeWizardMarketController = new TradeWizardMarketController(serviceProvider, this::onNext);
tradeWizardPriceController = new TradeWizardPriceController(serviceProvider, view.getRoot());
tradeWizardAmountController = new TradeWizardAmountController(serviceProvider, view.getRoot());
- tradeWizardFiatPaymentMethodController = new TradeWizardFiatPaymentMethodController(serviceProvider, view.getRoot(), this::onNext);
+ tradeWizardPaymentMethodsController = new TradeWizardPaymentMethodsController(serviceProvider, view.getRoot(), this::onNext);
tradeWizardSelectOfferController = new TradeWizardSelectOfferController(serviceProvider,
this::onBack,
this::onNext,
@@ -151,12 +151,12 @@ public void onActivate() {
tradeWizardMarketController.setDirection(direction);
tradeWizardSelectOfferController.setDirection(direction);
tradeWizardAmountController.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();
@@ -179,9 +179,9 @@ public void onActivate() {
isBackButtonHighlighted -> model.getIsBackButtonHighlighted().set(isBackButtonHighlighted));
handleFiatPaymentMethodsUpdate();
- tradeWizardFiatPaymentMethodController.getFiatPaymentMethods().addListener(fiatPaymentMethodsListener);
+ tradeWizardPaymentMethodsController.getFiatPaymentMethods().addListener(fiatPaymentMethodsListener);
handleBitcoinPaymentMethodsUpdate();
- tradeWizardFiatPaymentMethodController.getBitcoinPaymentMethods().addListener(bitcoinPaymentMethodsListener);
+ tradeWizardPaymentMethodsController.getBitcoinPaymentMethods().addListener(bitcoinPaymentMethodsListener);
}
@Override
@@ -195,8 +195,8 @@ public void onDeactivate() {
priceSpecPin.unsubscribe();
selectedBisqEasyOfferPin.unsubscribe();
isBackButtonHighlightedPin.unsubscribe();
- tradeWizardFiatPaymentMethodController.getFiatPaymentMethods().removeListener(fiatPaymentMethodsListener);
- tradeWizardFiatPaymentMethodController.getBitcoinPaymentMethods().removeListener(bitcoinPaymentMethodsListener);
+ tradeWizardPaymentMethodsController.getFiatPaymentMethods().removeListener(fiatPaymentMethodsListener);
+ tradeWizardPaymentMethodsController.getBitcoinPaymentMethods().removeListener(bitcoinPaymentMethodsListener);
}
@Override
@@ -206,8 +206,8 @@ protected void onStartProcessNavigationTarget(NavigationTarget navigationTarget,
tradeWizardReviewController.setDataForCreateOffer(
tradeWizardDirectionController.getDirection().get(),
tradeWizardMarketController.getMarket().get(),
- tradeWizardFiatPaymentMethodController.getBitcoinPaymentMethods(),
- tradeWizardFiatPaymentMethodController.getFiatPaymentMethods(),
+ tradeWizardPaymentMethodsController.getBitcoinPaymentMethods(),
+ tradeWizardPaymentMethodsController.getFiatPaymentMethods(),
tradeWizardAmountController.getQuoteSideAmountSpec().get(),
tradeWizardPriceController.getPriceSpec().get()
);
@@ -215,8 +215,8 @@ protected void onStartProcessNavigationTarget(NavigationTarget navigationTarget,
} else {
tradeWizardReviewController.setDataForTakeOffer(tradeWizardSelectOfferController.getSelectedBisqEasyOffer().get(),
tradeWizardAmountController.getQuoteSideAmountSpec().get(),
- tradeWizardFiatPaymentMethodController.getBitcoinPaymentMethods(),
- tradeWizardFiatPaymentMethodController.getFiatPaymentMethods()
+ tradeWizardPaymentMethodsController.getBitcoinPaymentMethods(),
+ tradeWizardPaymentMethodsController.getFiatPaymentMethods()
);
model.getNextButtonText().set(Res.get("bisqEasy.tradeWizard.review.nextButton.takeOffer"));
updateNextButtonDisabledState();
@@ -249,7 +249,7 @@ protected Optional extends Controller> createController(NavigationTarget navig
return Optional.of(tradeWizardPriceController);
}
case TRADE_WIZARD_FIAT_PAYMENT_METHOD: {
- return Optional.of(tradeWizardFiatPaymentMethodController);
+ return Optional.of(tradeWizardPaymentMethodsController);
}
case TRADE_WIZARD_AMOUNT: {
return Optional.of(tradeWizardAmountController);
@@ -328,7 +328,7 @@ private boolean validate(boolean calledFromNext) {
return tradeWizardAmountController.validate();
} else if (calledFromNext && model.getSelectedChildTarget().get() == NavigationTarget.TRADE_WIZARD_FIAT_PAYMENT_METHOD) {
// For PaymentMethod we tolerate to go back without having one selected
- return tradeWizardFiatPaymentMethodController.validate();
+ return tradeWizardPaymentMethodsController.validate();
}
return true;
}
@@ -355,7 +355,7 @@ private void reset() {
tradeWizardMarketController.reset();
tradeWizardPriceController.reset();
tradeWizardAmountController.reset();
- tradeWizardFiatPaymentMethodController.reset();
+ tradeWizardPaymentMethodsController.reset();
tradeWizardSelectOfferController.reset();
tradeWizardReviewController.reset();
@@ -384,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 = tradeWizardFiatPaymentMethodController.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/payment_methods/TradeWizardFiatPaymentMethodController.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsController.java
similarity index 96%
rename from apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodController.java
rename to apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsController.java
index 4c785927ba..c31392cd5a 100644
--- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodController.java
+++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsController.java
@@ -42,22 +42,22 @@
import java.util.stream.Stream;
@Slf4j
-public class TradeWizardFiatPaymentMethodController implements Controller {
- private final TradeWizardFiatPaymentMethodModel model;
+public class TradeWizardPaymentMethodsController implements Controller {
+ 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;
- 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() {
diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodModel.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsModel.java
similarity index 97%
rename from apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodModel.java
rename to apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsModel.java
index 8c59d692aa..1a9652ced7 100644
--- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodModel.java
+++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsModel.java
@@ -30,7 +30,7 @@
import lombok.Setter;
@Getter
-public class TradeWizardFiatPaymentMethodModel implements Model {
+public class TradeWizardPaymentMethodsModel implements Model {
@Setter
private Direction direction;
@Setter
diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodView.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsView.java
similarity index 97%
rename from apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodView.java
rename to apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsView.java
index 361195047b..08f0e58bbd 100644
--- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardFiatPaymentMethodView.java
+++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsView.java
@@ -41,7 +41,7 @@
import org.fxmisc.easybind.Subscription;
@Slf4j
-public class TradeWizardFiatPaymentMethodView extends View {
+public class TradeWizardPaymentMethodsView extends View {
private final MaterialTextField custom;
private final ListChangeListener fiatPaymentMethodListener;
private final ListChangeListener bitcoinPaymentMethodListener;
@@ -50,7 +50,7 @@ public class TradeWizardFiatPaymentMethodView extends View
Date: Fri, 19 Jul 2024 07:07:14 +0200
Subject: [PATCH 5/9] Update header title to payment methods
---
.../content/bisq_easy/trade_wizard/TradeWizardView.java | 6 +++---
i18n/src/main/resources/bisq_easy.properties | 3 +--
2 files changed, 4 insertions(+), 5 deletions(-)
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 3e6bdc0ca0..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,7 +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 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"));
@@ -230,7 +230,7 @@ private Triple> getProgressItems() {
getHLine(),
amount,
getHLine(),
- fiatPaymentMethod,
+ paymentMethods,
takeOfferProgressLine,
takeOfferProgressItem,
getHLine(),
@@ -238,7 +238,7 @@ private Triple> getProgressItems() {
Spacer.fillHBox(),
closeButton);
- return new Triple<>(hBox, closeButton, new ArrayList<>(List.of(direction, market, amount, fiatPaymentMethod, takeOfferProgressItem, review)));
+ return new Triple<>(hBox, closeButton, new ArrayList<>(List.of(direction, market, amount, paymentMethods, takeOfferProgressItem, review)));
}
private Region getHLine() {
diff --git a/i18n/src/main/resources/bisq_easy.properties b/i18n/src/main/resources/bisq_easy.properties
index 1954fd4d59..78d3751956 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
From 8c423073f72ea949b817b8dc4ac29d695d11f32d Mon Sep 17 00:00:00 2001
From: axpoems <145597137+axpoems@users.noreply.github.com>
Date: Fri, 19 Jul 2024 09:41:02 +0200
Subject: [PATCH 6/9] Add checkbox to allow LN payment method
---
.../TradeWizardPaymentMethodsController.java | 45 +++++++----
.../TradeWizardPaymentMethodsModel.java | 2 +-
.../TradeWizardPaymentMethodsView.java | 77 ++++---------------
i18n/src/main/resources/bisq_easy.properties | 10 +--
4 files changed, 49 insertions(+), 85 deletions(-)
diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsController.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsController.java
index c31392cd5a..f965688c68 100644
--- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsController.java
+++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsController.java
@@ -28,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;
@@ -43,13 +44,17 @@
@Slf4j
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 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 TradeWizardPaymentMethodsController(ServiceProvider serviceProvider, Region owner, Runnable onNextHandler) {
settingsService = serviceProvider.getSettingsService();
@@ -70,7 +75,7 @@ public ObservableList getBitcoinPaymentMethods() {
public boolean validate() {
if (getCustomFiatPaymentMethodNameNotEmpty()) {
- tryAddCustomPaymentMethodAndNavigateNext();
+ tryAddCustomFiatPaymentMethodAndNavigateNext();
return true;
}
if (model.getSelectedFiatPaymentMethods().isEmpty()) {
@@ -87,8 +92,8 @@ public boolean getCustomFiatPaymentMethodNameNotEmpty() {
return StringUtils.isNotEmpty(model.getCustomFiatPaymentMethodName().get());
}
- public void tryAddCustomPaymentMethodAndNavigateNext() {
- if (doAddCustomMethod()) {
+ public void tryAddCustomFiatPaymentMethodAndNavigateNext() {
+ if (doAddCustomFiatMethod()) {
onNextHandler.run();
}
}
@@ -117,9 +122,9 @@ 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));
@@ -127,7 +132,12 @@ public void onActivate() {
.map(BitcoinPaymentMethod::fromPaymentRail)
.collect(Collectors.toList());
model.getBitcoinPaymentMethods().setAll(paymentMethods);
- model.getSortedBitcoinPaymentMethods().setComparator(Comparator.comparingInt(o -> o.getPaymentRail().ordinal()));
+ 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 -> {
@@ -156,14 +166,18 @@ public void onActivate() {
});
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();
@@ -177,11 +191,11 @@ boolean onTogglePaymentMethod(FiatPaymentMethod fiatPaymentMethod, boolean isSel
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;
@@ -228,7 +242,7 @@ 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);
@@ -244,8 +258,7 @@ private String getCookieSubKey() {
return model.getMarket().get().getMarketCodes();
}
- // Bitcoin Payment Methods
- boolean onTogglePaymentMethod(BitcoinPaymentMethod bitcoinPaymentMethod, boolean isSelected) {
+ 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();
@@ -259,7 +272,7 @@ boolean onTogglePaymentMethod(BitcoinPaymentMethod bitcoinPaymentMethod, boolean
return true;
}
- void onRemoveCustomMethod(BitcoinPaymentMethod bitcoinPaymentMethod) {
+ private void onRemoveCustomBitcoinMethod(BitcoinPaymentMethod bitcoinPaymentMethod) {
model.getAddedCustomBitcoinPaymentMethods().remove(bitcoinPaymentMethod);
model.getSelectedBitcoinPaymentMethods().remove(bitcoinPaymentMethod);
model.getBitcoinPaymentMethods().remove(bitcoinPaymentMethod);
diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsModel.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsModel.java
index 1a9652ced7..de0605e0d8 100644
--- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsModel.java
+++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsModel.java
@@ -40,12 +40,12 @@ public class TradeWizardPaymentMethodsModel implements Model {
private final ObservableList selectedFiatPaymentMethods = FXCollections.observableArrayList();
private final ObservableList addedCustomFiatPaymentMethods = FXCollections.observableArrayList();
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();
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() {
diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsView.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsView.java
index 08f0e58bbd..0025424a42 100644
--- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsView.java
+++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/payment_methods/TradeWizardPaymentMethodsView.java
@@ -17,7 +17,6 @@
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.desktop.common.threading.UIThread;
import bisq.desktop.common.utils.ImageUtil;
@@ -31,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;
@@ -44,10 +45,10 @@
public class TradeWizardPaymentMethodsView extends View {
private final MaterialTextField custom;
private final ListChangeListener fiatPaymentMethodListener;
- private final ListChangeListener bitcoinPaymentMethodListener;
- private final FlowPane fiatMethodsFlowPane, bitcoinMethodsFlowPane;
+ private final FlowPane fiatMethodsFlowPane;
private final Label headlineLabel, nonFoundLabel;
private final BisqIconButton addButton;
+ private final CheckBox allowLNMethodSwitch;
private Subscription addCustomMethodIconEnabledPin;
public TradeWizardPaymentMethodsView(TradeWizardPaymentMethodsModel model, TradeWizardPaymentMethodsController controller) {
@@ -84,26 +85,22 @@ public TradeWizardPaymentMethodsView(TradeWizardPaymentMethodsModel model, Trade
addButton.setAlignment(Pos.CENTER);
custom.setMaxWidth(300);
- bitcoinMethodsFlowPane = new FlowPane();
- bitcoinMethodsFlowPane.setAlignment(Pos.CENTER);
- bitcoinMethodsFlowPane.setVgap(20);
- bitcoinMethodsFlowPane.setHgap(20);
+ 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(fiatMethodsFlowPane, new Insets(20, 60, 25, 60));
- VBox.setMargin(bitcoinMethodsFlowPane, new Insets(10, 60, 10, 60));
+ 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, bitcoinMethodsFlowPane, Spacer.fillVBox());
+ custom, allowLNHBox, Spacer.fillVBox());
fiatPaymentMethodListener = c -> {
c.next();
fillFiatPaymentMethods();
};
-
- bitcoinPaymentMethodListener = c -> {
- c.next();
- fillBitcoinPaymentMethods();
- };
}
@Override
@@ -115,6 +112,7 @@ protected void onViewAttached() {
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");
@@ -122,13 +120,11 @@ protected void onViewAttached() {
});
model.getFiatPaymentMethods().addListener(fiatPaymentMethodListener);
- model.getBitcoinPaymentMethods().addListener(bitcoinPaymentMethodListener);
- addButton.setOnAction(e -> controller.onAddCustomMethod());
+ addButton.setOnAction(e -> controller.onAddCustomFiatMethod());
root.setOnMousePressed(e -> root.requestFocus());
fillFiatPaymentMethods();
- fillBitcoinPaymentMethods();
}
@Override
@@ -139,21 +135,16 @@ protected void onViewDetached() {
fiatMethodsFlowPane.visibleProperty().unbind();
fiatMethodsFlowPane.managedProperty().unbind();
addButton.disableProperty().unbind();
+ allowLNMethodSwitch.selectedProperty().unbindBidirectional(model.getIsLNMethodAllowed());
fiatMethodsFlowPane.getChildren().stream()
.filter(e -> e instanceof ChipButton)
.map(e -> (ChipButton) e)
.forEach(chipToggleButton -> chipToggleButton.setOnAction(null));
- bitcoinMethodsFlowPane.getChildren().stream()
- .filter(e -> e instanceof ChipButton)
- .map(e -> (ChipButton) e)
- .forEach(chipToggleButton -> chipToggleButton.setOnAction(null));
-
addCustomMethodIconEnabledPin.unsubscribe();
model.getFiatPaymentMethods().removeListener(fiatPaymentMethodListener);
- model.getBitcoinPaymentMethods().removeListener(bitcoinPaymentMethodListener);
addButton.setOnAction(null);
root.setOnMousePressed(null);
@@ -171,7 +162,7 @@ private void fillFiatPaymentMethods() {
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));
}
@@ -182,7 +173,7 @@ private void fillFiatPaymentMethods() {
.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)
@@ -192,38 +183,4 @@ private void fillFiatPaymentMethods() {
fiatMethodsFlowPane.getChildren().add(chipButton);
}
}
-
- private void fillBitcoinPaymentMethods() {
- bitcoinMethodsFlowPane.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);
- });
- bitcoinMethodsFlowPane.getChildren().add(chipButton);
- }
- }
}
diff --git a/i18n/src/main/resources/bisq_easy.properties b/i18n/src/main/resources/bisq_easy.properties
index 78d3751956..903deb53e8 100644
--- a/i18n/src/main/resources/bisq_easy.properties
+++ b/i18n/src/main/resources/bisq_easy.properties
@@ -152,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}
@@ -177,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
################################################################################
From 2319ce8a35e32061637bc7b6f6a447926db532f3 Mon Sep 17 00:00:00 2001
From: axpoems <145597137+axpoems@users.noreply.github.com>
Date: Fri, 19 Jul 2024 09:56:37 +0200
Subject: [PATCH 7/9] Refactor: rename navigation target fiat payment method to
payment methods
---
.../bisq_easy/trade_wizard/TradeWizardController.java | 6 +++---
.../src/main/java/bisq/bisq_easy/NavigationTarget.java | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
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 c909b2b85f..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
@@ -136,7 +136,7 @@ public void onActivate() {
NavigationTarget.TRADE_WIZARD_DIRECTION,
NavigationTarget.TRADE_WIZARD_MARKET,
NavigationTarget.TRADE_WIZARD_AMOUNT,
- NavigationTarget.TRADE_WIZARD_FIAT_PAYMENT_METHOD,
+ NavigationTarget.TRADE_WIZARD_PAYMENT_METHODS,
NavigationTarget.TRADE_WIZARD_TAKE_OFFER_OFFER,
NavigationTarget.TRADE_WIZARD_REVIEW_OFFER
));
@@ -248,7 +248,7 @@ protected Optional extends Controller> createController(NavigationTarget navig
case TRADE_WIZARD_PRICE: {
return Optional.of(tradeWizardPriceController);
}
- case TRADE_WIZARD_FIAT_PAYMENT_METHOD: {
+ case TRADE_WIZARD_PAYMENT_METHODS: {
return Optional.of(tradeWizardPaymentMethodsController);
}
case TRADE_WIZARD_AMOUNT: {
@@ -326,7 +326,7 @@ 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_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 tradeWizardPaymentMethodsController.validate();
}
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 7cd7fec846..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,7 +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_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),
From fdb8ad5e14bc903c75e5f5c54b5b008b717cddef Mon Sep 17 00:00:00 2001
From: axpoems <145597137+axpoems@users.noreply.github.com>
Date: Fri, 19 Jul 2024 19:18:51 +0200
Subject: [PATCH 8/9] Fine tune reactions' style in my text messages
---
.../list/message_box/MyTextMessageBox.java | 1 +
.../list/message_box/PeerTextMessageBox.java | 1 +
.../desktop/desktop/src/main/resources/css/base.css | 5 +++++
.../desktop/desktop/src/main/resources/css/chat.css | 13 ++++++++++---
4 files changed, 17 insertions(+), 3 deletions(-)
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 extends ChatMessage, ? extends Cha
}
});
+ activeReactionsDisplayHBox.getStyleClass().add("my-text-message-box-active-reactions");
editInputField.maxWidthProperty().bind(message.widthProperty());
messageHBox.getChildren().setAll(Spacer.fillHBox(), activeReactionsDisplayHBox, messageBgHBox);
contentVBox.getChildren().setAll(userNameAndDateHBox, messageHBox, editButtonsHBox, actionsHBox);
diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/chat/message_container/list/message_box/PeerTextMessageBox.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/chat/message_container/list/message_box/PeerTextMessageBox.java
index bb03f76270..22d863d3c3 100644
--- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/chat/message_container/list/message_box/PeerTextMessageBox.java
+++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/chat/message_container/list/message_box/PeerTextMessageBox.java
@@ -47,6 +47,7 @@ public PeerTextMessageBox(ChatMessageListItem extends ChatMessage, ? extends C
setUpPeerMessage();
setMargin(userNameAndDateHBox, new Insets(-5, 0, -5, 10));
+ activeReactionsDisplayHBox.getStyleClass().add("peer-text-message-box-active-reactions");
messageHBox.getChildren().setAll(messageBgHBox, activeReactionsDisplayHBox, Spacer.fillHBox());
actionsHBox.getChildren().setAll(replyAction, openPrivateChatAction, copyAction, reactMenuBox, moreActionsMenu, Spacer.fillHBox());
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..7a0160a127 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;
+}
\ No newline at end of file
From 45b466ec3eb203317ade6c3f4cf284f3f11724be Mon Sep 17 00:00:00 2001
From: axpoems <145597137+axpoems@users.noreply.github.com>
Date: Fri, 19 Jul 2024 19:43:30 +0200
Subject: [PATCH 9/9] Tone-down reaction icons
---
.../bisq/desktop/components/controls/BisqMenuItem.java | 7 +++++++
.../list/reactions_box/ActiveReactionsDisplayBox.java | 5 +++++
.../message_container/list/reactions_box/ReactMenuBox.java | 5 +++++
apps/desktop/desktop/src/main/resources/css/chat.css | 2 +-
4 files changed, 18 insertions(+), 1 deletion(-)
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/chat/message_container/list/reactions_box/ActiveReactionsDisplayBox.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/chat/message_container/list/reactions_box/ActiveReactionsDisplayBox.java
index b0c7a3f4ed..c8d2cbdb9c 100644
--- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/chat/message_container/list/reactions_box/ActiveReactionsDisplayBox.java
+++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/chat/message_container/list/reactions_box/ActiveReactionsDisplayBox.java
@@ -26,6 +26,7 @@
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.collections.transformation.SortedList;
+import javafx.scene.effect.ColorAdjust;
import javafx.scene.layout.HBox;
import lombok.Getter;
@@ -115,6 +116,10 @@ private ActiveReactionMenuItem(ReactionItem reactionItem, ToggleReaction toggleR
setGraphicTextGap(4);
addStyleClasses();
setOnAction(e -> 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/chat.css b/apps/desktop/desktop/src/main/resources/css/chat.css
index 7a0160a127..15b5f9af2f 100644
--- a/apps/desktop/desktop/src/main/resources/css/chat.css
+++ b/apps/desktop/desktop/src/main/resources/css/chat.css
@@ -578,4 +578,4 @@
.peer-text-message-box-active-reactions .button.bisq-menu-item.active-reaction-menu-item {
-fx-background-color: -bisq2-peer-bubble-message;
-}
\ No newline at end of file
+}