aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-10-19 16:18:10 +0200
committerLibravatar Stefan Malzner <stefan@adlk.io>2017-10-19 16:27:21 +0200
commit55805f1d8fba4d1e96dba3ef02ec56c5de349778 (patch)
tree0e391af956c2b20f5728f82d595380286902f205
parentReset travis env vars (diff)
downloadferdium-app-55805f1d8fba4d1e96dba3ef02ec56c5de349778.tar.gz
ferdium-app-55805f1d8fba4d1e96dba3ef02ec56c5de349778.tar.zst
ferdium-app-55805f1d8fba4d1e96dba3ef02ec56c5de349778.zip
fix(System tray): Add macOS dark theme system tray icon
Fixes #1
-rw-r--r--src/assets/images/tray/darwin-dark/tray-active.pngbin0 -> 396 bytes
-rw-r--r--src/assets/images/tray/darwin-dark/tray-active@2x.pngbin0 -> 1291 bytes
-rw-r--r--src/assets/images/tray/darwin-dark/tray-unread-active.pngbin0 -> 424 bytes
-rw-r--r--src/assets/images/tray/darwin-dark/tray-unread-active@2x.pngbin0 -> 1359 bytes
-rw-r--r--src/assets/images/tray/darwin-dark/tray-unread.pngbin0 -> 424 bytes
-rw-r--r--src/assets/images/tray/darwin-dark/tray-unread@2x.pngbin0 -> 1359 bytes
-rw-r--r--src/assets/images/tray/darwin-dark/tray.pngbin0 -> 396 bytes
-rw-r--r--src/assets/images/tray/darwin-dark/tray@2x.pngbin0 -> 1291 bytes
-rw-r--r--src/lib/Tray.js27
9 files changed, 17 insertions, 10 deletions
diff --git a/src/assets/images/tray/darwin-dark/tray-active.png b/src/assets/images/tray/darwin-dark/tray-active.png
new file mode 100644
index 000000000..489533dbf
--- /dev/null
+++ b/src/assets/images/tray/darwin-dark/tray-active.png
Binary files differ
diff --git a/src/assets/images/tray/darwin-dark/tray-active@2x.png b/src/assets/images/tray/darwin-dark/tray-active@2x.png
new file mode 100644
index 000000000..76f212b52
--- /dev/null
+++ b/src/assets/images/tray/darwin-dark/tray-active@2x.png
Binary files differ
diff --git a/src/assets/images/tray/darwin-dark/tray-unread-active.png b/src/assets/images/tray/darwin-dark/tray-unread-active.png
new file mode 100644
index 000000000..e2fd1a822
--- /dev/null
+++ b/src/assets/images/tray/darwin-dark/tray-unread-active.png
Binary files differ
diff --git a/src/assets/images/tray/darwin-dark/tray-unread-active@2x.png b/src/assets/images/tray/darwin-dark/tray-unread-active@2x.png
new file mode 100644
index 000000000..9a64b3ef8
--- /dev/null
+++ b/src/assets/images/tray/darwin-dark/tray-unread-active@2x.png
Binary files differ
diff --git a/src/assets/images/tray/darwin-dark/tray-unread.png b/src/assets/images/tray/darwin-dark/tray-unread.png
new file mode 100644
index 000000000..e2fd1a822
--- /dev/null
+++ b/src/assets/images/tray/darwin-dark/tray-unread.png
Binary files differ
diff --git a/src/assets/images/tray/darwin-dark/tray-unread@2x.png b/src/assets/images/tray/darwin-dark/tray-unread@2x.png
new file mode 100644
index 000000000..9a64b3ef8
--- /dev/null
+++ b/src/assets/images/tray/darwin-dark/tray-unread@2x.png
Binary files differ
diff --git a/src/assets/images/tray/darwin-dark/tray.png b/src/assets/images/tray/darwin-dark/tray.png
new file mode 100644
index 000000000..489533dbf
--- /dev/null
+++ b/src/assets/images/tray/darwin-dark/tray.png
Binary files differ
diff --git a/src/assets/images/tray/darwin-dark/tray@2x.png b/src/assets/images/tray/darwin-dark/tray@2x.png
new file mode 100644
index 000000000..76f212b52
--- /dev/null
+++ b/src/assets/images/tray/darwin-dark/tray@2x.png
Binary files differ
diff --git a/src/lib/Tray.js b/src/lib/Tray.js
index 631342b24..ca6131c0c 100644
--- a/src/lib/Tray.js
+++ b/src/lib/Tray.js
@@ -1,16 +1,10 @@
1import { app, Tray, Menu } from 'electron'; 1import { app, Tray, Menu, systemPreferences } from 'electron';
2import path from 'path'; 2import path from 'path';
3 3
4const FILE_EXTENSION = process.platform === 'win32' ? 'ico' : 'png'; 4const FILE_EXTENSION = process.platform === 'win32' ? 'ico' : 'png';
5const INDICATOR_TRAY_PLAIN = 'tray'; 5const INDICATOR_TRAY_PLAIN = 'tray';
6const INDICATOR_TRAY_UNREAD = 'tray-unread'; 6const INDICATOR_TRAY_UNREAD = 'tray-unread';
7 7
8function getAsset(type, asset) {
9 return path.join(
10 __dirname, '..', 'assets', 'images', type, process.platform, `${asset}.${FILE_EXTENSION}`,
11 );
12}
13
14export default class TrayIcon { 8export default class TrayIcon {
15 mainWindow = null; 9 mainWindow = null;
16 trayIcon = null; 10 trayIcon = null;
@@ -20,7 +14,7 @@ export default class TrayIcon {
20 } 14 }
21 15
22 show() { 16 show() {
23 this.trayIcon = new Tray(getAsset('tray', INDICATOR_TRAY_PLAIN)); 17 this.trayIcon = new Tray(this._getAsset('tray', INDICATOR_TRAY_PLAIN));
24 const trayMenuTemplate = [ 18 const trayMenuTemplate = [
25 { 19 {
26 label: 'Show Franz', 20 label: 'Show Franz',
@@ -53,12 +47,25 @@ export default class TrayIcon {
53 setIndicator(indicator) { 47 setIndicator(indicator) {
54 if (!this.trayIcon) return; 48 if (!this.trayIcon) return;
55 49
56 this.trayIcon.setImage(getAsset('tray', indicator !== 0 ? INDICATOR_TRAY_UNREAD : INDICATOR_TRAY_PLAIN)); 50 this.trayIcon.setImage(this._getAsset('tray', indicator !== 0 ? INDICATOR_TRAY_UNREAD : INDICATOR_TRAY_PLAIN));
57 51
58 if (process.platform === 'darwin') { 52 if (process.platform === 'darwin') {
59 this.trayIcon.setPressedImage( 53 this.trayIcon.setPressedImage(
60 getAsset('tray', `${indicator !== 0 ? INDICATOR_TRAY_UNREAD : INDICATOR_TRAY_PLAIN}-active`), 54 this._getAsset('tray', `${indicator !== 0 ? INDICATOR_TRAY_UNREAD : INDICATOR_TRAY_PLAIN}-active`),
61 ); 55 );
62 } 56 }
63 } 57 }
58
59
60 _getAsset(type, asset) {
61 let platform = process.platform;
62
63 if (platform === 'darwin' && systemPreferences.isDarkMode()) {
64 platform = `${platform}-dark`;
65 }
66
67 return path.join(
68 __dirname, '..', 'assets', 'images', type, platform, `${asset}.${FILE_EXTENSION}`,
69 );
70 }
64} 71}