Last active
December 10, 2015 22:38
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.createView = function (args) { | |
if (!args) args = {}; | |
if (!args.color) args.color = 'blue'; | |
return Ti.UI.createLabel(args); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.createWindow = function () { | |
var win = Ti.UI.createWindow({ | |
backgroundColor: '#fff' | |
}); | |
win.add(require('ui-label').createView({ | |
text: 'This is Win 1' | |
})); | |
return win; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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