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 {
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
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
|
|
|
}
|
|
|
|
}
|