mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: add number and phone input types for prompt dialog (#6365)
This commit is contained in:
committed by
Manol Donev
parent
7fbdc7adc8
commit
7e7c050064
@@ -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";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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) {
|
||||
|
||||
16
tns-core-modules/ui/dialogs/dialogs.d.ts
vendored
16
tns-core-modules/ui/dialogs/dialogs.d.ts
vendored
@@ -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>;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user