use logo for fiat currencies

This commit is contained in:
woodser 2025-07-05 11:58:08 -04:00 committed by woodser
parent 61122493b5
commit 55032f94e7
5 changed files with 28 additions and 11 deletions

View file

@ -313,6 +313,10 @@
-fx-image: url("../../images/settings.png"); -fx-image: url("../../images/settings.png");
} }
#image-fiat-logo {
-fx-image: url("../../images/fiat_logo_light_mode.png");
}
#image-btc-logo { #image-btc-logo {
-fx-image: url("../../images/btc_logo.png"); -fx-image: url("../../images/btc_logo.png");
} }

View file

@ -643,3 +643,7 @@
.regular-text-color { .regular-text-color {
-fx-text-fill: -bs-text-color; -fx-text-fill: -bs-text-color;
} }
#image-fiat-logo {
-fx-image: url("../../images/fiat_logo_dark_mode.png");
}

View file

@ -349,10 +349,11 @@ public class GUIUtil {
break; break;
default: default:
// use icons for crypto // use icon if available
if (CurrencyUtil.isCryptoCurrency(code)) { ImageView currencyIcon = getCurrencyIcon(code);
if (currencyIcon != null) {
label1.setText(""); label1.setText("");
StackPane iconWrapper = new StackPane(getCurrencyIcon(code)); // TODO: icon must be wrapped in StackPane for reliable rendering on linux StackPane iconWrapper = new StackPane(currencyIcon); // TODO: icon must be wrapped in StackPane for reliable rendering on linux
label1.setGraphic(iconWrapper); label1.setGraphic(iconWrapper);
} }
@ -459,10 +460,12 @@ public class GUIUtil {
break; break;
default: default:
// use icons for crypto // use icon if available
if (CurrencyUtil.isCryptoCurrency(item.getCode())) { ImageView currencyIcon = getCurrencyIcon(code);
if (currencyIcon != null) {
label1.setText(""); label1.setText("");
label1.setGraphic(getCurrencyIcon(item.getCode())); StackPane iconWrapper = new StackPane(currencyIcon); // TODO: icon must be wrapped in StackPane for reliable rendering on linux
label1.setGraphic(iconWrapper);
} }
boolean isCrypto = CurrencyUtil.isCryptoCurrency(code); boolean isCrypto = CurrencyUtil.isCryptoCurrency(code);
@ -502,10 +505,12 @@ public class GUIUtil {
Label label2 = new AutoTooltipLabel(item.getNameAndCode()); Label label2 = new AutoTooltipLabel(item.getNameAndCode());
label2.getStyleClass().add("currency-label"); label2.getStyleClass().add("currency-label");
// use icons for crypto // use icon if available
if (CurrencyUtil.isCryptoCurrency(item.getCode())) { ImageView currencyIcon = getCurrencyIcon(item.getCode());
if (currencyIcon != null) {
label1.setText(""); label1.setText("");
label1.setGraphic(getCurrencyIcon(item.getCode())); StackPane iconWrapper = new StackPane(currencyIcon); // TODO: icon must be wrapped in StackPane for reliable rendering on linux
label1.setGraphic(iconWrapper);
} }
box.getChildren().addAll(label1, label2); box.getChildren().addAll(label1, label2);
@ -1284,12 +1289,14 @@ public class GUIUtil {
public static ImageView getCurrencyIcon(String currencyCode, double size) { public static ImageView getCurrencyIcon(String currencyCode, double size) {
if (currencyCode == null) return null; if (currencyCode == null) return null;
String imageId = getImageId(currencyCode);
if (imageId == null) return null;
ImageView iconView = new ImageView(); ImageView iconView = new ImageView();
iconView.setFitWidth(size); iconView.setFitWidth(size);
iconView.setPreserveRatio(true); iconView.setPreserveRatio(true);
iconView.setSmooth(true); iconView.setSmooth(true);
iconView.setCache(true); iconView.setCache(true);
iconView.setId(getImageId(currencyCode)); iconView.setId(imageId);
return iconView; return iconView;
} }
@ -1327,7 +1334,9 @@ public class GUIUtil {
private static String getImageId(String currencyCode) { private static String getImageId(String currencyCode) {
if (currencyCode == null) return null; if (currencyCode == null) return null;
return "image-" + currencyCode.toLowerCase() + "-logo"; if (CurrencyUtil.isCryptoCurrency(currencyCode)) return "image-" + currencyCode.toLowerCase() + "-logo";
if (CurrencyUtil.isFiatCurrency(currencyCode)) return "image-fiat-logo";
return null;
} }
public static void adjustHeightAutomatically(TextArea textArea) { public static void adjustHeightAutomatically(TextArea textArea) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB