Created
October 21, 2011 20:07
-
-
Save adampax/1304819 to your computer and use it in GitHub Desktop.
simple contact list with detail window in a tab group
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 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 : '[email protected]' | |
}, { | |
title : 'Susie', | |
email : '[email protected]' | |
}]; | |
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 = ['[email protected]']; | |
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