You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
Various RN changes
This commit is contained in:
32
ReactNativeClient/lib/dialogs.js
Normal file
32
ReactNativeClient/lib/dialogs.js
Normal file
@ -0,0 +1,32 @@
|
||||
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 };
|
Reference in New Issue
Block a user