Feature: New Dialog-Prompt-Input-Type for E-Mails (#3905)

* #3118 Feature: New Dialog-Prompt-Input-Type for E-Mails

* Forgot to change a comment

Changed Password to Email in a comment.
This commit is contained in:
Eddy Verbruggen
2017-04-06 11:41:04 +02:00
committed by Hristo Hristov
parent 59e34f0bfc
commit 979c2fe850
4 changed files with 25 additions and 3 deletions

View File

@ -25,6 +25,11 @@ export module inputType {
* Password input type. * Password input type.
*/ */
export const password: string = "password"; export const password: string = "password";
/**
* Email input type.
*/
export const email: string = "email";
} }
let frame: typeof frameModule; let frame: typeof frameModule;

View File

@ -179,8 +179,12 @@ export function prompt(arg: any): Promise<PromptResult> {
const input = new android.widget.EditText(androidApp.foregroundActivity); const input = new android.widget.EditText(androidApp.foregroundActivity);
if (options && options.inputType === inputType.password) { if (options) {
input.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD); if (options.inputType === inputType.password) {
input.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD);
} else if (options.inputType === inputType.email) {
input.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
}
} }
input.setText(options && options.defaultText || ""); input.setText(options && options.defaultText || "");

View File

@ -14,6 +14,11 @@ export module inputType {
* Password input type. * Password input type.
*/ */
export var password: string; export var password: string;
/**
* Email input type.
*/
export var email: string;
} }
/** /**
@ -167,7 +172,7 @@ export interface PromptOptions extends ConfirmOptions {
defaultText?: string; defaultText?: string;
/** /**
* Gets or sets the prompt input type (plain text or password). * Gets or sets the prompt input type (plain text, password, or email).
*/ */
inputType?: string; inputType?: string;
} }

View File

@ -240,6 +240,10 @@ export function prompt(arg: any): Promise<PromptResult> {
textField = alert.textFieldAtIndex(0); textField = alert.textFieldAtIndex(0);
textField.text = isString(options.defaultText) ? options.defaultText : ""; textField.text = isString(options.defaultText) ? options.defaultText : "";
if (options.inputType === inputType.email) {
textField.keyboardType = UIKeyboardType.EmailAddress;
}
// Assign first to local letiable, otherwise it will be garbage collected since delegate is weak reference. // Assign first to local letiable, otherwise it will be garbage collected since delegate is weak reference.
let delegate = UIAlertViewDelegateImpl.initWithCallback(function (view, index) { let delegate = UIAlertViewDelegateImpl.initWithCallback(function (view, index) {
resolve({ result: getDialogResult(alert.tag, index), text: textField.text }); resolve({ result: getDialogResult(alert.tag, index), text: textField.text });
@ -257,6 +261,10 @@ export function prompt(arg: any): Promise<PromptResult> {
arg.text = isString(options.defaultText) ? options.defaultText : ""; arg.text = isString(options.defaultText) ? options.defaultText : "";
arg.secureTextEntry = options && options.inputType === inputType.password; arg.secureTextEntry = options && options.inputType === inputType.password;
if (options && options.inputType === inputType.email) {
arg.keyboardType = UIKeyboardType.EmailAddress;
}
let color = getTextFieldColor(); let color = getTextFieldColor();
if (color) { if (color) {
arg.textColor = arg.tintColor = color.ios; arg.textColor = arg.tintColor = color.ios;