A NativeScript plugin to deal with dynamically loading UI Themes.
This is a fork from https://github.com/NathanaelA/nativescript-themes
. Check that repo for more updates.
To use the original plugin:
tns plugin add @proplugins/nativescript-themes@latest
To use this fork:
- clone the repo;
- make a .tar.gz with the contents of the
src/
folder; tns plugin add path/to/nativescript-themes.tar.gz
To use the module you just require()
it:
var themes = require('nativescript-themes');
Modify your startup app.js
var themes = require('nativescript-themes');
themes.applyTheme(themes.getAppliedTheme('red-theme.css'));
This will automatically apply the "red-theme.css" theme if no other theme has ever been chosen as the default theme.
You can also load a theme bundled by webpack using applyThemeCss
:
var themes = require('nativescript-themes');
var cssText = require('~/assets/themes/dark.scss');
themes.applyThemeCss(cssText, 'dark.scss');
Demo shows three sample themes, and shows how to load the last chosen theme at startup.
See also: https://github.com/tralves/ns-vue-theme-swap-sample
Documentation for this plugin is located here.