BlueWallet/prompt.js

38 lines
916 B
JavaScript
Raw Normal View History

import prompt from 'react-native-prompt-android';
2018-03-31 02:03:58 +02:00
2019-01-05 17:29:13 +01:00
module.exports = (title, text, isCancelable = true, type = 'secure-text') => {
2018-09-18 08:48:53 +02:00
return new Promise((resolve, reject) => {
const buttons = isCancelable
? [
{
text: 'Cancel',
onPress: () => {
reject(Error('Cancel Pressed'));
},
style: 'cancel',
2018-09-18 08:48:53 +02:00
},
{
text: 'OK',
onPress: password => {
console.log('OK Pressed, password: ' + password);
resolve(password);
},
2018-03-31 02:03:58 +02:00
},
]
: [
{
text: 'OK',
onPress: password => {
console.log('OK Pressed, password: ' + password);
resolve(password);
},
},
];
prompt(title, text, buttons, {
2019-01-05 17:29:13 +01:00
type: type,
cancelable: isCancelable,
});
2018-03-31 02:03:58 +02:00
});
};