Added help modal

This commit is contained in:
Jake Howard 2016-02-02 22:26:55 +00:00
parent af2da9ea19
commit 4798ddd3df
4 changed files with 106 additions and 15 deletions

View file

@ -0,0 +1,54 @@
import React from 'react-native';
import GlobalStyles from '../../settings/styles';
import Modal from 'react-native-modalbox';
const {
StyleSheet,
Text,
View
} = React;
const styles = StyleSheet.create({
modal: {
justifyContent: 'center',
alignItems: 'center',
backgroundColor: GlobalStyles.get('CIRCLE_GREY_DARK'),
height: 300
},
title: {
fontSize: 18,
color: 'white'
},
text: {
fontSize: 13,
color: 'white'
},
modalView: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
}
});
export default class Login extends React.Component {
render() {
return (
<Modal
isOpen={this.props.open}
style={styles.modal}
backdrop={true}>
<View style={styles.modalView}>
<Text style={styles.title}>
What is a token?
</Text>
<Text style={styles.text}>
A token is a thing.
</Text>
</View>
<Text style={styles.text}>
Swipe down to dismiss
</Text>
</Modal>
);
}
};

View file

@ -1,5 +1,8 @@
import React from 'react-native'; import React from 'react-native';
import GlobalStyles from '../../settings/styles'; import GlobalStyles from '../../settings/styles';
import TokenHelp from '../login/token-help';
var dismissKeyboard = require('dismissKeyboard');
const { const {
StyleSheet, StyleSheet,
@ -8,13 +11,14 @@ const {
TextInput, TextInput,
TouchableHighlight, TouchableHighlight,
ScrollView, ScrollView,
BackAndroid BackAndroid,
TouchableWithoutFeedback
} = React; } = React;
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
flex: 1, flex: 1,
backgroundColor: '#F5FCFF', backgroundColor: GlobalStyles.get('CIRCLE_GREY_DARK'),
}, },
contentWrapper: { contentWrapper: {
flex: 0.85, flex: 0.85,
@ -28,10 +32,13 @@ const styles = StyleSheet.create({
}, },
loginButton: { loginButton: {
flex: 1, flex: 1,
backgroundColor: GlobalStyles.get('CIRCLE_BLUE'), backgroundColor: GlobalStyles.get('CIRCLE_GREEN'),
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
padding: 10 padding: 10,
borderColor: GlobalStyles.get('CIRCLE_GREEN'),
borderWidth: 2,
borderRadius: 12
}, },
loginButtonText: { loginButtonText: {
fontSize: 18, fontSize: 18,
@ -53,7 +60,11 @@ const styles = StyleSheet.create({
marginVertical: 20 marginVertical: 20
}, },
helpText: { helpText: {
fontSize: 12, fontSize: 11,
fontStyle: 'italic'
},
text: {
color: 'white'
} }
}); });
@ -61,10 +72,13 @@ export default class Login extends React.Component {
constructor() { constructor() {
super(); super();
this.state = { this.state = {
token: '' token: '',
showTokenHelp: false
}; };
this.validate = this.validate.bind(this); this.validate = this.validate.bind(this);
this.updateState = this.updateState.bind(this); this.updateState = this.updateState.bind(this);
this.showTokenHelp = this.showTokenHelp.bind(this);
this.hideTokenHelp = this.hideTokenHelp.bind(this);
} }
updateState(key, value) { updateState(key, value) {
@ -74,6 +88,20 @@ export default class Login extends React.Component {
} }
validate() { validate() {
dismissKeyboard();
}
showTokenHelp() {
dismissKeyboard();
this.setState({
showTokenHelp: true
});
}
hideTokenHelp() {
this.setState({
showTokenHelp: false
});
} }
componentWillUnmount() { componentWillUnmount() {
@ -88,35 +116,42 @@ export default class Login extends React.Component {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<View style={styles.buttonContainer}> <View style={styles.buttonContainer}>
<Text style={styles.title}> <Text style={[styles.title, styles.text]}>
Sphere Sphere
</Text> </Text>
</View> </View>
<ScrollView keyboardShouldPersistTaps={false} contentContainerStyle={styles.container}> <ScrollView keyboardShouldPersistTaps={false} contentContainerStyle={styles.container}>
<View style={styles.contentWrapper}> <View style={styles.contentWrapper}>
<Text style={styles.heading}> <Text style={[styles.heading, styles.text]}>
Please enter your CircleCI token Please enter your CircleCI token
</Text> </Text>
<TextInput <TextInput
style={styles.input} style={[styles.input, styles.text]}
onChangeText={(token) => this.updateState('token', token)} onChangeText={(token) => this.updateState('token', token)}
value={this.state.token} value={this.state.token}
onSubmitEditing={this.validate} onSubmitEditing={this.validate}
placeholder="CircleCI Token" placeholder="CircleCI Token"
placeholderTextColor="#A7A7A7"
autoCorrect={false} autoCorrect={false}
/> />
<Text style={styles.helpText}> <TouchableWithoutFeedback onPress={this.showTokenHelp}>
What's this? <Text style={[styles.helpText, styles.text]}>
</Text> What's this?
</Text>
</TouchableWithoutFeedback>
</View> </View>
</ScrollView> </ScrollView>
<View style={styles.buttonContainer}> <View style={styles.buttonContainer}>
<TouchableHighlight style={styles.loginButton} onPress={this.validate}> <TouchableHighlight
<Text style={styles.loginButtonText}> style={styles.loginButton}
onPress={this.validate}
underlayColor={GlobalStyles.get('CIRCLE_GREY_DARK')}>
<Text style={[styles.loginButtonText, styles.text]}>
Authenticate Authenticate
</Text> </Text>
</TouchableHighlight> </TouchableHighlight>
</View> </View>
<TokenHelp open={this.state.showTokenHelp} onClose={this.hideTokenHelp} />
</View> </View>
); );
} }

View file

@ -1,5 +1,6 @@
import { Map } from 'immutable'; import { Map } from 'immutable';
export default Map({ export default Map({
CIRCLE_BLUE: 'blue' CIRCLE_GREEN: '#229922',
CIRCLE_GREY_DARK: '#343434'
}); });

View file

@ -11,6 +11,7 @@
"circleci": "=0.3.0", "circleci": "=0.3.0",
"immutable": "=3.7.6", "immutable": "=3.7.6",
"react-native": "=0.19.0", "react-native": "=0.19.0",
"react-native-modalbox": "=1.2.8",
"react-native-side-menu": "=0.18.0", "react-native-side-menu": "=0.18.0",
"react-native-vector-icons": "=1.0.4", "react-native-vector-icons": "=1.0.4",
"underscore": "=1.8.3" "underscore": "=1.8.3"