Giter Club home page Giter Club logo

cordova-plugin-os-theme's Introduction

cordova-plugin-os-theme npm version

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!

cordova-plugin-os-theme's People

Contributors

davidbriglio avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

cordova-plugin-os-theme's Issues

Theme change event

Hi @DavidBriglio. Thanks for this cool plugin. I have feature suggestion :). Do you think, it could be possible to listen for some OS theme change event (or system configuration change, not sure) and broadcast it to JavaScript? Basically, I need to listen for dark mode change in my app in order to dynamically apply dark/light theme on OS theme change. What I did so far (as workaround) โ€“ is checking (via this plugin) what is the OS color schema every some time however I would like to avoid that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.