aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/UIStore.js
diff options
context:
space:
mode:
authorLibravatar Steliyan Stoyanov <steliyan@st6.io>2019-10-29 22:53:10 +0200
committerLibravatar Steliyan Stoyanov <steliyan@st6.io>2019-10-30 10:11:26 +0200
commitb3d2bad9c5a481132d3d4c81b876b6754d684592 (patch)
treeef363afd8756c155259af8d512e286a29836b734 /src/stores/UIStore.js
parentAdd "adaptable dark mode" checkbox (diff)
downloadferdium-app-b3d2bad9c5a481132d3d4c81b876b6754d684592.tar.gz
ferdium-app-b3d2bad9c5a481132d3d4c81b876b6754d684592.tar.zst
ferdium-app-b3d2bad9c5a481132d3d4c81b876b6754d684592.zip
Respect MacOS current theme
Diffstat (limited to 'src/stores/UIStore.js')
-rw-r--r--src/stores/UIStore.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/stores/UIStore.js b/src/stores/UIStore.js
index 9680c5bcc..44bc7c974 100644
--- a/src/stores/UIStore.js
+++ b/src/stores/UIStore.js
@@ -5,12 +5,18 @@ import {
5 reaction, 5 reaction,
6} from 'mobx'; 6} from 'mobx';
7import { theme } from '@meetfranz/theme'; 7import { theme } from '@meetfranz/theme';
8import { remote } from 'electron';
8 9
9import Store from './lib/Store'; 10import Store from './lib/Store';
11import { isMac } from '../environment';
12
13const { systemPreferences } = remote;
10 14
11export default class UIStore extends Store { 15export default class UIStore extends Store {
12 @observable showServicesUpdatedInfoBar = false; 16 @observable showServicesUpdatedInfoBar = false;
13 17
18 @observable isOsDarkThemeActive = isMac ? systemPreferences.isDarkMode() : false;
19
14 constructor(...args) { 20 constructor(...args) {
15 super(...args); 21 super(...args);
16 22
@@ -18,6 +24,13 @@ export default class UIStore extends Store {
18 this.actions.ui.openSettings.listen(this._openSettings.bind(this)); 24 this.actions.ui.openSettings.listen(this._openSettings.bind(this));
19 this.actions.ui.closeSettings.listen(this._closeSettings.bind(this)); 25 this.actions.ui.closeSettings.listen(this._closeSettings.bind(this));
20 this.actions.ui.toggleServiceUpdatedInfoBar.listen(this._toggleServiceUpdatedInfoBar.bind(this)); 26 this.actions.ui.toggleServiceUpdatedInfoBar.listen(this._toggleServiceUpdatedInfoBar.bind(this));
27
28 // Listen for theme change on MacOS
29 if (isMac) {
30 systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => {
31 this.isOsDarkThemeActive = systemPreferences.isDarkMode();
32 });
33 }
21 } 34 }
22 35
23 setup() { 36 setup() {
@@ -35,7 +48,7 @@ export default class UIStore extends Store {
35 } 48 }
36 49
37 @computed get isDarkThemeActive() { 50 @computed get isDarkThemeActive() {
38 return this.stores.settings.all.app.darkMode; 51 return this.stores.settings.all.app.darkMode || (this.stores.settings.all.app.adaptableDarkMode && this.isOsDarkThemeActive);
39 } 52 }
40 53
41 @computed get theme() { 54 @computed get theme() {