A load of

This commit is contained in:
Jake Howard 2016-02-11 20:45:40 +00:00
parent 7a688bb016
commit d189461648
5 changed files with 50 additions and 28 deletions

View file

@ -27,9 +27,6 @@ export default class NavigationButton extends React.Component {
} }
render() { render() {
if (this.props.nav.getCurrentRoutes().length <= 1) {
return <View />;
}
return ( return (
<View style={styles.container}> <View style={styles.container}>
<TouchableHighlight <TouchableHighlight

View file

@ -26,7 +26,9 @@ const styles = StyleSheet.create({
export default class InfoButton extends React.Component { export default class InfoButton extends React.Component {
showInfo() { showInfo() {
this.props.nav.push(RouteMaster.get('INFO')); if (this.props.route.id !== RouteMaster.get('INFO').id) {
this.props.nav.push(RouteMaster.get('INFO'));
}
} }
render() { render() {
return ( return (

View file

@ -6,22 +6,23 @@ import NavigationInfoButton from './InfoButton';
import { View } from 'react-native'; import { View } from 'react-native';
export default { export default {
LeftButton(route, nav, index, navState) { LeftButton(route, nav, index, navState) {
if (index === 0) {
return <View />;
}
return ( return (
<NavigationBackButton nav={nav} /> <NavigationBackButton nav={nav} />
); );
}, },
RightButton(route, nav, index, navState) { RightButton(route, nav, index, navState) {
if (route.id === 'login'&& route.id !== 'info') { if (route.id === 'login') {
return <NavigationInfoButton nav={nav} />; return <NavigationInfoButton nav={nav} route={route} />;
} }
return ( return <View />;
<View />
);
}, },
Title(route, nav, index, navState) { Title(route, nav, index, navState) {

View file

@ -1,4 +1,5 @@
import React from 'react-native'; import React from 'react-native';
import { getProjects } from '../../api/CircleCI';
const { const {
StyleSheet, StyleSheet,
@ -24,6 +25,13 @@ const styles = StyleSheet.create({
}); });
export default class Home extends React.Component { export default class Home extends React.Component {
constructor() {
super();
this.state = {
projects: ''
};
}
componentWillUnmount() { componentWillUnmount() {
BackAndroid.removeEventListener('hardwareBackPress', () => true); BackAndroid.removeEventListener('hardwareBackPress', () => true);
@ -33,12 +41,21 @@ export default class Home extends React.Component {
BackAndroid.addEventListener('hardwareBackPress', () => true); BackAndroid.addEventListener('hardwareBackPress', () => true);
} }
componentDidMount() {
getProjects().then(function (data) {
this.setState({
projects: data
});
}.bind(this)).catch(console.log);
}
render() { render() {
const data = JSON.stringify(this.state.projects);
return ( return (
<View style={styles.container}> <View style={styles.container}>
<ScrollView keyboardShouldPersistTaps={false} contentContainerStyle={styles.container}> <ScrollView keyboardShouldPersistTaps={false} contentContainerStyle={styles.container}>
<View style={styles.contentWrapper}> <View style={styles.contentWrapper}>
<Text style={styles.text}>Home</Text> <Text style={styles.text}>{data}</Text>
</View> </View>
</ScrollView> </ScrollView>
</View> </View>

View file

@ -29,13 +29,12 @@ const styles = StyleSheet.create({
}, },
contentWrapper: { contentWrapper: {
flex: 0.85, flex: 0.85,
justifyContent: 'flex-start', justifyContent: 'center',
alignItems: 'center' alignItems: 'center'
}, },
input: { input: {
marginHorizontal: 10, fontSize: 13,
fontSize: 15, marginHorizontal: 15,
textAlign: 'center'
}, },
loginButton: { loginButton: {
flex: 0.92, flex: 0.92,
@ -60,23 +59,20 @@ const styles = StyleSheet.create({
margin: 5 margin: 5
}, },
heading: { heading: {
fontSize: 18, fontSize: 15,
margin: 8,
marginTop: 20
}, },
helpText: { helpText: {
fontSize: 11, fontSize: 10,
fontStyle: 'italic', fontStyle: 'italic',
margin: 5,
padding: 5, padding: 5,
marginBottom: 50
}, },
text: { text: {
color: GlobalStyles.get('CIRCLE_TEXT') color: GlobalStyles.get('CIRCLE_TEXT'),
}, },
icon: { icon: {
flex: 1, height: 65,
margin: 15, marginBottom: 50
marginVertical: 35
} }
}); });
@ -104,22 +100,31 @@ export default class Login extends React.Component {
this.props.nav.push(RouteMaster.get('HOME')); this.props.nav.push(RouteMaster.get('HOME'));
} }
invalidToken() {
Alert.alert('Invalid',
'Token not accepted!',
[ {text: 'Return' }]);
}
validate() { validate() {
loaderHandler.showLoader('Loading'); loaderHandler.showLoader('Loading');
dismissKeyboard(); dismissKeyboard();
if (!this.state.token) {
this.invalidToken();
loaderHandler.hideLoader();
return;
}
checkToken(this.state.token).then(function (isValid) { checkToken(this.state.token).then(function (isValid) {
if (isValid) { if (isValid) {
set(this.state.token).then(this.proceed); set(this.state.token).then(this.proceed);
} else { } else {
Alert.alert('Invalid', this.invalidToken();
'Token not accepted!',
[ {text: 'Return' }]);
this.setState({ this.setState({
token: '' token: ''
}); });
} }
loaderHandler.hideLoader(); loaderHandler.hideLoader();
}.bind(this)); }.bind(this)).catch(console.log);
} }
showAbout() { showAbout() {