diff options
author | Mahadevan Sreenivasan <mahadevan_sv@yahoo.com> | 2020-04-09 05:27:58 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-09 00:57:58 +0100 |
commit | 5e5945f591027ce6f160010bbd577b8ae8479035 (patch) | |
tree | 9d34b953d9d7d17b8ee9f275f403f89bd3a41c13 /src/stores/UIStore.js | |
parent | #304 Add option to show draggable window area (#532) (diff) | |
download | ferdium-app-5e5945f591027ce6f160010bbd577b8ae8479035.tar.gz ferdium-app-5e5945f591027ce6f160010bbd577b8ae8479035.tar.zst ferdium-app-5e5945f591027ce6f160010bbd577b8ae8479035.zip |
Add support for Adaptable Dark Mode on Windows (#548)
- Add support for making adaptable checkbox visible for Windows
- Add support in UIStore to check for theme updated using the nativeTheme.on('update', () => {}) event and update the darkmode properties accordinly.
- Update intl to change text to a more generic wording - "settings.app.form.adaptableDarkMode": "Synchronize dark mode with my OS's dark mode setting"
Diffstat (limited to 'src/stores/UIStore.js')
-rw-r--r-- | src/stores/UIStore.js | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/stores/UIStore.js b/src/stores/UIStore.js index 6941cf086..f6e059bfb 100644 --- a/src/stores/UIStore.js +++ b/src/stores/UIStore.js | |||
@@ -5,14 +5,14 @@ import { theme } from '@meetfranz/theme'; | |||
5 | import { remote } from 'electron'; | 5 | import { remote } from 'electron'; |
6 | 6 | ||
7 | import Store from './lib/Store'; | 7 | import Store from './lib/Store'; |
8 | import { isMac } from '../environment'; | 8 | import { isMac, isWindows } from '../environment'; |
9 | 9 | ||
10 | const { nativeTheme, systemPreferences } = remote; | 10 | const { nativeTheme, systemPreferences } = remote; |
11 | 11 | ||
12 | export default class UIStore extends Store { | 12 | export default class UIStore extends Store { |
13 | @observable showServicesUpdatedInfoBar = false; | 13 | @observable showServicesUpdatedInfoBar = false; |
14 | 14 | ||
15 | @observable isOsDarkThemeActive = isMac | 15 | @observable isOsDarkThemeActive = (isMac || isWindows) |
16 | ? nativeTheme.shouldUseDarkColors | 16 | ? nativeTheme.shouldUseDarkColors |
17 | : false; | 17 | : false; |
18 | 18 | ||
@@ -36,6 +36,13 @@ export default class UIStore extends Store { | |||
36 | }, | 36 | }, |
37 | ); | 37 | ); |
38 | } | 38 | } |
39 | |||
40 | if (isWindows) { | ||
41 | nativeTheme.on('updated', () => { | ||
42 | this.isOsDarkThemeActive = nativeTheme.shouldUseDarkColors; | ||
43 | this.actions.service.shareSettingsWithServiceProcess(); | ||
44 | }); | ||
45 | } | ||
39 | } | 46 | } |
40 | 47 | ||
41 | setup() { | 48 | setup() { |
@@ -56,16 +63,16 @@ export default class UIStore extends Store { | |||
56 | } | 63 | } |
57 | 64 | ||
58 | @computed get isDarkThemeActive() { | 65 | @computed get isDarkThemeActive() { |
59 | const isMacWithAdaptableInDarkMode = isMac | 66 | const isMacOrWindowsWithAdaptableInDarkMode = (isMac || isWindows) |
60 | && this.stores.settings.all.app.adaptableDarkMode | 67 | && this.stores.settings.all.app.adaptableDarkMode |
61 | && this.isOsDarkThemeActive; | 68 | && this.isOsDarkThemeActive; |
62 | const isMacWithoutAdaptableInDarkMode = isMac | 69 | const isMacOrWindowsWithoutAdaptableInDarkMode = (isMac || isWindows) |
63 | && this.stores.settings.all.app.darkMode | 70 | && this.stores.settings.all.app.darkMode |
64 | && !this.stores.settings.all.app.adaptableDarkMode; | 71 | && !this.stores.settings.all.app.adaptableDarkMode; |
65 | const isNotMacInDarkMode = !isMac && this.stores.settings.all.app.darkMode; | 72 | const isMacOrWindowsNotInDarkMode = !(isMac || isWindows) && this.stores.settings.all.app.darkMode; |
66 | return !!(isMacWithAdaptableInDarkMode | 73 | return !!(isMacOrWindowsWithAdaptableInDarkMode |
67 | || isMacWithoutAdaptableInDarkMode | 74 | || isMacOrWindowsWithoutAdaptableInDarkMode |
68 | || isNotMacInDarkMode); | 75 | || isMacOrWindowsNotInDarkMode); |
69 | } | 76 | } |
70 | 77 | ||
71 | @computed get theme() { | 78 | @computed get theme() { |