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