add inverted icons for dark theme

This commit is contained in:
Craig Raw
2022-11-14 12:45:13 +02:00
parent 5be5363f25
commit a05fcba6d9
32 changed files with 27 additions and 9 deletions
@@ -2186,6 +2186,14 @@ public class AppController implements Initializable {
} else {
tabs.getScene().getStylesheets().remove(darkCss);
}
for(Tab tab : tabs.getTabs()) {
if(tab.getUserData() instanceof WalletTabData) {
Label tabLabel = (Label)tab.getGraphic();
WalletIcon walletIcon = (WalletIcon)tabLabel.getGraphic();
walletIcon.refresh();
}
}
}
@Subscribe
@@ -2,7 +2,9 @@ package com.sparrowwallet.sparrow.control;
import com.sparrowwallet.drongo.wallet.*;
import com.sparrowwallet.sparrow.AppServices;
import com.sparrowwallet.sparrow.Theme;
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
import com.sparrowwallet.sparrow.io.Config;
import com.sparrowwallet.sparrow.io.ImageUtils;
import com.sparrowwallet.sparrow.io.Storage;
import javafx.application.Platform;
@@ -60,18 +62,16 @@ public class WalletIcon extends StackPane {
WalletModel walletModel = keystore.getWalletModel();
Image image = null;
try {
image = new Image("image/" + walletModel.getType() + "-icon.png", 15, 15, true, true);
} catch(Exception e) {
//ignore
if(Config.get().getTheme() == Theme.DARK) {
image = loadImage("image/" + walletModel.getType() + "-icon-invert.png");
}
if(image == null) {
try {
image = new Image("image/" + walletModel.getType() + ".png", 15, 15, true, true);
} catch(Exception e) {
//ignore
}
image = loadImage("image/" + walletModel.getType() + "-icon.png");
}
if(image == null) {
image = loadImage("image/" + walletModel.getType() + ".png");
}
if(image != null && !image.isError()) {
@@ -88,6 +88,16 @@ public class WalletIcon extends StackPane {
}
}
private Image loadImage(String imageName) {
try {
return new Image(imageName, 15, 15, true, true);
} catch(Exception e) {
//ignore
}
return null;
}
private void addWalletIcon(String walletId) {
Image image = new Image(PROTOCOL + ":" + walletId + "?" + QUERY, WIDTH, HEIGHT, true, false);
getChildren().clear();