Skip to content

Commit

Permalink
Merge pull request #7341 from alvasw/show_ars_popup_when_selecting_cu…
Browse files Browse the repository at this point in the history
…rrency_in_app

Show ARS blue rate popup when selecting currency in app
  • Loading branch information
alejandrogarcia83 authored Jan 15, 2025
2 parents ad9c216 + 4bb7b38 commit 0d25afd
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import bisq.core.locale.FiatCurrency;
import bisq.core.locale.Res;
import bisq.core.locale.TradeCurrency;
import bisq.core.user.DontShowAgainLookup;

public class ArsBlueRatePopup {
public static boolean isTradeCurrencyArgentinePesos(TradeCurrency tradeCurrency) {
Expand All @@ -13,11 +14,22 @@ public static boolean isTradeCurrencyArgentinePesos(TradeCurrency tradeCurrency)
}

public static void show() {
new Popup()
createPopup().show();
}

public static void showMaybe() {
String key = "arsBlueMarketNotificationPopup";
if (DontShowAgainLookup.showAgain(key)) {
createPopup().dontShowAgainId(key)
.show();
}
}

private static Popup createPopup() {
return new Popup()
.headLine(Res.get("popup.arsBlueMarket.title"))
.information(Res.get("popup.arsBlueMarket.info"))
.actionButtonText(Res.get("shared.iUnderstand"))
.hideCloseButton()
.show();
.hideCloseButton();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
import bisq.desktop.components.AutocompleteComboBox;
import bisq.desktop.components.ColoredDecimalPlacesWithZerosText;
import bisq.desktop.components.PeerInfoIconSmall;
import bisq.desktop.components.paymentmethods.ArsBlueRatePopup;
import bisq.desktop.main.offer.offerbook.OfferBookListItem;
import bisq.desktop.util.CurrencyListItem;
import bisq.desktop.util.DisplayUtils;
import bisq.desktop.util.GUIUtil;

import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res;
import bisq.core.locale.TradeCurrency;
import bisq.core.offer.Offer;
import bisq.core.offer.OfferDirection;
import bisq.core.util.FormattingUtils;
Expand Down Expand Up @@ -203,8 +205,13 @@ protected void activate() {
currencyComboBox.setOnChangeConfirmed(e -> {
CurrencyListItem selectedItem = currencyComboBox.getSelectionModel().getSelectedItem();
if (selectedItem != null) {
model.onSetTradeCurrency(selectedItem.tradeCurrency);
TradeCurrency selectedCurrency = selectedItem.tradeCurrency;
model.onSetTradeCurrency(selectedCurrency);
updateChartData();

if (ArsBlueRatePopup.isTradeCurrencyArgentinePesos(selectedCurrency)) {
ArsBlueRatePopup.showMaybe();
}
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import bisq.desktop.components.AutoTooltipToggleButton;
import bisq.desktop.components.AutocompleteComboBox;
import bisq.desktop.components.ColoredDecimalPlacesWithZerosText;
import bisq.desktop.components.paymentmethods.ArsBlueRatePopup;
import bisq.desktop.main.market.trades.charts.price.CandleStickChart;
import bisq.desktop.main.market.trades.charts.volume.VolumeChart;
import bisq.desktop.util.CurrencyListItem;
Expand All @@ -33,6 +34,7 @@

import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res;
import bisq.core.locale.TradeCurrency;
import bisq.core.monetary.Price;
import bisq.core.trade.statistics.TradeStatistics3;
import bisq.core.user.CookieKey;
Expand Down Expand Up @@ -309,7 +311,12 @@ else if (model.getSelectedCurrencyListItem().isPresent())
currencyComboBox.getSelectionModel().select(SHOW_ALL);
CurrencyListItem selectedItem = currencyComboBox.getSelectionModel().getSelectedItem();
if (selectedItem != null) {
model.onSetTradeCurrency(selectedItem.tradeCurrency);
TradeCurrency selectedCurrency = selectedItem.tradeCurrency;
model.onSetTradeCurrency(selectedCurrency);

if (ArsBlueRatePopup.isTradeCurrencyArgentinePesos(selectedCurrency)) {
ArsBlueRatePopup.showMaybe();
}
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import bisq.desktop.components.PeerInfoIconMap;
import bisq.desktop.components.PeerInfoIconTrading;
import bisq.desktop.components.TitledGroupBg;
import bisq.desktop.components.paymentmethods.ArsBlueRatePopup;
import bisq.desktop.main.MainView;
import bisq.desktop.main.account.AccountView;
import bisq.desktop.main.account.content.altcoinaccounts.AltCoinAccountsView;
Expand Down Expand Up @@ -363,12 +364,17 @@ protected void activate() {
currencyComboBox.setOnChangeConfirmed(e -> {
if (currencyComboBox.getEditor().getText().isEmpty())
currencyComboBox.getSelectionModel().select(SHOW_ALL);
model.onSetTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem());
TradeCurrency selectedCurrency = currencyComboBox.getSelectionModel().getSelectedItem();
model.onSetTradeCurrency(selectedCurrency);
paymentMethodComboBox.setAutocompleteItems(model.getPaymentMethods());
model.updateSelectedPaymentMethod();
updatePaymentMethodComboBoxEditor();
model.onSetPaymentMethod(paymentMethodComboBox.getSelectionModel().getSelectedItem());
updateCreateOfferButton();

if (ArsBlueRatePopup.isTradeCurrencyArgentinePesos(selectedCurrency)) {
ArsBlueRatePopup.showMaybe();
}
});
updateCurrencyComboBoxFromModel();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import bisq.desktop.components.InputTextField;
import bisq.desktop.components.PasswordTextField;
import bisq.desktop.components.TitledGroupBg;
import bisq.desktop.components.paymentmethods.ArsBlueRatePopup;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.overlays.windows.EditCustomExplorerWindow;
import bisq.desktop.util.GUIUtil;
Expand Down Expand Up @@ -1029,8 +1030,13 @@ private void activateDisplayCurrencies() {
preferredTradeCurrencyComboBox.setVisibleRowCount(12);
preferredTradeCurrencyComboBox.setOnAction(e -> {
TradeCurrency selectedItem = preferredTradeCurrencyComboBox.getSelectionModel().getSelectedItem();
if (selectedItem != null)
if (selectedItem != null) {
preferences.setPreferredTradeCurrency(selectedItem);

if (ArsBlueRatePopup.isTradeCurrencyArgentinePesos(selectedItem)) {
ArsBlueRatePopup.showMaybe();
}
}
GUIUtil.updateTopAltcoin(preferences);
});

Expand Down

0 comments on commit 0d25afd

Please sign in to comment.