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 {
|
2023-03-06 16:22:01 +02:00
|
|
|
public constructor(props: any) {
|
2021-01-22 19:41:11 +02:00
|
|
|
super(props);
|
2020-10-12 11:25:59 +02:00
|
|
|
|
|
|
|
this.backHandler_ = () => {
|
|
|
|
if (this.state.isVisible) {
|
|
|
|
this.close();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-03-06 16:22:01 +02:00
|
|
|
public async componentDidUpdate() {
|
2020-11-14 18:02:14 +02:00
|
|
|
if (this.state.isVisible) {
|
|
|
|
BackButtonService.addHandler(this.backHandler_);
|
|
|
|
} else {
|
|
|
|
BackButtonService.removeHandler(this.backHandler_);
|
|
|
|
}
|
2020-10-12 11:25:59 +02:00
|
|
|
}
|
|
|
|
}
|