diff --git a/app/components/routes/RouteMaster.js b/app/components/routes/RouteMaster.js
index 78b67ae..95fbcb3 100644
--- a/app/components/routes/RouteMaster.js
+++ b/app/components/routes/RouteMaster.js
@@ -2,6 +2,7 @@ import { Map } from 'immutable';
import Login from './login';
import Info from './info';
+import Home from './home';
export default Map({
'LOGIN': {
@@ -11,5 +12,9 @@ export default Map({
'INFO': {
id: 'info',
component: Info
+ },
+ 'HOME': {
+ id: 'home',
+ component: Home
}
});
diff --git a/app/components/routes/home.js b/app/components/routes/home.js
new file mode 100644
index 0000000..b93b04c
--- /dev/null
+++ b/app/components/routes/home.js
@@ -0,0 +1,47 @@
+import React from 'react-native';
+
+const {
+ StyleSheet,
+ Text,
+ View,
+ ScrollView,
+ BackAndroid,
+} = React;
+
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: '#333',
+ },
+ contentWrapper: {
+ flex: 0.85,
+ justifyContent: 'flex-start',
+ alignItems: 'center'
+ },
+ text: {
+ color: 'white'
+ }
+});
+
+export default class Home extends React.Component {
+
+ componentWillUnmount() {
+ BackAndroid.removeEventListener('hardwareBackPress', () => true);
+ }
+
+ componentWillMount() {
+ BackAndroid.addEventListener('hardwareBackPress', () => true);
+ }
+
+ render() {
+ return (
+
+
+
+ Home
+
+
+
+ );
+ }
+};
diff --git a/app/components/routes/login.js b/app/components/routes/login.js
index 1b4d11e..c47be3b 100644
--- a/app/components/routes/login.js
+++ b/app/components/routes/login.js
@@ -2,6 +2,11 @@ import React from 'react-native';
import GlobalStyles from '../../settings/styles';
import TokenHelp from '../login/token-help';
import RouteMaster from './RouteMaster';
+import { checkToken } from '../../api/CircleCI';
+import { set } from '../../api/token';
+import loaderHandler from 'react-native-busy-indicator/LoaderHandler';
+import BusyIndicator from 'react-native-busy-indicator';
+
const dismissKeyboard = require('dismissKeyboard');
@@ -13,7 +18,8 @@ const {
TouchableHighlight,
ScrollView,
BackAndroid,
- TouchableWithoutFeedback
+ TouchableWithoutFeedback,
+ Alert
} = React;
const styles = StyleSheet.create({
@@ -89,14 +95,36 @@ export default class Login extends React.Component {
this.showTokenHelp = this.showTokenHelp.bind(this);
this.hideTokenHelp = this.hideTokenHelp.bind(this);
this.showAbout = this.showAbout.bind(this);
+ this.proceed = this.proceed.bind(this);
}
textChanged(token) {
this.setState({ token });
}
+ proceed() {
+ this.props.nav.push(RouteMaster.get('HOME'));
+ }
+
validate() {
+ loaderHandler.showLoader('Loading');
dismissKeyboard();
+ checkToken(this.state.token).then(function (isValid) {
+ if (isValid) {
+ Alert.alert('Valid',
+ 'Token accepted!',
+ [ {text: 'OK' }]);
+ set(this.state.token).then(this.proceed);
+ } else {
+ Alert.alert('Invalid',
+ 'Token not accepted!',
+ [ {text: 'Return' }]);
+ this.setState({
+ token: ''
+ });
+ }
+ loaderHandler.hideLoader();
+ }.bind(this));
}
showAbout() {
@@ -172,6 +200,7 @@ export default class Login extends React.Component {
+
);
}
diff --git a/package.json b/package.json
index 8957d33..0c8b9fc 100644
--- a/package.json
+++ b/package.json
@@ -10,6 +10,7 @@
"dependencies": {
"immutable": "=3.7.6",
"react-native": "=0.19.0",
+ "react-native-busy-indicator": "=1.0.6",
"react-native-modalbox": "=1.2.8",
"react-native-side-menu": "=0.18.0",
"react-native-vector-icons": "=1.0.4",