From 628f805645a1b0f73298adfea784e6e4e5cd71ee Mon Sep 17 00:00:00 2001 From: sarthakpranesh Date: Sat, 27 Jun 2020 19:30:35 +0530 Subject: [PATCH] Update - logout should show confirmation dialog --- src/screens/GameHome.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/screens/GameHome.js b/src/screens/GameHome.js index 03997c4..6441935 100644 --- a/src/screens/GameHome.js +++ b/src/screens/GameHome.js @@ -8,6 +8,7 @@ import { Animated, TouchableOpacity, BackHandler, + Alert, } from 'react-native'; import SoundPlayer from 'react-native-sound-player'; import auth from '@react-native-firebase/auth'; @@ -113,6 +114,25 @@ export default class GameHome extends Component { }); } + onLogout() { + Alert.alert( + 'Logout', + 'Are you sure, you want to logout of the app?', + [ + { + text: 'Yes', + onPress: async () => { + await GoogleSignin.revokeAccess(); + await GoogleSignin.signOut(); + auth().signOut(); + }, + }, + {text: 'No'}, + ], + {cancelable: true}, + ); + } + render() { return ( @@ -154,11 +174,7 @@ export default class GameHome extends Component { { - await GoogleSignin.revokeAccess(); - await GoogleSignin.signOut(); - auth().signOut(); - }}> + onPress={() => this.onLogout()}> LogOut