BlueWallet/prompt.js

35 lines
850 B
JavaScript
Raw Normal View History

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