feat: add APIs to support mojave dark modes (#14755)
* feat: add APIs to support mojave dark mode Closes #13387 * docs: fix system-prefs typo
This commit is contained in:
parent
8963529238
commit
0d2a0c7583
8 changed files with 204 additions and 1 deletions
|
@ -35,6 +35,14 @@ Returns:
|
|||
* `invertedColorScheme` Boolean - `true` if an inverted color scheme, such as
|
||||
a high contrast theme, is being used, `false` otherwise.
|
||||
|
||||
### Event: 'appearance-changed' _macOS_
|
||||
|
||||
Returns:
|
||||
|
||||
* `newAppearance` String - Can be `dark` or `light`
|
||||
|
||||
**NOTE:** This event is only emitted after you have called `startAppLevelAppearanceTrackingOS`
|
||||
|
||||
## Methods
|
||||
|
||||
### `systemPreferences.isDarkMode()` _macOS_
|
||||
|
@ -274,3 +282,51 @@ Returns `Boolean` - `true` if an inverted color scheme, such as a high contrast
|
|||
theme, is active, `false` otherwise.
|
||||
|
||||
[windows-colors]:https://msdn.microsoft.com/en-us/library/windows/desktop/ms724371(v=vs.85).aspx
|
||||
|
||||
### `systemPreferences.getEffectiveAppearance()` _macOS_
|
||||
|
||||
Returns `String` - Can be `dark`, `light` or `unknown`.
|
||||
|
||||
Gets the macOS appearance setting that is currently applied to your application,
|
||||
maps to [NSApplication.effectiveAppearance](https://developer.apple.com/documentation/appkit/nsapplication/2967171-effectiveappearance?language=objc)
|
||||
|
||||
Please note that until Electron is built targeting the 10.14 SDK, your application's
|
||||
`effectiveAppearance` will default to 'light' and won't inherit the OS preference. In
|
||||
the interim we have provided a helper method `startAppLevelAppearanceTrackingOS()`
|
||||
which emulates this behavior.
|
||||
|
||||
### `systemPreferences.getAppLevelAppearance()` _macOS_
|
||||
|
||||
Returns `String` | `null` - Can be `dark`, `light` or `unknown`.
|
||||
|
||||
Gets the macOS appearance setting that you have declared you want for
|
||||
your application, maps to [NSApplication.appearance](https://developer.apple.com/documentation/appkit/nsapplication/2967170-appearance?language=objc).
|
||||
You can use the `setAppLevelAppearance` API to set this value.
|
||||
|
||||
### `systemPreferences.setAppLevelAppearance(appearance)` _macOS_
|
||||
|
||||
* `appearance` String | null - Can be `dark` or `light`
|
||||
|
||||
Sets the appearance setting for your application, this should override the
|
||||
system default and override the value of `getEffectiveAppearance`.
|
||||
|
||||
### `systemPreferences.startAppLevelAppearanceTrackingOS()` _macOS_
|
||||
|
||||
This is a helper method to make your application's "appearance" setting track the
|
||||
user's OS level appearance setting. I.e. your app will have dark mode enabled if
|
||||
the user's system has dark mode enabled.
|
||||
|
||||
You can track this automatic change with the `appearance-changed` event.
|
||||
|
||||
**Note:** This method is exempt from our standard deprecation cycle and will be removed
|
||||
without deprecation in an upcoming major release of Electron as soon as we target the 10.14
|
||||
SDK
|
||||
|
||||
### `systemPreferences.stopAppLevelAppearanceTrackingOS()` _macOS_
|
||||
|
||||
This is a helper method to stop your application tracking the OS level appearance
|
||||
setting. It is a no-op if you have not called `startAppLevelAppearanceTrackingOS()`
|
||||
|
||||
**Note:** This method is exempt from our standard deprecation cycle and will be removed
|
||||
without deprecation in an upcoming major release of Electron as soon as we target the 10.14
|
||||
SDK
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue