Skip to content

Instantly share code, notes, and snippets.

@vanbungkring
Created July 30, 2012 15:01
Show Gist options
  • Save vanbungkring/3207599 to your computer and use it in GitHub Desktop.
Save vanbungkring/3207599 to your computer and use it in GitHub Desktop.
var menu = require('lib/menu');
Ti.App.addEventListener('addAirplaneToTable', function(e) {
closeOpen()
})
var winmenu = new menu();
winmenu.open();
var menuOpen = false;
var win = Titanium.UI.createWindow({
left : 0,
width : '100%',
zIndex : 2
});
var win1 = Titanium.UI.createWindow({
title : 'Master Window',
backgroundColor : '#fff',
barColor : '#4a649d'
});
var nav = Titanium.UI.iPhone.createNavigationGroup({
window : win1
});
var menuButton = Ti.UI.createButton({
title : 'menu',
style : Titanium.UI.iPhone.SystemButtonStyle.BORDERED
});
var winAnimIn = Ti.UI.createAnimation({
left : 0,
curve : Ti.UI.iOS.ANIMATION_CURVE_EASE_OUT,
duration : 300
});
var winAnimOut = Ti.UI.createAnimation({
left : 258,
curve : Ti.UI.iOS.ANIMATION_CURVE_EASE_OUT,
duration : 300
});
function closeOpen() {
if (menuOpen) {
win.animate(winAnimIn);
winCover.hide();
} else {
win.animate(winAnimOut);
winCover.show();
}
menuOpen = !menuOpen;
}
menuButton.addEventListener('click', function(e) {
closeOpen()
});
win1.setLeftNavButton(menuButton);
var tableView = Ti.UI.createTableView({
zIndex : 1
});
tableView.addEventListener('click', function(e) {
nav.open(win2);
});
var row = Ti.UI.createTableViewRow({
title : 'Open Detail Window',
height : 44
});
tableView.setData([row]);
win1.add(tableView);
var winCover = Ti.UI.createView({
width : Ti.UI.FILL,
height : Ti.UI.FILL,
visible : false,
zIndex : 2
});
winCover.addEventListener('click', function(e) {
if (menuOpen) {
win.animate(winAnimIn);
winCover.hide();
menuOpen = !menuOpen;
}
});
win1.add(winCover);
var win2 = Titanium.UI.createWindow({
title : 'Detail Window',
backgroundColor : '#fff',
barColor : '#4a649d',
backButtonTitle : 'Back'
});
win.add(nav);
win.addEventListener('open', function(e) {
winmenu.show();
});
win.open();
function createRow(text) {
var row = Ti.UI.createTableViewRow({
height : 40,
selectedBackgroundColor : '#262c3a'
});
var rowLabel = Ti.UI.createLabel({
left : 10,
text : text,
color : '#ddd',
font : {
fontSize : 15,
fontWeight : 'bold'
}
});
row.add(rowLabel);
return row;
}
function createHeader(text) {
var headerView = Ti.UI.createView({
width : Ti.UI.FILL,
height : 24,
backgroundColor : '#3e4357'
});
var headerLabel = Ti.UI.createLabel({
left : 10,
text : text,
color : '#fff',
font : {
fontSize : 14,
fontWeight : 'bold'
},
shadowColor : "#000",
shadowOffset : {
x : 0,
y : 1
}
});
headerView.add(headerLabel);
return headerView;
}
function Menu() {
var self = Titanium.UI.createWindow({
left : 0,
width : 258,
backgroundColor : '#323848',
visible : false,
zIndex : 1
});
var tableView = Ti.UI.createTableView({
backgroundColor : '#323848',
separatorColor : '#2a3040'
});
self.add(tableView);
var section1 = Ti.UI.createTableViewSection();
section1.headerView = createHeader('Menu Group 1');
section1.add(createRow('Menu Item 1'));
section1.add(createRow('Menu Item 2'));
var section2 = Ti.UI.createTableViewSection();
section2.headerView = createHeader('Menu Group 2');
section2.add(createRow('Menu Item 3'));
section2.add(createRow('Menu Item 4'));
section2.add(createRow('Menu Item 5'));
var section3 = Ti.UI.createTableViewSection();
section3.headerView = createHeader('Menu Group 3');
section3.add(createRow('Menu Item 6'));
section3.add(createRow('Menu Item 7'));
section3.add(createRow('Menu Item 8'));
section3.add(createRow('Menu Item 9'));
section3.add(createRow('Menu Item 10'));
var section4 = Ti.UI.createTableViewSection();
section4.headerView = createHeader('Menu Group 4');
section4.add(createRow('Menu Item 11'));
section4.add(createRow('Menu Item 12'));
section4.add(createRow('Menu Item 13'));
tableView.setData([section1, section2, section3, section4]);
tableView.addEventListener('click', function(e) {
Ti.App.fireEvent('addAirplaneToTable')
})
return self;
}
module.exports = Menu;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment