2024-09-21 10:28:41 -07:00
|
|
|
import BackButtonService from '../services/BackButtonService';
|
2020-10-12 10:25:59 +01:00
|
|
|
const DialogBox = require('react-native-dialogbox').default;
|
|
|
|
|
|
|
|
export default class BackButtonDialogBox extends DialogBox {
|
2024-04-05 12:16:49 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
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
|
|
|
}
|
|
|
|
}
|