diff options
author | Stefan Malzner <stefan@adlk.io> | 2017-10-19 16:18:10 +0200 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2017-10-19 16:27:21 +0200 |
commit | 55805f1d8fba4d1e96dba3ef02ec56c5de349778 (patch) | |
tree | 0e391af956c2b20f5728f82d595380286902f205 /src | |
parent | Reset travis env vars (diff) | |
download | ferdium-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
Diffstat (limited to 'src')
-rw-r--r-- | src/assets/images/tray/darwin-dark/tray-active.png | bin | 0 -> 396 bytes | |||
-rw-r--r-- | src/assets/images/tray/darwin-dark/tray-active@2x.png | bin | 0 -> 1291 bytes | |||
-rw-r--r-- | src/assets/images/tray/darwin-dark/tray-unread-active.png | bin | 0 -> 424 bytes | |||
-rw-r--r-- | src/assets/images/tray/darwin-dark/tray-unread-active@2x.png | bin | 0 -> 1359 bytes | |||
-rw-r--r-- | src/assets/images/tray/darwin-dark/tray-unread.png | bin | 0 -> 424 bytes | |||
-rw-r--r-- | src/assets/images/tray/darwin-dark/tray-unread@2x.png | bin | 0 -> 1359 bytes | |||
-rw-r--r-- | src/assets/images/tray/darwin-dark/tray.png | bin | 0 -> 396 bytes | |||
-rw-r--r-- | src/assets/images/tray/darwin-dark/tray@2x.png | bin | 0 -> 1291 bytes | |||
-rw-r--r-- | src/lib/Tray.js | 27 |
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 @@ | |||
1 | import { app, Tray, Menu } from 'electron'; | 1 | import { app, Tray, Menu, systemPreferences } from 'electron'; |
2 | import path from 'path'; | 2 | import path from 'path'; |
3 | 3 | ||
4 | const FILE_EXTENSION = process.platform === 'win32' ? 'ico' : 'png'; | 4 | const FILE_EXTENSION = process.platform === 'win32' ? 'ico' : 'png'; |
5 | const INDICATOR_TRAY_PLAIN = 'tray'; | 5 | const INDICATOR_TRAY_PLAIN = 'tray'; |
6 | const INDICATOR_TRAY_UNREAD = 'tray-unread'; | 6 | const INDICATOR_TRAY_UNREAD = 'tray-unread'; |
7 | 7 | ||
8 | function getAsset(type, asset) { | ||
9 | return path.join( | ||
10 | __dirname, '..', 'assets', 'images', type, process.platform, `${asset}.${FILE_EXTENSION}`, | ||
11 | ); | ||
12 | } | ||
13 | |||
14 | export default class TrayIcon { | 8 | export 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 | } |