REF: show numeric keyboard when ask for numbers in prompt

This commit is contained in:
Ivan Vershigora 2020-10-20 11:20:52 +03:00 committed by Overtorment
parent 177730a89c
commit 056956c3fc

View File

@ -2,6 +2,8 @@ import { Platform } from 'react-native';
import prompt from 'react-native-prompt-android';
module.exports = (title, text, isCancelable = true, type = 'secure-text') => {
const keyboardType = type === 'numeric' ? 'numeric' : 'default';
if (Platform.OS === 'ios' && type === 'numeric') {
// `react-native-prompt-android` on ios does not support numeric input
type = 'plain-text';
@ -20,7 +22,7 @@ module.exports = (title, text, isCancelable = true, type = 'secure-text') => {
{
text: 'OK',
onPress: password => {
console.log('OK Pressed, password: ' + password);
console.log('OK Pressed');
resolve(password);
},
},
@ -29,7 +31,7 @@ module.exports = (title, text, isCancelable = true, type = 'secure-text') => {
{
text: 'OK',
onPress: password => {
console.log('OK Pressed, password: ' + password);
console.log('OK Pressed');
resolve(password);
},
},
@ -38,6 +40,7 @@ module.exports = (title, text, isCancelable = true, type = 'secure-text') => {
prompt(title, text, buttons, {
type: type,
cancelable: isCancelable,
keyboardType,
});
});
};