Skip to content

Commit 628f805

Browse files
author
sarthakpranesh
committed
Update - logout should show confirmation dialog
1 parent 5f6e418 commit 628f805

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/screens/GameHome.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
Animated,
99
TouchableOpacity,
1010
BackHandler,
11+
Alert,
1112
} from 'react-native';
1213
import SoundPlayer from 'react-native-sound-player';
1314
import auth from '@react-native-firebase/auth';
@@ -113,6 +114,25 @@ export default class GameHome extends Component {
113114
});
114115
}
115116

117+
onLogout() {
118+
Alert.alert(
119+
'Logout',
120+
'Are you sure, you want to logout of the app?',
121+
[
122+
{
123+
text: 'Yes',
124+
onPress: async () => {
125+
await GoogleSignin.revokeAccess();
126+
await GoogleSignin.signOut();
127+
auth().signOut();
128+
},
129+
},
130+
{text: 'No'},
131+
],
132+
{cancelable: true},
133+
);
134+
}
135+
116136
render() {
117137
return (
118138
<View style={styles.viewContainer}>
@@ -154,11 +174,7 @@ export default class GameHome extends Component {
154174
</TouchableOpacity>
155175
<TouchableOpacity
156176
style={styles.button}
157-
onPress={async () => {
158-
await GoogleSignin.revokeAccess();
159-
await GoogleSignin.signOut();
160-
auth().signOut();
161-
}}>
177+
onPress={() => this.onLogout()}>
162178
<Text style={styles.buttonText}>LogOut</Text>
163179
</TouchableOpacity>
164180
</Animated.View>

0 commit comments

Comments
 (0)