mirror of
https://github.com/status-im/react-native-dialogs.git
synced 2025-03-01 00:30:28 +00:00
Implement 'keyboardType' on native side (#104)
This commit is contained in:
parent
86341a5bfc
commit
8a4cbfdb5d
@ -172,7 +172,7 @@ type ProgressStyle = typeof DialogAndroid.progressHorizontal;
|
|||||||
|
|
||||||
type OptionsPrompt = {|
|
type OptionsPrompt = {|
|
||||||
...OptionsCommon,
|
...OptionsCommon,
|
||||||
keyboardType?: 'numeric' | 'numbers-and-punctuation' | 'numeric-password' | 'email-address' | 'password' | 'phone-pad' | 'decimal-pad',
|
keyboardType?: 'numeric' | 'number-pad' | 'decimal-pad' | 'numeric-password' | 'email-address' | 'password' | 'phone-pad' | 'url',
|
||||||
defaultValue?: string,
|
defaultValue?: string,
|
||||||
placeholder?: string,
|
placeholder?: string,
|
||||||
allowEmptyInput?: boolean,
|
allowEmptyInput?: boolean,
|
||||||
@ -446,7 +446,7 @@ class DialogAndroid {
|
|||||||
if (allowEmptyInput !== undefined) inputConfig.allowEmptyInput = allowEmptyInput;
|
if (allowEmptyInput !== undefined) inputConfig.allowEmptyInput = allowEmptyInput;
|
||||||
if (minLength) inputConfig.minLength = minLength;
|
if (minLength) inputConfig.minLength = minLength;
|
||||||
if (maxLength) inputConfig.maxLength = maxLength;
|
if (maxLength) inputConfig.maxLength = maxLength;
|
||||||
// if (keyboardType) inputConfig.keyboardType = keyboardType; // TODO: support this on native side - https://github.com/aakashns/react-native-dialogs/pull/55
|
if (keyboardType) inputConfig.keyboardType = keyboardType;
|
||||||
|
|
||||||
const nativeConfig = {
|
const nativeConfig = {
|
||||||
...DialogAndroid.defaults,
|
...DialogAndroid.defaults,
|
||||||
|
100
README.md
100
README.md
@ -4,49 +4,49 @@
|
|||||||
An Android only module for Material Design dialogs. This is a wrapper over [afollestad/material-dialogs](https://github.com/afollestad/material-dialogs). This module is designed for Android only with no plans to support iOS.
|
An Android only module for Material Design dialogs. This is a wrapper over [afollestad/material-dialogs](https://github.com/afollestad/material-dialogs). This module is designed for Android only with no plans to support iOS.
|
||||||
|
|
||||||
### Table of Contents
|
### Table of Contents
|
||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
- [Manual Linking](#manual-linking)
|
- [Manual Linking](#manual-linking)
|
||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
- [API](#api)
|
- [API](#api)
|
||||||
- [Properties](#properties)
|
- [Properties](#properties)
|
||||||
- [`defaults`](#defaults)
|
- [`defaults`](#defaults)
|
||||||
- [`actionDismiss`](#actiondismiss)
|
- [`actionDismiss`](#actiondismiss)
|
||||||
- [`actionNegative`](#actionnegative)
|
- [`actionNegative`](#actionnegative)
|
||||||
- [`actionNeutral`](#actionneutral)
|
- [`actionNeutral`](#actionneutral)
|
||||||
- [`actionPositive`](#actionpositive)
|
- [`actionPositive`](#actionpositive)
|
||||||
- [`listPlain`](#listplain)
|
- [`listPlain`](#listplain)
|
||||||
- [`listRadio`](#listradio)
|
- [`listRadio`](#listradio)
|
||||||
- [`listCheckbox`](#listcheckbox)
|
- [`listCheckbox`](#listcheckbox)
|
||||||
- [`progressHorizontal`](#progresshorizontal)
|
- [`progressHorizontal`](#progresshorizontal)
|
||||||
- [Methods](#methods)
|
- [Methods](#methods)
|
||||||
- [`alert`](#alert)
|
- [`alert`](#alert)
|
||||||
- [`assignDefaults`](#assigndefaults)
|
- [`assignDefaults`](#assigndefaults)
|
||||||
- [`dismiss`](#dismiss)
|
- [`dismiss`](#dismiss)
|
||||||
- [`prompt`](#prompt)
|
- [`prompt`](#prompt)
|
||||||
- [`showPicker`](#showpicker)
|
- [`showPicker`](#showpicker)
|
||||||
- [`showProgress`](#showprogress)
|
- [`showProgress`](#showprogress)
|
||||||
- [Types](#types)
|
- [Types](#types)
|
||||||
- [Internal Types](#internal-types)
|
- [Internal Types](#internal-types)
|
||||||
- [`type ActionType`](#type-actiontype)
|
- [`type ActionType`](#type-actiontype)
|
||||||
- [`type ListItem`](#type-listitem)
|
- [`type ListItem`](#type-listitem)
|
||||||
- [`type ListType`](#type-listtype)
|
- [`type ListType`](#type-listtype)
|
||||||
- [`type OptionsAlert`](#type-optionsalert)
|
- [`type OptionsAlert`](#type-optionsalert)
|
||||||
- [`type OptionsCheckbox`](#type-optionscheckbox)
|
- [`type OptionsCheckbox`](#type-optionscheckbox)
|
||||||
- [`type OptionsCommon`](#type-optionscommon)
|
- [`type OptionsCommon`](#type-optionscommon)
|
||||||
- [`type OptionsProgress`](#type-optionsprogress)
|
- [`type OptionsProgress`](#type-optionsprogress)
|
||||||
- [`type OptionsPicker`](#type-optionspicker)
|
- [`type OptionsPicker`](#type-optionspicker)
|
||||||
- [`type OptionsPrompt`](#type-optionsprompt)
|
- [`type OptionsPrompt`](#type-optionsprompt)
|
||||||
- [`type ProgressStyle`](#type-progressstyle)
|
- [`type ProgressStyle`](#type-progressstyle)
|
||||||
- [Examples](#examples)
|
- [Examples](#examples)
|
||||||
- [Progress Dialog](#progress-dialog)
|
- [Progress Dialog](#progress-dialog)
|
||||||
- [Basic List](#basic-list)
|
- [Basic List](#basic-list)
|
||||||
- [Radio List](#radio-list)
|
- [Radio List](#radio-list)
|
||||||
- [Without auto-dismiss](#without-auto-dismiss)
|
- [Without auto-dismiss](#without-auto-dismiss)
|
||||||
- [Checklist](#checklist)
|
- [Checklist](#checklist)
|
||||||
- [With clear list button](#with-clear-list-button)
|
- [With clear list button](#with-clear-list-button)
|
||||||
- [Prompt](#prompt)
|
- [Prompt](#prompt)
|
||||||
- [HTML](#html)
|
- [HTML](#html)
|
||||||
- [assignDefaults](#assigndefaults)
|
- [assignDefaults](#assigndefaults)
|
||||||
- [Contributors](#contributors)
|
- [Contributors](#contributors)
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
@ -437,6 +437,20 @@ Shows a progress dialog. By default no buttons are shown, and hardware back butt
|
|||||||
|
|
||||||
> {
|
> {
|
||||||
> ...OptionsCommon,
|
> ...OptionsCommon,
|
||||||
|
> keyboardType?:
|
||||||
|
> | 'numeric'
|
||||||
|
> | 'number-pad'
|
||||||
|
> | 'numeric-password'
|
||||||
|
> | 'decimal-pad'
|
||||||
|
> | 'email-address'
|
||||||
|
> | 'password'
|
||||||
|
> | 'phone-pad'
|
||||||
|
> | 'url',
|
||||||
|
> defaultValue?: string,
|
||||||
|
> placeholder?: string,
|
||||||
|
> allowEmptyInput?: boolean,
|
||||||
|
> minLength?: number,
|
||||||
|
> maxLength?: number,
|
||||||
> widgetColor?: ColorValue
|
> widgetColor?: ColorValue
|
||||||
> }
|
> }
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.aakashns.reactnativedialogs.modules;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
|
import android.text.InputType;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@ -367,9 +368,43 @@ public class DialogAndroid extends ReactContextBaseJavaModule {
|
|||||||
// Check if empty input is allowed
|
// Check if empty input is allowed
|
||||||
boolean allowEmptyInput = !input.hasKey("allowEmptyInput") || input.getBoolean("allowEmptyInput");
|
boolean allowEmptyInput = !input.hasKey("allowEmptyInput") || input.getBoolean("allowEmptyInput");
|
||||||
|
|
||||||
// TODO : Provide pre-selected input types in Javascript
|
if (input.hasKey("keyboardType")) {
|
||||||
if (input.hasKey("type")) {
|
switch (input.getString("keyboardType")) {
|
||||||
mBuilder.inputType(input.getInt("type"));
|
case "phone-pad":
|
||||||
|
mBuilder.inputType(InputType.TYPE_CLASS_PHONE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "number-pad":
|
||||||
|
mBuilder.inputType(InputType.TYPE_CLASS_NUMBER);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "decimal-pad":
|
||||||
|
mBuilder.inputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "numeric":
|
||||||
|
mBuilder.inputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "numeric-password":
|
||||||
|
mBuilder.inputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "email-address":
|
||||||
|
mBuilder.inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "password":
|
||||||
|
mBuilder.inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "url":
|
||||||
|
mBuilder.inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_URI);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
mBuilder.inputType(InputType.TYPE_CLASS_TEXT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int minLength = input.hasKey("minLength") ? input.getInt("minLength") : 0;
|
int minLength = input.hasKey("minLength") ? input.getInt("minLength") : 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user