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