1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-05-28 22:27:40 +02:00
2017-07-13 00:01:15 +01:00

32 lines
627 B
JavaScript

import DialogBox from 'react-native-dialogbox';
// Add this at the bottom of the component:
//
// <DialogBox ref={dialogbox => { this.dialogbox = dialogbox }}/>
let dialogs = {};
dialogs.confirm = (parentComponent, message) => {
if (!'dialogbox' in parentComponent) throw new Error('A "dialogbox" component must be defined on the parent component!');
return new Promise((resolve, reject) => {
parentComponent.dialogbox.confirm({
content: message,
ok: {
callback: () => {
resolve(true);
}
},
cancel: {
callback: () => {
resolve(false);
}
},
});
})
}
export { dialogs };