From acb8905dd64738c9e1b6d9a7987aff6500b31b3a Mon Sep 17 00:00:00 2001 From: Shyam Seshadri Date: Fri, 5 Oct 2018 19:09:52 +0530 Subject: [PATCH 1/3] feat: Add number inputType for prompt dialog Add an inputType number to the PromptOptions for dialogs Closes #6363 --- tns-core-modules/ui/dialogs/dialogs-common.ts | 5 +++++ tns-core-modules/ui/dialogs/dialogs.android.ts | 2 ++ tns-core-modules/ui/dialogs/dialogs.d.ts | 11 ++++++++--- tns-core-modules/ui/dialogs/dialogs.ios.ts | 2 ++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tns-core-modules/ui/dialogs/dialogs-common.ts b/tns-core-modules/ui/dialogs/dialogs-common.ts index 441c6a3661..4c3272703b 100644 --- a/tns-core-modules/ui/dialogs/dialogs-common.ts +++ b/tns-core-modules/ui/dialogs/dialogs-common.ts @@ -31,6 +31,11 @@ export module inputType { * Email input type. */ export const email: string = "email"; + + /** + * Number input type + */ + export const number: string = "number"; } /** diff --git a/tns-core-modules/ui/dialogs/dialogs.android.ts b/tns-core-modules/ui/dialogs/dialogs.android.ts index 7d6c81d33e..033469ef2b 100644 --- a/tns-core-modules/ui/dialogs/dialogs.android.ts +++ b/tns-core-modules/ui/dialogs/dialogs.android.ts @@ -184,6 +184,8 @@ export function prompt(arg: any): Promise { 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); } switch (options.capitalizationType) { diff --git a/tns-core-modules/ui/dialogs/dialogs.d.ts b/tns-core-modules/ui/dialogs/dialogs.d.ts index 9921f8761d..ecdd4ed298 100644 --- a/tns-core-modules/ui/dialogs/dialogs.d.ts +++ b/tns-core-modules/ui/dialogs/dialogs.d.ts @@ -21,6 +21,11 @@ export module inputType { * Email input type. */ export var email: string; + + /** + * Number input type. + */ + export var number: string; } /** @@ -81,7 +86,7 @@ export function prompt(message: string, defaultText?: string): Promise; @@ -95,7 +100,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; @@ -109,7 +114,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; diff --git a/tns-core-modules/ui/dialogs/dialogs.ios.ts b/tns-core-modules/ui/dialogs/dialogs.ios.ts index bf748c09d5..5947c82210 100644 --- a/tns-core-modules/ui/dialogs/dialogs.ios.ts +++ b/tns-core-modules/ui/dialogs/dialogs.ios.ts @@ -104,6 +104,8 @@ export function prompt(arg: any): Promise { if (options && options.inputType === inputType.email) { arg.keyboardType = UIKeyboardType.EmailAddress; + } else if (options && options.inputType === inputType.number) { + arg.keyboardType = UIKeyboardType.NumberPad; } let color = getTextFieldColor(); From f164f1b765a24b7abd25f6278b8419bfcdb2bbcf Mon Sep 17 00:00:00 2001 From: Shyam Seshadri Date: Sat, 6 Oct 2018 09:43:12 +0530 Subject: [PATCH 2/3] feat: Add inputType phone to prompt dialog Add support for phone inputType to prompt dialog, and add both prompt options to the dialogs test page. --- apps/app/ui-tests-app/dialogs/dialogs.xml | 4 +- apps/app/ui-tests-app/dialogs/view-model.ts | 40 +++++++++++++++++++ apps/package.json | 2 +- tns-core-modules/ui/dialogs/dialogs-common.ts | 5 +++ .../ui/dialogs/dialogs.android.ts | 2 + tns-core-modules/ui/dialogs/dialogs.d.ts | 5 +++ tns-core-modules/ui/dialogs/dialogs.ios.ts | 2 + 7 files changed, 58 insertions(+), 2 deletions(-) diff --git a/apps/app/ui-tests-app/dialogs/dialogs.xml b/apps/app/ui-tests-app/dialogs/dialogs.xml index b8a68129de..0ada85f9b6 100644 --- a/apps/app/ui-tests-app/dialogs/dialogs.xml +++ b/apps/app/ui-tests-app/dialogs/dialogs.xml @@ -7,7 +7,9 @@