mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-18 09:35:20 +02:00
26 lines
658 B
TypeScript
26 lines
658 B
TypeScript
import BackButtonService from '../services/BackButtonService';
|
|
const DialogBox = require('react-native-dialogbox').default;
|
|
|
|
export default class BackButtonDialogBox extends DialogBox {
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
|
public constructor(props: any) {
|
|
super(props);
|
|
|
|
this.backHandler_ = () => {
|
|
if (this.state.isVisible) {
|
|
this.close();
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
}
|
|
|
|
public async componentDidUpdate() {
|
|
if (this.state.isVisible) {
|
|
BackButtonService.addHandler(this.backHandler_);
|
|
} else {
|
|
BackButtonService.removeHandler(this.backHandler_);
|
|
}
|
|
}
|
|
}
|