Merge pull request #7338 from alvasw/show_ars_popup_when_selecting_currency

Show ARS Blue Rate popup during payment account creation
This commit is contained in:
Alejandro García 2025-01-15 20:21:30 +00:00 committed by GitHub
commit 550cc09a13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 51 additions and 19 deletions

View file

@ -37,6 +37,7 @@ import bisq.core.offer.OfferDirection;
import bisq.core.payment.AssetAccount;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.user.DontShowAgainLookup;
import bisq.core.util.coin.CoinFormatter;
import bisq.core.util.validation.InputValidator;
@ -67,6 +68,7 @@ import javafx.collections.FXCollections;
import javafx.util.StringConverter;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import lombok.extern.slf4j.Slf4j;
@ -118,8 +120,13 @@ public abstract class PaymentMethodForm {
}
});
currencyComboBox.setOnAction(e -> {
paymentAccount.setSingleTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem());
TradeCurrency selectedCurrency = currencyComboBox.getSelectionModel().getSelectedItem();
paymentAccount.setSingleTradeCurrency(selectedCurrency);
updateFromInputs();
if (isArgentinePesos(selectedCurrency)) {
maybeShowArgentinePesosBlueRatePopup();
}
});
}
@ -299,19 +306,32 @@ public abstract class PaymentMethodForm {
TradeCurrency e, PaymentAccount paymentAccount) {
CheckBox checkBox = new AutoTooltipCheckBox(e.getCode());
checkBox.setMouseTransparent(!isEditable);
checkBox.setSelected(paymentAccount.getTradeCurrencies().contains(e));
boolean isCurrencySelected = paymentAccount.getTradeCurrencies().contains(e);
checkBox.setSelected(isCurrencySelected);
checkBox.setMinWidth(60);
checkBox.setMaxWidth(checkBox.getMinWidth());
checkBox.setTooltip(new Tooltip(e.getName()));
checkBox.setOnAction(event -> {
if (checkBox.isSelected())
if (checkBox.isSelected()) {
paymentAccount.addCurrency(e);
else
if (isArgentinePesos(e)) {
maybeShowArgentinePesosBlueRatePopup();
}
} else {
paymentAccount.removeCurrency(e);
}
updateAllInputsValid();
});
flowPane.getChildren().add(checkBox);
if (isCurrencySelected && isArgentinePesos(e)) {
maybeShowArgentinePesosBlueRatePopup();
}
}
protected abstract void autoFillNameTextField();
@ -352,4 +372,22 @@ public abstract class PaymentMethodForm {
void addAcceptedCountry(String countryCode) {
}
public static boolean isArgentinePesos(TradeCurrency tradeCurrency) {
FiatCurrency arsCurrency = new FiatCurrency("ARS");
return tradeCurrency.equals(arsCurrency);
}
public static void maybeShowArgentinePesosBlueRatePopup() {
String key = "arsBlueMarketNotificationPopup";
if (DontShowAgainLookup.showAgain(key)) {
new Popup()
.headLine(Res.get("popup.arsBlueMarket.title"))
.information(Res.get("popup.arsBlueMarket.info"))
.actionButtonText(Res.get("shared.iUnderstand"))
.hideCloseButton()
.dontShowAgainId(key)
.show();
}
}
}

View file

@ -126,19 +126,6 @@ class FiatAccountsDataModel extends ActivatableDataModel {
accountAgeWitnessService.publishMyAccountAgeWitness(paymentAccount.getPaymentAccountPayload());
accountAgeWitnessService.signAndPublishSameNameAccounts();
if (paymentAccount.getSingleTradeCurrency().getCode().equals("ARS")) {
String key = "arsBlueMarketNotificationPopup";
if (DontShowAgainLookup.showAgain(key)) {
new Popup()
.headLine(Res.get("popup.arsBlueMarket.title"))
.information(Res.get("popup.arsBlueMarket.info"))
.actionButtonText(Res.get("shared.iUnderstand"))
.hideCloseButton()
.dontShowAgainId(key)
.show();
}
}
}
public void onUpdateAccount(PaymentAccount paymentAccount) {

View file

@ -24,6 +24,7 @@ import bisq.desktop.components.BisqScrollPane;
import bisq.desktop.components.BisqTextArea;
import bisq.desktop.components.InfoAutoTooltipLabel;
import bisq.desktop.components.indicator.TxConfidenceIndicator;
import bisq.desktop.components.paymentmethods.PaymentMethodForm;
import bisq.desktop.main.MainView;
import bisq.desktop.main.account.AccountView;
import bisq.desktop.main.account.content.fiataccounts.FiatAccountsView;
@ -1103,8 +1104,14 @@ public class GUIUtil {
});
currencyComboBox.setDisable(true);
currencyComboBox.setOnAction(e ->
onTradeCurrencySelectedHandler.accept(currencyComboBox.getSelectionModel().getSelectedItem()));
currencyComboBox.setOnAction(e -> {
TradeCurrency selectedCurrency = currencyComboBox.getSelectionModel().getSelectedItem();
onTradeCurrencySelectedHandler.accept(selectedCurrency);
if (PaymentMethodForm.isArgentinePesos(selectedCurrency)) {
PaymentMethodForm.maybeShowArgentinePesosBlueRatePopup();
}
});
return new Tuple2<>(currencyComboBox, gridRow);
}