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() {
if (this.props.nav.getCurrentRoutes().length <= 1) {
return <View />;
}
return (
<View style={styles.container}>
<TouchableHighlight

View file

@ -26,7 +26,9 @@ const styles = StyleSheet.create({
export default class InfoButton extends React.Component {
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() {
return (

View file

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

View file

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

View file

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