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/routes/login.js

124 lines
2.8 KiB
JavaScript
Raw Normal View History

2016-02-01 20:58:00 +00:00
import React from 'react-native';
import GlobalStyles from '../../settings/styles';
const {
StyleSheet,
Text,
View,
TextInput,
TouchableHighlight,
ScrollView,
BackAndroid
} = React;
const styles = StyleSheet.create({
container: {
2016-02-02 14:50:42 +00:00
flex: 1,
2016-02-01 20:58:00 +00:00
backgroundColor: '#F5FCFF',
},
2016-02-02 14:50:42 +00:00
contentWrapper: {
flex: 0.85,
2016-02-02 19:16:21 +00:00
justifyContent: 'flex-start',
2016-02-02 14:50:42 +00:00
alignItems: 'center'
},
2016-02-01 20:58:00 +00:00
input: {
2016-02-02 19:16:21 +00:00
marginHorizontal: 15,
fontSize: 15,
2016-02-02 14:50:42 +00:00
textAlign: 'center'
2016-02-01 20:58:00 +00:00
},
loginButton: {
2016-02-02 14:50:42 +00:00
flex: 1,
2016-02-01 20:58:00 +00:00
backgroundColor: GlobalStyles.get('CIRCLE_BLUE'),
justifyContent: 'center',
alignItems: 'center',
2016-02-02 19:16:21 +00:00
padding: 10
2016-02-01 20:58:00 +00:00
},
loginButtonText: {
2016-02-02 19:16:21 +00:00
fontSize: 18,
2016-02-01 20:58:00 +00:00
color: 'white',
},
2016-02-02 14:50:42 +00:00
buttonContainer: {
flexDirection: 'row',
justifyContent: 'center',
2016-02-02 19:16:21 +00:00
padding: 10,
paddingVertical: 15
2016-02-02 14:50:42 +00:00
},
2016-02-01 20:58:00 +00:00
title: {
2016-02-02 19:16:21 +00:00
fontSize: 30,
2016-02-01 20:58:00 +00:00
margin: 13
2016-02-02 19:16:21 +00:00
},
heading: {
fontSize: 18,
margin: 8,
marginVertical: 20
},
helpText: {
fontSize: 12,
2016-02-01 20:58:00 +00:00
}
});
export default class Login extends React.Component {
constructor() {
super();
2016-02-01 22:41:36 +00:00
this.state = {
2016-02-02 19:16:21 +00:00
token: ''
2016-02-01 22:41:36 +00:00
};
this.validate = this.validate.bind(this);
this.updateState = this.updateState.bind(this);
2016-02-01 20:58:00 +00:00
}
2016-02-01 22:41:36 +00:00
updateState(key, value) {
let state = this.state;
state[key] = value;
this.setState(state);
}
2016-02-01 20:58:00 +00:00
2016-02-01 22:41:36 +00:00
validate() {
2016-02-01 20:58:00 +00:00
}
2016-02-02 19:16:21 +00:00
componentWillUnmount() {
BackAndroid.removeEventListener('hardwareBackPress', () => { return true; }); // Re-enable back button
}
2016-02-01 20:58:00 +00:00
componentWillMount() {
BackAndroid.addEventListener('hardwareBackPress', () => { return true; }); // Disable back button
}
render() {
return (
2016-02-02 14:50:42 +00:00
<View style={styles.container}>
2016-02-02 19:16:21 +00:00
<View style={styles.buttonContainer}>
<Text style={styles.title}>
Sphere
</Text>
</View>
2016-02-02 14:50:42 +00:00
<ScrollView keyboardShouldPersistTaps={false} contentContainerStyle={styles.container}>
<View style={styles.contentWrapper}>
2016-02-02 19:16:21 +00:00
<Text style={styles.heading}>
Please enter your CircleCI token
2016-02-02 14:50:42 +00:00
</Text>
<TextInput
style={styles.input}
2016-02-02 19:16:21 +00:00
onChangeText={(token) => this.updateState('token', token)}
value={this.state.token}
2016-02-02 14:50:42 +00:00
onSubmitEditing={this.validate}
2016-02-02 19:16:21 +00:00
placeholder="CircleCI Token"
autoCorrect={false}
2016-02-02 14:50:42 +00:00
/>
2016-02-02 19:16:21 +00:00
<Text style={styles.helpText}>
What's this?
</Text>
2016-02-02 14:50:42 +00:00
</View>
</ScrollView>
<View style={styles.buttonContainer}>
<TouchableHighlight style={styles.loginButton} onPress={this.validate}>
2016-02-01 20:58:00 +00:00
<Text style={styles.loginButtonText}>
Authenticate
</Text>
</TouchableHighlight>
</View>
2016-02-02 14:50:42 +00:00
</View>
2016-02-01 20:58:00 +00:00
);
}
};