Skip to content

Commit 95cfa1b

Browse files
Kilianckerr
andauthored
docs: fix missing import, explicitly use nativeTheme api (electron#21937)
* docs: fix missing import, explicitly use nativeTheme api * Update docs/tutorial/mojave-dark-mode-guide.md Co-Authored-By: Charles Kerr <ckerr@github.com> * switch to nativeTheme event Co-authored-by: Charles Kerr <ckerr@github.com>
1 parent 89eb309 commit 95cfa1b

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

docs/tutorial/mojave-dark-mode-guide.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
In macOS 10.14 Mojave, Apple introduced a new [system-wide dark mode](https://developer.apple.com/design/human-interface-guidelines/macos/visual-design/dark-mode/)
44
for all macOS computers. If your app does have a dark mode, you can make your Electron app
5-
follow the system-wide dark mode setting.
5+
follow the system-wide dark mode setting using [the nativeTheme api](../api/native-theme.md).
66

77
In macOS 10.15 Catalina, Apple introduced a new "automatic" dark mode option for all macOS computers. In order
8-
for the `isDarkMode` and `Tray` APIs to work correctly in this mode on Catalina you need to either have `NSRequiresAquaSystemAppearance` set to `false` in your `Info.plist` file or be on Electron `>=7.0.0`.
8+
for the `nativeTheme.shouldUseDarkColors` and `Tray` APIs to work correctly in this mode on Catalina you need to either have `NSRequiresAquaSystemAppearance` set to `false` in your `Info.plist` file or be on Electron `>=7.0.0`.
99

1010
## Automatically updating the native interfaces
1111

@@ -18,15 +18,12 @@ out of this theming.
1818
## Automatically updating your own interfaces
1919

2020
If your app has its own dark mode you should toggle it on and off in sync with the system's dark mode setting. You can do
21-
this by listening for the theme changed event on Electron's `systemPreferences` module. E.g.
21+
this by listening for the theme updated event on Electron's `nativeTheme` module. E.g.
2222

2323
```js
2424
const { nativeTheme } = require('electron')
2525

26-
systemPreferences.subscribeNotification(
27-
'AppleInterfaceThemeChangedNotification',
28-
function theThemeHasChanged () {
29-
updateMyAppTheme(nativeTheme.shouldUseDarkColors)
30-
}
31-
)
26+
nativeTheme.on('updated', function theThemeHasChanged () {
27+
updateMyAppTheme(nativeTheme.shouldUseDarkColors)
28+
})
3229
```

0 commit comments

Comments
 (0)