Skip to content

Instantly share code, notes, and snippets.

@sobytes
Forked from codeboxed/app.js
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sobytes/df95b36070237cff383f to your computer and use it in GitHub Desktop.
Save sobytes/df95b36070237cff383f to your computer and use it in GitHub Desktop.
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
var isAndroid = false;
if (Ti.Platform.name === 'android') {
isAndroid = true;
}
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
// create base UI tab and root window
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
});
var win2 = Titanium.UI.createWindow({
title:'Tab 2',
backgroundColor:'#fff'
});
var tab2 = Titanium.UI.createTab({
icon:'KS_nav_ui.png',
title:'Tab 2',
window:win2
});
var win3 = Titanium.UI.createWindow({
title:'Tab 3',
backgroundColor:'#fff'
});
var tab3 = Titanium.UI.createTab({
icon:'KS_nav_ui.png',
title:'Tab 3',
window:win3
});
var win4 = Titanium.UI.createWindow({
title:'Tab 4',
backgroundColor:'#fff'
});
var tab4 = Titanium.UI.createTab({
icon:'KS_nav_ui.png',
title:'Tab 4',
window:win4
});
var win5 = Titanium.UI.createWindow({
title:'Tab 4',
backgroundColor:'#fff'
});
var tab5 = Titanium.UI.createTab({
icon:'KS_nav_ui.png',
title:'Tab 5',
window:win5
});
var win6 = Titanium.UI.createWindow({
title:'Tab 5',
backgroundColor:'#fff'
});
var tab6 = Titanium.UI.createTab({
icon:'KS_nav_ui.png',
title:'Tab 6',
window:win6
});
if (isAndroid) {
var moreWin = Ti.UI.createWindow({
title:'More',
url:'more_window.js',
backgroundColor:'#fff'
});
var moreTab = Ti.UI.createTab({
icon:'KS_nav_ui.png',
title:'More',
window:moreWin
});
}
// add tabs
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
tabGroup.addTab(tab3);
tabGroup.addTab(tab4);
if (isAndroid) {
tabGroup.addTab(moreTab);
} else {
tabGroup.addTab(tab5);
tabGroup.addTab(tab6);
}
// open tab group
tabGroup.open();
var win = Ti.UI.currentWindow;
var tabsData = [
{title: 'Tab 5', hasChild: true, url: 'window5.js'},
{title: 'Tab 6', hasChild: true, url: 'window6.js'}
];
var tabsTableView = Ti.UI.createTableView({
data: tabsData
});
tabsTableView.addEventListener('click', function (e) {
if (e.rowData.hasChild) {
var newWin = Ti.UI.createWindow({
title: e.rowData.title,
url: e.rowData.url
});
Ti.UI.currentTab.open(newWin);
}
});
win.add(tabsTableView);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment