Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dawsontoth
Last active December 10, 2015 22:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dawsontoth/4503143 to your computer and use it in GitHub Desktop.
Save dawsontoth/4503143 to your computer and use it in GitHub Desktop.
Demonstrates what using CommonJS can look like for a standard tab group on iOS or Android using Appcelerator Titanium. Note that I recommend placing the "ui-" stuff in a "ui" directory, but Gists don't let me do subdirectories.
var tabGroup = Ti.UI.createTabGroup({
backgroundColor: '#fff'
});
tabGroup.addTab(Ti.UI.createTab({
title: 'Tab 1',
window: require('ui-win1').createWindow(),
icon: 'images/tab-1.png'
}));
tabGroup.addTab(Ti.UI.createTab({
title: 'Tab 2',
window: require('ui-win2').createWindow(),
icon: 'images/tab-2.png'
}));
require('push').startListening();
tabGroup.open();
exports.startListening = function() {
// do your registerForPushNotifications
// when you do get a push, you can Ti.App.fireEvent if there is UI you want to update.
};
exports.createView = function (args) {
if (!args) args = {};
if (!args.color) args.color = 'blue';
return Ti.UI.createLabel(args);
};
exports.createWindow = function () {
var win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
win.add(require('ui-label').createView({
text: 'This is Win 1'
}));
return win;
};
exports.createWindow = function () {
var win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
win.add(require('ui-label').createView({
text: 'This is Win 2'
}));
return win;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment