feat: add number and phone input types for prompt dialog (#6365)

This commit is contained in:
Shyam Seshadri
2018-11-07 21:02:20 +05:30
committed by Manol Donev
parent 7fbdc7adc8
commit 7e7c050064
6 changed files with 74 additions and 4 deletions

View File

@@ -31,6 +31,16 @@ export module inputType {
* Email input type.
*/
export const email: string = "email";
/**
* Number input type
*/
export const number: string = "number";
/**
* Phone input type
*/
export const phone: string = "phone";
}
/**

View File

@@ -184,6 +184,10 @@ export function prompt(arg: any): Promise<PromptResult> {
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);
} else if (options.inputType === inputType.number) {
input.setInputType(android.text.InputType.TYPE_CLASS_NUMBER);
} else if (options.inputType === inputType.phone) {
input.setInputType(android.text.InputType.TYPE_CLASS_PHONE);
}
switch (options.capitalizationType) {

View File

@@ -21,6 +21,16 @@ export module inputType {
* Email input type.
*/
export var email: string;
/**
* Number input type.
*/
export var number: string;
/**
* Phone input type.
*/
export var phone: string;
}
/**
@@ -81,7 +91,7 @@ export function prompt(message: string, defaultText?: string): Promise<PromptRes
/**
* The prompt() method displays a dialog box that prompts the visitor for input.
* @param options The options for the dialog box.
* @param options The options for the dialog box.
*/
export function prompt(options: PromptOptions): Promise<PromptResult>;
@@ -95,7 +105,7 @@ export function login(message: string, userName?: string, password?: string): Pr
/**
* The login() method displays a login dialog box that prompts the visitor for user name and password.
* @param options The options for the dialog box.
* @param options The options for the dialog box.
*/
export function login(options: LoginOptions): Promise<LoginResult>;
@@ -109,7 +119,7 @@ export function action(message: string, cancelButtonText: string, actions: Array
/**
* The action() method displays a action box that prompts the visitor to choose some action.
* @param options The options for the dialog box.
* @param options The options for the dialog box.
*/
export function action(options: ActionOptions): Promise<string>;

View File

@@ -104,6 +104,10 @@ export function prompt(arg: any): Promise<PromptResult> {
if (options && options.inputType === inputType.email) {
arg.keyboardType = UIKeyboardType.EmailAddress;
} else if (options && options.inputType === inputType.number) {
arg.keyboardType = UIKeyboardType.NumberPad;
} else if (options && options.inputType === inputType.phone) {
arg.keyboardType = UIKeyboardType.PhonePad;
}
let color = getTextFieldColor();