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 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 {
<TouchableHighlight
style={styles.toolbarButton}
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>
</TouchableHighlight>
</View>