Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use dark mode support #260

Open
LDubya opened this issue Jan 14, 2020 · 2 comments
Open

how to use dark mode support #260

LDubya opened this issue Jan 14, 2020 · 2 comments

Comments

@LDubya
Copy link

LDubya commented Jan 14, 2020

Hello,

I notice that one of the Mac build settings is "darkModeSupport" (https://www.electron.build/configuration/mac)

How can the Meteor desktop app tell if the device is in dark mode so that it can set its styles to follow the system-wide dark mode setting?

@LDubya
Copy link
Author

LDubya commented Jan 14, 2020

It seems as though we'd need to do something like this:

const { nativeTheme, systemPreferences } = require('electron')

systemPreferences.subscribeNotification(
  'AppleInterfaceThemeChangedNotification',
  function theThemeHasChanged () {
    updateMyAppTheme(nativeTheme.shouldUseDarkColors)
  }
)

I'll give it a shot

@msavin
Copy link

msavin commented Mar 6, 2020

@LDubya

in settings.json:

      "mac": {
          "darkModeSupport": true,
          "extendInfo": {
            "NSRequiresAquaSystemAppearance": false
          }
      }

in desktop.js

eventsBus.on('windowCreated', (window) => {
  const setTheme = function () {
    const darkMode = systemPreferences.isDarkMode();
    desktop.send("darkMode",  darkMode)
  }

  systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', function () {
    setTheme()
  })

  setTheme()
});

This will only work on the build Electron application, not the one in development. It looks like meteor-desktop needs support for enableDarkMode and/or 'extendInfo'. cc @wojtkowiak @darqs

Update: looks like these things are working in development in Electron 8.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants