From ebf639a49c02cd60e69beae9e44bdb9464527efd Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 7 May 2016 20:50:11 +0100 Subject: [PATCH] Add prompt for logout --- app/components/navigation/LogoutButton.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/components/navigation/LogoutButton.js b/app/components/navigation/LogoutButton.js index bddcde8..5e1ebde 100644 --- a/app/components/navigation/LogoutButton.js +++ b/app/components/navigation/LogoutButton.js @@ -4,9 +4,10 @@ import Icon from 'react-native-vector-icons/FontAwesome'; import token from '../../api/token'; import RouteMaster from '../routes/RouteMaster'; -var { +const { StyleSheet, TouchableHighlight, + Alert, View, Text } = React; @@ -31,6 +32,16 @@ export default class LogoutButton extends React.Component { token.clear(); this.props.nav.resetTo(RouteMaster.get('LOGIN')); } + promptLogout() { + Alert.alert( + 'Log out?', + 'Are you sure you want to log out?', + [ + { text: 'Yes', onPress: this.logout.bind(this) }, + { text: 'No' } + ] + ) + } render() { return ( @@ -38,7 +49,7 @@ export default class LogoutButton extends React.Component { + onPress={this.promptLogout.bind(this)}>