mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 18:00:17 +01:00
48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
import { Platform } from 'react-native';
|
|
import prompt from 'react-native-prompt-android';
|
|
|
|
module.exports = (title, text, isCancelable = true, type = 'secure-text', isOKDestructive = false) => {
|
|
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';
|
|
}
|
|
|
|
return new Promise((resolve, reject) => {
|
|
const buttons = isCancelable
|
|
? [
|
|
{
|
|
text: 'Cancel',
|
|
onPress: () => {
|
|
reject(Error('Cancel Pressed'));
|
|
},
|
|
style: 'cancel',
|
|
},
|
|
{
|
|
text: 'OK',
|
|
onPress: password => {
|
|
console.log('OK Pressed');
|
|
resolve(password);
|
|
},
|
|
style: isOKDestructive ? 'destructive' : 'default',
|
|
},
|
|
]
|
|
: [
|
|
{
|
|
text: 'OK',
|
|
onPress: password => {
|
|
console.log('OK Pressed');
|
|
resolve(password);
|
|
},
|
|
},
|
|
];
|
|
|
|
prompt(title, text, buttons, {
|
|
type: type,
|
|
cancelable: isCancelable,
|
|
keyboardType,
|
|
});
|
|
});
|
|
};
|