Skip to content
Snippets Groups Projects
Unverified Commit 82016022 authored by Djorkaeff Alexandre's avatar Djorkaeff Alexandre Committed by GitHub
Browse files

[FIX] Backhandler onboarding (#2077)

parent 6c2bc1c6
No related branches found
No related tags found
No related merge requests found
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { import {
Text, Keyboard, StyleSheet, TouchableOpacity, View, Alert Text, Keyboard, StyleSheet, TouchableOpacity, View, Alert, BackHandler
} from 'react-native'; } from 'react-native';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import * as FileSystem from 'expo-file-system'; import * as FileSystem from 'expo-file-system';
...@@ -105,6 +105,7 @@ class NewServerView extends React.Component { ...@@ -105,6 +105,7 @@ class NewServerView extends React.Component {
certificate: null certificate: null
}; };
EventEmitter.addEventListener('NewServer', this.handleNewServerEvent); EventEmitter.addEventListener('NewServer', this.handleNewServerEvent);
BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
} }
componentDidMount() { componentDidMount() {
...@@ -116,6 +117,16 @@ class NewServerView extends React.Component { ...@@ -116,6 +117,16 @@ class NewServerView extends React.Component {
componentWillUnmount() { componentWillUnmount() {
EventEmitter.removeListener('NewServer', this.handleNewServerEvent); 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) => { onChangeText = (text) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment