From d18946164834c7a3b19086284202f015d21645eb Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 11 Feb 2016 20:45:40 +0000 Subject: [PATCH] A load of --- app/components/navigation/BackButton.js | 3 -- app/components/navigation/InfoButton.js | 4 ++- app/components/navigation/RouteMapper.js | 13 ++++---- app/components/routes/home.js | 19 +++++++++++- app/components/routes/login.js | 39 +++++++++++++----------- 5 files changed, 50 insertions(+), 28 deletions(-) diff --git a/app/components/navigation/BackButton.js b/app/components/navigation/BackButton.js index b61ca40..42daf81 100644 --- a/app/components/navigation/BackButton.js +++ b/app/components/navigation/BackButton.js @@ -27,9 +27,6 @@ export default class NavigationButton extends React.Component { } render() { - if (this.props.nav.getCurrentRoutes().length <= 1) { - return ; - } return ( ; + } + return ( ); }, RightButton(route, nav, index, navState) { - if (route.id === 'login'&& route.id !== 'info') { - return ; + if (route.id === 'login') { + return ; } - return ( - - ); + return ; }, Title(route, nav, index, navState) { diff --git a/app/components/routes/home.js b/app/components/routes/home.js index b93b04c..6d5a6f5 100644 --- a/app/components/routes/home.js +++ b/app/components/routes/home.js @@ -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 ( - Home + {data} diff --git a/app/components/routes/login.js b/app/components/routes/login.js index 535d478..ac0c1a5 100644 --- a/app/components/routes/login.js +++ b/app/components/routes/login.js @@ -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() {