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