[FIX] Backhandler onboarding (#2077)

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Djorkaeff Alexandre 2020-04-30 13:06:58 -03:00 committed by GitHub
parent 6c2bc1c635
commit 8201602291
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions

View File

@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
Text, Keyboard, StyleSheet, TouchableOpacity, View, Alert
Text, Keyboard, StyleSheet, TouchableOpacity, View, Alert, BackHandler
} from 'react-native';
import { connect } from 'react-redux';
import * as FileSystem from 'expo-file-system';
@ -105,6 +105,7 @@ class NewServerView extends React.Component {
certificate: null
};
EventEmitter.addEventListener('NewServer', this.handleNewServerEvent);
BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
}
componentDidMount() {
@ -116,6 +117,16 @@ class NewServerView extends React.Component {
componentWillUnmount() {
EventEmitter.removeListener('NewServer', this.handleNewServerEvent);
BackHandler.removeEventListener('hardwareBackPress', this.handleBackPress);
}
handleBackPress = () => {
const { navigation } = this.props;
if (navigation.isFocused() && this.previousServer) {
this.close();
return true;
}
return false;
}
onChangeText = (text) => {