Add prompt for logout

This commit is contained in:
Jake Howard 2016-05-07 20:50:11 +01:00
parent 50fa5a4a03
commit ebf639a49c

View file

@ -4,9 +4,10 @@ import Icon from 'react-native-vector-icons/FontAwesome';
import token from '../../api/token'; import token from '../../api/token';
import RouteMaster from '../routes/RouteMaster'; import RouteMaster from '../routes/RouteMaster';
var { const {
StyleSheet, StyleSheet,
TouchableHighlight, TouchableHighlight,
Alert,
View, View,
Text Text
} = React; } = React;
@ -31,6 +32,16 @@ export default class LogoutButton extends React.Component {
token.clear(); token.clear();
this.props.nav.resetTo(RouteMaster.get('LOGIN')); 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() { render() {
return ( return (
@ -38,7 +49,7 @@ export default class LogoutButton extends React.Component {
<TouchableHighlight <TouchableHighlight
style={styles.toolbarButton} style={styles.toolbarButton}
underlayColor={GlobalStyles.get('CIRCLE_NAVBAR_BG')} underlayColor={GlobalStyles.get('CIRCLE_NAVBAR_BG')}
onPress={this.logout.bind(this)}> onPress={this.promptLogout.bind(this)}>
<Text style={styles.text}><Icon name="sign-out" style={styles.text}/></Text> <Text style={styles.text}><Icon name="sign-out" style={styles.text}/></Text>
</TouchableHighlight> </TouchableHighlight>
</View> </View>