[TIMOB-10507] iOS: Text/password inputs for AlertDialog
| GitHub Issue | n/a |
|---|---|
| Type | New Feature |
| Priority | Critical |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2012-09-18T11:56:40.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | n/a |
| Labels | alertdialog, input, password, style, textfield |
| Reporter | Hidayet Dogan |
| Assignee | Betty Tran |
| Created | 2012-08-16T02:41:20.000+0000 |
| Updated | 2017-03-09T22:13:16.000+0000 |
Description
It would be nice to have text and password inputs can be enabled for AlertDialog. "style" API property can be used for this purpose. (UIAlertView alertViewStyle property).
For example:
var dialog = Ti.UI.createAlertDialog({
title: 'Please enter your name',
style: Ti.UI.iOS.AlertDialogStyle.PLAIN_TEXT_INPUT /* default is Ti.UI.iOS.AlertDialogStyle.DEFAULT */
});
and the text can be passed to AlertDialog's "click" event (fired by clickedButtonAtIndex).
I'm going to submit pull request for this feature, here is the functional test code:
Titanium.UI.setBackgroundColor('#fff'); var win = Titanium.UI.createWindow({ title: 'Alert Dialog Style', backgroundColor: '#fff', layout: 'vertical' }); var dialog = Titanium.UI.createAlertDialog({ message: 'Sample message...', buttonNames: ['OK', 'Cancel', 'Baska'] }); dialog.addEventListener('click', function(e) { switch (dialog.style) { case Titanium.UI.iPhone.AlertDialogStyle.PLAIN_TEXT_INPUT: value_label.text = 'Plain Text Input: ' + e.text; break; case Titanium.UI.iPhone.AlertDialogStyle.SECURE_TEXT_INPUT: value_label.text = 'Secure Text Input: ' + e.text; break; case Titanium.UI.iPhone.AlertDialogStyle.LOGIN_AND_PASSWORD_INPUT: value_label.text = 'Login: ' + e.login + ' Password: ' + e.password; break; default: value_label.text = 'Default alert dialog shown. There will be notextorlogin,passwordevent properties.'; break; } }); var button_default = Titanium.UI.createButton({ top: 10, title: 'Default Dialog', style: Titanium.UI.iPhone.SystemButtonStyle.BORDERED }); button_default.addEventListener('click', function(e) { dialog.title = 'Default Dialog'; dialog.style = Titanium.UI.iPhone.AlertDialogStyle.DEFAULT; dialog.show(); }); win.add(button_default); var button_plain = Titanium.UI.createButton({ top: 5, title: 'Plain Text Input Dialog', style: Titanium.UI.iPhone.SystemButtonStyle.BORDERED }); button_plain.addEventListener('click', function(e) { dialog.text = 'Enter text'; dialog.style = Titanium.UI.iPhone.AlertDialogStyle.PLAIN_TEXT_INPUT; dialog.show(); }); win.add(button_plain); var button_secure = Titanium.UI.createButton({ top: 5, title: 'Secure Text Input Dialog', style: Titanium.UI.iPhone.SystemButtonStyle.BORDERED }); button_secure.addEventListener('click', function(e) { dialog.title = 'Enter password'; dialog.style = Titanium.UI.iPhone.AlertDialogStyle.SECURE_TEXT_INPUT; dialog.show(); }); win.add(button_secure); var button_login_and_password = Titanium.UI.createButton({ top: 5, title: 'Login and Password Dialog', style: Titanium.UI.iPhone.SystemButtonStyle.BORDERED }); button_login_and_password.addEventListener('click', function(e) { dialog.title = 'Enter login and password'; dialog.style = Titanium.UI.iPhone.AlertDialogStyle.LOGIN_AND_PASSWORD_INPUT; dialog.show(); }); win.add(button_login_and_password); var label = Titanium.UI.createLabel({ top: 10, text: 'Dialog Input Value(s):' }); win.add(label); var value_label = Titanium.UI.createLabel({ top: 5, text: '' }); win.add(value_label); win.open();Git commit can be found at https://github.com/appcelerator/titanium_mobile/pull/2789 I've functionally tested with the code below using iOS 5 SDK.
merge pulled.
Closing ticket as fixed.