From b0e698520f0be4e054b8f3d1feff694d1ddf1779 Mon Sep 17 00:00:00 2001 From: Steliyan Stoyanov Date: Tue, 29 Oct 2019 20:34:19 +0200 Subject: Add "adaptable dark mode" checkbox --- .../settings/settings/EditSettingsForm.js | 3 + src/containers/settings/EditSettingsScreen.js | 10 ++ src/i18n/locales/defaultMessages.json | 169 +++++++++++---------- src/i18n/locales/en-US.json | 1 + .../settings/settings/EditSettingsForm.json | 116 +++++++------- .../containers/settings/EditSettingsScreen.json | 53 ++++--- src/stores/ServicesStore.js | 5 + 7 files changed, 201 insertions(+), 156 deletions(-) diff --git a/src/components/settings/settings/EditSettingsForm.js b/src/components/settings/settings/EditSettingsForm.js index 2be5c4ed7..d567a47d1 100644 --- a/src/components/settings/settings/EditSettingsForm.js +++ b/src/components/settings/settings/EditSettingsForm.js @@ -12,6 +12,7 @@ import PremiumFeatureContainer from '../../ui/PremiumFeatureContainer'; import Input from '../../ui/Input'; import { FRANZ_TRANSLATION } from '../../../config'; +import { isMac } from '../../../environment'; function escapeHtml(unsafe) { return unsafe @@ -383,8 +384,10 @@ export default @observer class EditSettingsForm extends Component { + {isMac && } {isDarkmodeEnabled && ( <> +

this._shareSettingsWithServiceProcess(), ); + reaction( + () => this.stores.settings.app.adaptableDarkMode, + () => this._shareSettingsWithServiceProcess(), + ); + reaction( () => this.stores.settings.app.universalDarkMode, () => this._shareSettingsWithServiceProcess(), -- cgit v1.2.3-70-g09d2 From b3d2bad9c5a481132d3d4c81b876b6754d684592 Mon Sep 17 00:00:00 2001 From: Steliyan Stoyanov Date: Tue, 29 Oct 2019 22:53:10 +0200 Subject: Respect MacOS current theme --- src/stores/UIStore.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 { reaction, } from 'mobx'; import { theme } from '@meetfranz/theme'; +import { remote } from 'electron'; import Store from './lib/Store'; +import { isMac } from '../environment'; + +const { systemPreferences } = remote; export default class UIStore extends Store { @observable showServicesUpdatedInfoBar = false; + @observable isOsDarkThemeActive = isMac ? systemPreferences.isDarkMode() : false; + constructor(...args) { super(...args); @@ -18,6 +24,13 @@ export default class UIStore extends Store { this.actions.ui.openSettings.listen(this._openSettings.bind(this)); this.actions.ui.closeSettings.listen(this._closeSettings.bind(this)); this.actions.ui.toggleServiceUpdatedInfoBar.listen(this._toggleServiceUpdatedInfoBar.bind(this)); + + // Listen for theme change on MacOS + if (isMac) { + systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => { + this.isOsDarkThemeActive = systemPreferences.isDarkMode(); + }); + } } setup() { @@ -35,7 +48,7 @@ export default class UIStore extends Store { } @computed get isDarkThemeActive() { - return this.stores.settings.all.app.darkMode; + return this.stores.settings.all.app.darkMode || (this.stores.settings.all.app.adaptableDarkMode && this.isOsDarkThemeActive); } @computed get theme() { -- cgit v1.2.3-70-g09d2