Commit d794fa83 authored by norhalimah's avatar norhalimah

backhandler fixed

parent 58a0fc00
......@@ -17,7 +17,7 @@ class App extends React.PureComponent {
componentDidMount() {
Orientation.lockToPortrait();
}
componentDidUpdate(){
componentDidUpdate() {
Orientation.lockToPortrait();
}
......
......@@ -10,9 +10,11 @@ import {
StyleSheet,
ScrollView,
Image,
BackHandler,
} from 'react-native';
import {Icon} from 'react-native-elements';
import Orientation from 'react-native-orientation';
const exitApp = () => BackHandler.exitApp();
class Home extends React.PureComponent {
......@@ -26,7 +28,9 @@ class Home extends React.PureComponent {
// Orientation.lockAsync(Orientation.OrientationLock.PORTRAIT_UP);
}
render() {
BackHandler.addEventListener('hardwareBackPress', exitApp);
return (
<View style={styles.container}>
<ImageBackground
......
......@@ -10,6 +10,7 @@ import {
StyleSheet,
ScrollView,
// Alert,
BackHandler,
} from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';
import Orientation from 'react-native-orientation';
......@@ -43,8 +44,13 @@ class LogBook extends React.PureComponent {
this.displayData();
}
homeExit = async () => {
this.props.navigation.navigate('1');
//Orientation.lockToPortrait();
};
render() {
BackHandler.addEventListener('hardwareBackPress', this.homeExit);
return (
<View style={styles.container}>
<ImageBackground
......
......@@ -599,9 +599,9 @@ class Quiz extends React.Component {
}
};
homeExit = () => {
homeExit = async () => {
// this.props.navigation.navigate('1');
Alert.alert('Hold on!', 'Are you sure you want to stop?', [
Alert.alert('Hold on!', 'Are you sure you want to exit?', [
{
text: 'Cancel',
onPress: () => null,
......@@ -617,16 +617,16 @@ class Quiz extends React.Component {
Orientation.lockToPortrait();
};
async componentDidMount() {
componentDidMount() {
//this.removeArray();
BackHandler.addEventListener('hardwareBackPress', this.homeExit);
// BackHandler.addEventListener('hardwareBackPress', this.homeExit);
Orientation.lockToLandscape();
this.displayData();
}
componentWillUnmount() {
this.removeArray();
BackHandler.addEventListener('hardwareBackPress', this.homeExit);
// BackHandler.addEventListener('hardwareBackPress', this.homeExit);
//clearInterval(this.interval);
// Orientation.lockToLandscape();
}
......@@ -752,6 +752,7 @@ this.setState({records: []});
};
render() {
BackHandler.addEventListener('hardwareBackPress', this.homeExit);
const {
selectedKeywordStyle,
buttonStyle,
......
......@@ -12,6 +12,7 @@ import {
ScrollView,
Dimensions,
// TextInput,
BackHandler,
} from 'react-native';
import Orientation from 'react-native-orientation';
import Notes from './data';
......@@ -172,7 +173,14 @@ export default class Settings extends React.Component {
}
}
homeExit = async () => {
this.props.navigation.navigate('1');
//Orientation.lockToPortrait();
};
render() {
BackHandler.addEventListener('hardwareBackPress', this.homeExit);
return (
<View style={styles.container}>
<SafeAreaView>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment