show crypto logos in account pulldown and change naming

This commit is contained in:
woodser 2025-06-04 16:03:37 -04:00
parent 62012af94d
commit 8de527d88e
No known key found for this signature in database
GPG key ID: 55A10DD48ADEE5EF
2 changed files with 60 additions and 13 deletions

View file

@ -36,6 +36,7 @@ import haveno.desktop.components.AutocompleteComboBox;
import haveno.desktop.components.InputTextField; import haveno.desktop.components.InputTextField;
import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.main.overlays.popups.Popup;
import haveno.desktop.util.FormBuilder; import haveno.desktop.util.FormBuilder;
import haveno.desktop.util.GUIUtil;
import haveno.desktop.util.Layout; import haveno.desktop.util.Layout;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.scene.control.CheckBox; import javafx.scene.control.CheckBox;
@ -202,6 +203,8 @@ public class AssetsForm extends PaymentMethodForm {
CurrencyUtil.getActiveSortedCryptoCurrencies(filterManager)); CurrencyUtil.getActiveSortedCryptoCurrencies(filterManager));
currencyComboBox.setVisibleRowCount(Math.min(currencyComboBox.getItems().size(), 10)); currencyComboBox.setVisibleRowCount(Math.min(currencyComboBox.getItems().size(), 10));
currencyComboBox.setCellFactory(GUIUtil.getTradeCurrencyCellFactoryNameAndCode());
currencyComboBox.setConverter(new StringConverter<>() { currencyComboBox.setConverter(new StringConverter<>() {
@Override @Override
public String toString(TradeCurrency tradeCurrency) { public String toString(TradeCurrency tradeCurrency) {

View file

@ -325,13 +325,11 @@ public class GUIUtil {
HBox box = new HBox(); HBox box = new HBox();
box.setSpacing(20); box.setSpacing(20);
box.setAlignment(Pos.CENTER_LEFT); box.setAlignment(Pos.CENTER_LEFT);
Label currencyType = new AutoTooltipLabel( Label currencyType = new AutoTooltipLabel(getCurrencyType(code));
CurrencyUtil.isTraditionalCurrency(code) ? Res.get("shared.traditional") : Res.get("shared.crypto"));
currencyType.getStyleClass().add("currency-label-small"); currencyType.getStyleClass().add("currency-label-small");
Label currency = new AutoTooltipLabel(code); Label currency = new AutoTooltipLabel(CurrencyUtil.isCryptoCurrency(code) ? item.tradeCurrency.getNameAndCode() : code);
currency.getStyleClass().add("currency-label"); currency.getStyleClass().add("currency-label");
Label offers = new AutoTooltipLabel(item.tradeCurrency.getName()); Label offers = new AutoTooltipLabel(CurrencyUtil.isCryptoCurrency(code) ? "" : item.tradeCurrency.getName());
offers.getStyleClass().add("currency-label"); offers.getStyleClass().add("currency-label");
box.getChildren().addAll(currencyType, currency, offers); box.getChildren().addAll(currencyType, currency, offers);
@ -355,7 +353,7 @@ public class GUIUtil {
} }
if (preferences.isSortMarketCurrenciesNumerically()) { if (preferences.isSortMarketCurrenciesNumerically()) {
offers.setText(offers.getText() + " (" + item.numTrades + " " + offers.setText((!offers.getText().isEmpty() ? offers.getText() + " " : "") + "(" + item.numTrades + " " +
(item.numTrades == 1 ? postFixSingle : postFixMulti) + ")"); (item.numTrades == 1 ? postFixSingle : postFixMulti) + ")");
} }
} }
@ -460,12 +458,11 @@ public class GUIUtil {
HBox box = new HBox(); HBox box = new HBox();
box.setSpacing(20); box.setSpacing(20);
Label label = new AutoTooltipLabel( Label label = new AutoTooltipLabel(getCurrencyType(item.getCode()));
CurrencyUtil.isTraditionalCurrency(item.getCode()) ? Res.get("shared.traditional") : Res.get("shared.crypto"));
label.getStyleClass().add("currency-label-small"); label.getStyleClass().add("currency-label-small");
Label currency = new AutoTooltipLabel(item.getCode()); Label currency = new AutoTooltipLabel(CurrencyUtil.isCryptoCurrency(code) ? item.getNameAndCode() : code);
currency.getStyleClass().add("currency-label"); currency.getStyleClass().add("currency-label");
Label offers = new AutoTooltipLabel(item.getName()); Label offers = new AutoTooltipLabel(CurrencyUtil.isCryptoCurrency(code) ? "" : item.getName());
offers.getStyleClass().add("currency-label"); offers.getStyleClass().add("currency-label");
Optional<Integer> offerCountOptional = Optional.ofNullable(offerCounts.get(code)); Optional<Integer> offerCountOptional = Optional.ofNullable(offerCounts.get(code));
@ -501,6 +498,55 @@ public class GUIUtil {
}; };
} }
public static Callback<ListView<TradeCurrency>, ListCell<TradeCurrency>> getTradeCurrencyCellFactoryNameAndCode() {
return p -> new ListCell<>() {
@Override
protected void updateItem(TradeCurrency item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
HBox box = new HBox();
box.setSpacing(10);
Label label = new AutoTooltipLabel(getCurrencyType(item.getCode()));
label.getStyleClass().add("currency-label-small");
Label currency = new AutoTooltipLabel(item.getNameAndCode());
currency.getStyleClass().add("currency-label");
// use icons for crypto
if (CurrencyUtil.isCryptoCurrency(item.getCode())) {
label.setText("");
label.setGraphic(getCurrencyIcon(item.getCode()));
}
box.getChildren().addAll(label, currency);
setGraphic(box);
} else {
setGraphic(null);
}
}
};
}
private static String getCurrencyType(String code) {
if (CurrencyUtil.isFiatCurrency(code)) {
return Res.get("shared.fiat");
} else if (CurrencyUtil.isTraditionalCurrency(code)) {
return Res.get("shared.traditional");
} else if (CurrencyUtil.isCryptoCurrency(code)) {
return Res.get("shared.crypto");
} else {
return "";
}
}
private static String getCurrencyType(PaymentMethod method) {
return method.isTraditional() ? Res.get("shared.traditional") : Res.get("shared.crypto");
}
public static ListCell<PaymentMethod> getPaymentMethodButtonCell() { public static ListCell<PaymentMethod> getPaymentMethodButtonCell() {
return new ListCell<>() { return new ListCell<>() {
@ -536,9 +582,7 @@ public class GUIUtil {
HBox box = new HBox(); HBox box = new HBox();
box.setSpacing(20); box.setSpacing(20);
Label paymentType = new AutoTooltipLabel( Label paymentType = new AutoTooltipLabel(getCurrencyType(method));
method.isTraditional() ? Res.get("shared.traditional") : Res.get("shared.crypto"));
paymentType.getStyleClass().add("currency-label-small"); paymentType.getStyleClass().add("currency-label-small");
Label paymentMethod = new AutoTooltipLabel(Res.get(id)); Label paymentMethod = new AutoTooltipLabel(Res.get(id));
paymentMethod.getStyleClass().add("currency-label"); paymentMethod.getStyleClass().add("currency-label");