1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-12 08:54:00 +02:00
joplin/packages/app-mobile/components/BackButtonDialogBox.ts
2021-01-22 17:41:11 +00:00

25 lines
550 B
TypeScript

const { BackButtonService } = require('../services/back-button.js');
const DialogBox = require('react-native-dialogbox').default;
export default class BackButtonDialogBox extends DialogBox {
constructor(props: any) {
super(props);
this.backHandler_ = () => {
if (this.state.isVisible) {
this.close();
return true;
}
return false;
};
}
async componentDidUpdate() {
if (this.state.isVisible) {
BackButtonService.addHandler(this.backHandler_);
} else {
BackButtonService.removeHandler(this.backHandler_);
}
}
}