Skip to content

Instantly share code, notes, and snippets.

@adampax
Created October 21, 2011 20:07
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 adampax/1304819 to your computer and use it in GitHub Desktop.
Save adampax/1304819 to your computer and use it in GitHub Desktop.
simple contact list with detail window in a tab group
var app = {};
app.createContactTabGroup = function() {
var tg = Ti.UI.createTabGroup();
var win = Ti.UI.createWindow({
title : 'Contact Us',
});
var tab1 = Ti.UI.createTab({
title : 'tab 1',
window : win
});
tg.addTab(tab1);
var tableData = [{
title : 'Bob',
email : 'bob@domain.com'
}, {
title : 'Susie',
email : 'susie@domain.com'
}];
var tableview = Titanium.UI.createTableView({
top : 0,
data : tableData
});
win.add(tableview);
tableview.addEventListener("click", function(e) {
var win2 = app.createContactDetailWindow(e.rowData);
tab1.open(win2);
});
return tg;
};
app.createContactDetailWindow = function(contact) {
var win = Ti.UI.createWindow({
title : 'Contact Details',
backgroundColor:'#fff'
});
var emailButton = Ti.UI.createButton({
title : 'Email: ' + contact.title,
height : 50,
width : 200
});
win.add(emailButton);
emailButton.addEventListener('click', function(e) {
var emailDialog = Titanium.UI.createEmailDialog();
if(!emailDialog.isSupported()) {
alert('email not supported');
}
emailDialog.subject = "NEW COMMENT ON ";
emailDialog.toRecipients = ['johnmohan@aol.com'];
emailDialog.messageBody = "The sender has added the following comment which was also embedded in the attached jpeg by FOTONOTES" + "\n" + "\n FOTONOTES is needed to view the embedded comments. FOTONOTES can be downloaded to your Android from Google";
emailDialog.open();
Ti.API.info("Email sent");
});
return win;
}
var tg = app.createContactTabGroup();
tg.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment