1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00
joplin/packages/app-mobile/components/BackButtonDialogBox.ts

25 lines
564 B
TypeScript
Raw Normal View History

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