Commit 12a0c461 authored by norhalimah's avatar norhalimah

backhandler

parent b295c1d1
......@@ -18,10 +18,12 @@ class Home extends React.PureComponent {
async componentDidMount() {
Orientation.lockToPortrait();
// Orientation.lockAsync(Orientation.OrientationLock.PORTRAIT_UP);
}
componentWillUnmount() {
Orientation.lockToPortrait();
// Orientation.lockAsync(Orientation.OrientationLock.PORTRAIT_UP);
}
render() {
......
......@@ -11,10 +11,11 @@ import {
TouchableHighlight,
Button,
Image,
///Alert,
Alert,
Modal,
TouchableOpacity,
Dimensions,
BackHandler,
} from 'react-native';
import {Stopwatch} from 'react-native-stopwatch-timer';
import Orientation from 'react-native-orientation';
......@@ -171,8 +172,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
keywordsList.splice(0, keywordsList.length);
......@@ -185,8 +185,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
this.setState({showW: true});
......@@ -204,8 +203,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
keywordsList.splice(0, keywordsList.length);
......@@ -218,8 +216,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
this.setState({showW: true});
......@@ -237,8 +234,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
keywordsList.splice(0, keywordsList.length);
......@@ -251,8 +247,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
this.setState({showW: true});
......@@ -270,8 +265,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
keywordsList.splice(0, keywordsList.length);
......@@ -284,8 +278,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
this.setState({showW: true});
......@@ -303,8 +296,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
keywordsList.splice(0, keywordsList.length);
......@@ -317,8 +309,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
this.setState({showW: true});
......@@ -336,8 +327,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
keywordsList.splice(0, keywordsList.length);
......@@ -350,8 +340,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
this.setState({showW: true});
......@@ -369,8 +358,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
keywordsList.splice(0, keywordsList.length);
......@@ -383,8 +371,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
this.setState({showW: true});
......@@ -402,8 +389,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
keywordsList.splice(0, keywordsList.length);
......@@ -416,8 +402,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
this.setState({showW: true});
......@@ -435,8 +420,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
keywordsList.splice(0, keywordsList.length);
......@@ -449,8 +433,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
this.setState({showW: true});
......@@ -468,8 +451,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
keywordsList.splice(0, keywordsList.length);
......@@ -482,8 +464,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
this.setState({showW: true});
......@@ -501,8 +482,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
keywordsList.splice(0, keywordsList.length);
......@@ -515,8 +495,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
this.setState({showW: true});
......@@ -534,8 +513,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
keywordsList.splice(0, keywordsList.length);
......@@ -548,8 +526,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
this.setState({showW: true});
......@@ -567,8 +544,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
keywordsList.splice(0, keywordsList.length);
......@@ -581,8 +557,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
this.setState({showW: true});
......@@ -600,8 +575,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
keywordsList.splice(0, keywordsList.length);
......@@ -614,8 +588,7 @@ class Quiz extends React.Component {
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
this.backAction();
}
else {
this.setState({showW: true});
......@@ -626,14 +599,34 @@ class Quiz extends React.Component {
}
};
homeExit = () => {
// this.props.navigation.navigate('1');
Alert.alert('Hold on!', 'Are you sure you want to stop?', [
{
text: 'Cancel',
onPress: () => null,
style: 'cancel',
},
{ text: 'YES', onPress: () => [ this.props.navigation.navigate('1'), Orientation.lockToPortrait()]},
]);
return true;
};
backAction = () => {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
};
async componentDidMount() {
//this.removeArray();
//BackHandler.addEventListener('hardwareBackPress', this.homeExit);
Orientation.lockToLandscape();
this.displayData();
}
componentWillUnmount() {
this.removeArray();
BackHandler.addEventListener('hardwareBackPress', this.homeExit);
//clearInterval(this.interval);
// Orientation.lockToLandscape();
}
......
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