diff --git a/build.gradle b/build.gradle index 54699f62..a2458e81 100644 --- a/build.gradle +++ b/build.gradle @@ -111,6 +111,7 @@ dependencies { implementation('com.github.librepdf:openpdf:1.3.27') implementation('com.googlecode.lanterna:lanterna:3.1.1') implementation('net.coobird:thumbnailator:0.4.18') + implementation('com.github.hervegirod:fxsvgimage:1.0b2') testImplementation('junit:junit:4.12') } @@ -584,6 +585,11 @@ extraJavaModuleInfo { exports('net.coobird.thumbnailator') requires('java.desktop') } + module('fxsvgimage-1.0b2.jar', 'com.github.hervegirod', '1.0b2') { + exports('org.girod.javafx.svgimage') + requires('javafx.graphics') + requires('java.xml') + } module("netlayer-jpms-${osName}${targetName}-0.6.8.jar", 'netlayer.jpms', '0.6.8') { exports('org.berndpruenster.netlayer.tor') requires('com.github.ravn.jsocks') diff --git a/src/main/java/com/sparrowwallet/sparrow/control/WalletIcon.java b/src/main/java/com/sparrowwallet/sparrow/control/WalletIcon.java index 28927007..0a5f2c29 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/WalletIcon.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/WalletIcon.java @@ -17,6 +17,8 @@ import javafx.scene.layout.StackPane; import javafx.scene.paint.ImagePattern; import javafx.scene.shape.Circle; import org.controlsfx.glyphfont.Glyph; +import org.girod.javafx.svgimage.SVGImage; +import org.girod.javafx.svgimage.SVGLoader; import java.io.*; import java.net.MalformedURLException; @@ -61,6 +63,18 @@ public class WalletIcon extends StackPane { if(keystore.getSource() == KeystoreSource.HW_USB || keystore.getSource() == KeystoreSource.HW_AIRGAPPED) { WalletModel walletModel = keystore.getWalletModel(); + SVGImage svgImage; + if(Config.get().getTheme() == Theme.DARK) { + svgImage = loadSVGImage("/image/" + walletModel.getType() + "-icon-invert.svg"); + } else { + svgImage = loadSVGImage("/image/" + walletModel.getType() + "-icon.svg"); + } + + if(svgImage != null) { + getChildren().add(svgImage); + return; + } + Image image = null; if(Config.get().getTheme() == Theme.DARK) { image = loadImage("image/" + walletModel.getType() + "-icon-invert.png"); @@ -88,6 +102,19 @@ public class WalletIcon extends StackPane { } } + private SVGImage loadSVGImage(String imageName) { + try { + URL url = AppServices.class.getResource(imageName); + if(url != null) { + return SVGLoader.load(url); + } + } catch(Exception e) { + //ignore + } + + return null; + } + private Image loadImage(String imageName) { try { return new Image(imageName, 15, 15, true, true); diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index e7e53e55..0d32b3cc 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -47,4 +47,5 @@ open module com.sparrowwallet.sparrow { requires com.github.librepdf.openpdf; requires com.googlecode.lanterna; requires net.coobird.thumbnailator; + requires com.github.hervegirod; } \ No newline at end of file diff --git a/src/main/resources/image/bitbox02-icon-invert.svg b/src/main/resources/image/bitbox02-icon-invert.svg new file mode 100644 index 00000000..dfd4e864 --- /dev/null +++ b/src/main/resources/image/bitbox02-icon-invert.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/main/resources/image/bitbox02-icon.svg b/src/main/resources/image/bitbox02-icon.svg new file mode 100644 index 00000000..23bd255a --- /dev/null +++ b/src/main/resources/image/bitbox02-icon.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/main/resources/image/coldcard-icon-invert.svg b/src/main/resources/image/coldcard-icon-invert.svg new file mode 100644 index 00000000..247533ee --- /dev/null +++ b/src/main/resources/image/coldcard-icon-invert.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/src/main/resources/image/coldcard-icon.svg b/src/main/resources/image/coldcard-icon.svg new file mode 100644 index 00000000..fedc3eb8 --- /dev/null +++ b/src/main/resources/image/coldcard-icon.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/src/main/resources/image/jade-icon-invert.svg b/src/main/resources/image/jade-icon-invert.svg new file mode 100644 index 00000000..83039722 --- /dev/null +++ b/src/main/resources/image/jade-icon-invert.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/main/resources/image/jade-icon.svg b/src/main/resources/image/jade-icon.svg new file mode 100644 index 00000000..e841d6ff --- /dev/null +++ b/src/main/resources/image/jade-icon.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/main/resources/image/keystone-icon-invert.svg b/src/main/resources/image/keystone-icon-invert.svg new file mode 100644 index 00000000..f190d4aa --- /dev/null +++ b/src/main/resources/image/keystone-icon-invert.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/main/resources/image/keystone-icon.svg b/src/main/resources/image/keystone-icon.svg new file mode 100644 index 00000000..419c9abf --- /dev/null +++ b/src/main/resources/image/keystone-icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/main/resources/image/ledger-icon-invert.svg b/src/main/resources/image/ledger-icon-invert.svg new file mode 100644 index 00000000..15e904af --- /dev/null +++ b/src/main/resources/image/ledger-icon-invert.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/main/resources/image/ledger-icon.svg b/src/main/resources/image/ledger-icon.svg new file mode 100644 index 00000000..a3cb9eab --- /dev/null +++ b/src/main/resources/image/ledger-icon.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/main/resources/image/passport-icon-invert.svg b/src/main/resources/image/passport-icon-invert.svg new file mode 100644 index 00000000..21f4a947 --- /dev/null +++ b/src/main/resources/image/passport-icon-invert.svg @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/image/passport-icon.svg b/src/main/resources/image/passport-icon.svg new file mode 100644 index 00000000..cc7b6428 --- /dev/null +++ b/src/main/resources/image/passport-icon.svg @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/image/trezor-icon-invert.svg b/src/main/resources/image/trezor-icon-invert.svg new file mode 100644 index 00000000..31b76b6a --- /dev/null +++ b/src/main/resources/image/trezor-icon-invert.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/main/resources/image/trezor-icon.svg b/src/main/resources/image/trezor-icon.svg new file mode 100644 index 00000000..ec46c847 --- /dev/null +++ b/src/main/resources/image/trezor-icon.svg @@ -0,0 +1,6 @@ + + + + + +