Skip to content

Instantly share code, notes, and snippets.

Created Jul 2, 2015
Embed
What would you like to do?
The gist demonstrates how to create a custom Tabris.js Android theme.
<?xml version='1.0' encoding='utf-8'?>
<widget
xmlns="http://www.w3.org/ns/widgets"
id="com.eclipsesource.sandbox.theme"
version="1.0.0">
<name>Tabris.js Android Theming Sandbox</name>
<hook type="after_platform_add" src="scripts/android/afterPlatformAdd.js" />
<platform name="android">
<preference name="Theme" value="com.eclipsesource.sandbox.theme.R.style.Theme_Sandbox" />
</platform>
</widget>
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.Sandbox" parent="@style/Theme.Tabris.Light.DarkActionBar">
<item name="colorPrimary">#3F51B5</item>
<item name="colorPrimaryDark">#303F9F</item>
<item name="colorAccent">#FF4081</item>
</style>
</resources>
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
module.exports = function(context) {
var androidPlatformDir = path.join(context.opts.projectRoot, "platforms/android");
if (fs.existsSync(androidPlatformDir)) {
var srcDir = path.join(context.opts.projectRoot, "resources/android/res");
var targetDir = path.join(context.opts.projectRoot, "platforms/android/res");
copyRecursiveSync(srcDir, targetDir);
}
}
var copyRecursiveSync = function(src, dest) {
var exists = fs.existsSync(src);
var stats = exists && fs.statSync(src);
var isDirectory = exists && stats.isDirectory();
if (exists && isDirectory) {
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest);
}
fs.readdirSync(src).forEach(function(childItemName) {
copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName));
});
} else {
fs.linkSync(src, dest);
}
};
{
"title": "Tabris.js Android Theming Sandbox",
"main": "src/app.js",
"dependencies": {
"tabris": "^1.0.0"
}
}
var page = tabris.create("Page", {
title: "Tabris.js Theming",
topLevel: true
});
tabris.create("CheckBox", {
text: "Custom Theme",
layoutData: {left: 16, top: 16}
}).appendTo(page);
page.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment