cordova-plugin-os-theme
v1.0.1
Published
Get information about the os theme (light / dark modes).
Downloads
7
Maintainers
Readme
cordova-plugin-os-theme
This plugin is designed to return information about the current os theme (android and iOS).
Installation
Through your terminal:
# Newest npm version
cordova plugin add cordova-plugin-os-theme
# Newest github version
cordova plugin add https://github.com/DavidBriglio/cordova-plugin-os-theme.git
Useage
This plugin has one method: cordova.plugins.osTheme.getTheme()
that will return a promise that will in turn receive an object with the current os theme properties. Currently there is only one property being tracked: isDark
. This will be set to true
only if dark mode is confirmed active. If we do not know the state of the theme or it is in light mode, isDark
will be false
.
Example
cordova.plugins.osTheme.getTheme()
.then(theme => { // { isDark: [boolean] }
console.log('The current theme is: ' + (theme.isDark ? 'Dark' : 'Light'))
})
.catch(message => { // string error message
console.log('Error getting theme: ' + message)
})
Compatibility
This plugin can be used for android
, and iOS
version 13.0.0+
!
License
MIT - Please see license file for full details.
Questions
Please feel free to open an issue!