Skip to content

Commit

Permalink
Merge pull request #296 from ShivangiTiwari10/fix/redirectUser
Browse files Browse the repository at this point in the history
Fix/redirect user
  • Loading branch information
shreya-mishra authored Oct 10, 2023
2 parents b2abae6 + d9f21a8 commit 48f242b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/screens/AuthScreen/AuthScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
View,
TouchableOpacity,
Image,
BackHandler,
ScrollView,
StyleSheet,
Alert,
Expand Down Expand Up @@ -66,6 +67,25 @@ const AuthScreen = () => {
try {
//await requestCameraPermission();
setCameraActive((prev) => !prev); // Set cameraActive state to true

const backAction = () => {
console.log('backClicked');
setCameraActive(false);
Alert.alert('Hold on!', 'Are you sure you want to go back?', [
{
text: 'Cancel',
onPress: () => null,
style: 'cancel',
},
{ text: 'YES', onPress: () => BackHandler.exitApp() },
]);
return true;
};
const backHandler = BackHandler.addEventListener(
'hardwareBackPress',
backAction,
);
return () => backHandler.remove();
} catch (error: any) {
Alert.alert('Error requesting camera permission:', error);
}
Expand Down

0 comments on commit 48f242b

Please sign in to comment.