This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
Sphere/app/components/navigation/LogoutButton.js

59 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-05-07 19:32:59 +01:00
import React from 'react-native';
import GlobalStyles from '../../settings/styles';
import Icon from 'react-native-vector-icons/FontAwesome';
import token from '../../api/token';
import RouteMaster from '../routes/RouteMaster';
2016-05-07 20:50:11 +01:00
const {
2016-05-07 19:32:59 +01:00
StyleSheet,
TouchableHighlight,
2016-05-07 20:50:11 +01:00
Alert,
2016-05-07 19:32:59 +01:00
View,
Text
} = React;
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center'
},
toolbarButton: {
paddingHorizontal: 15,
},
text: {
color: GlobalStyles.get('CIRCLE_NAVBAR_TEXT'),
fontSize: 18,
paddingHorizontal: 10
}
});
export default class LogoutButton extends React.Component {
logout() {
token.clear();
this.props.nav.resetTo(RouteMaster.get('LOGIN'));
}
2016-05-07 20:50:11 +01:00
promptLogout() {
Alert.alert(
'Log out?',
'Are you sure you want to log out?',
[
{ text: 'Yes', onPress: this.logout.bind(this) },
{ text: 'No' }
]
)
}
2016-05-07 19:32:59 +01:00
render() {
return (
<View style={styles.container}>
<TouchableHighlight
style={styles.toolbarButton}
underlayColor={GlobalStyles.get('CIRCLE_NAVBAR_BG')}
2016-05-07 20:50:11 +01:00
onPress={this.promptLogout.bind(this)}>
2016-05-07 19:32:59 +01:00
<Text style={styles.text}><Icon name="sign-out" style={styles.text}/></Text>
</TouchableHighlight>
</View>
);
}
}