merge some things, i think

This commit is contained in:
Jake Howard 2016-02-21 12:05:14 +00:00
parent 388e648b26
commit d2bbd2d34b
7 changed files with 89 additions and 20 deletions

View file

@ -10,4 +10,4 @@ async function set(token) {
return await AsyncStorage.setItem(STORAGE_KEY, token); return await AsyncStorage.setItem(STORAGE_KEY, token);
} }
export default { get, set }; export default { get, set};

View file

@ -3,6 +3,7 @@ import React from 'react-native';
import RouteMaster from './routes/RouteMaster'; import RouteMaster from './routes/RouteMaster';
import RouteMapper from './navigation/RouteMapper'; import RouteMapper from './navigation/RouteMapper';
import GlobalStyles from '../settings/styles'; import GlobalStyles from '../settings/styles';
import BusyIndicator from 'react-native-busy-indicator';
const { const {
Navigator, Navigator,
@ -33,6 +34,7 @@ export default class extends React.Component {
nav={nav} nav={nav}
currentRoute={props.route} currentRoute={props.route}
{...props} /> {...props} />
<BusyIndicator />
</View> </View>
); );
} }

View file

@ -0,0 +1,15 @@
import React from 'react-native';
var {
View,
Text,
StyleSheet,
} = React;
export default class ProjectItem extends React.Component {
render() {
return (
<Text>{this.props.project.reponame}</Text>
);
}
};

View file

@ -0,0 +1,49 @@
import React from 'react-native';
import ProjectItem from './ProjectItem';
var {
ListView,
StyleSheet,
Text,
ScrollView
} = React;
var styles = StyleSheet.create({
composerListView: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
flexWrap: 'wrap',
padding: 15
},
});
export default class ProjectList extends React.Component {
constructor(props) {
super(props);
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
console.log(JSON.stringify(this.props.data));
this.state = {
dataSource: ds.cloneWithRows(this.props.data)
};
this.renderRow = this.renderRow.bind(this);
}
renderRow(project) {
return (
<ProjectItem project={project} />
);
}
render() {
return (
<ScrollView>
<ListView
contentContainerStyle={styles.composerListView}
dataSource={this.state.dataSource}
renderRow={this.renderRow} />
</ScrollView>
);
}
};

View file

@ -1,27 +1,21 @@
import React from 'react-native'; import React from 'react-native';
import { getProjects } from '../../api/CircleCI'; import { getProjects } from '../../api/CircleCI';
import loaderHandler from 'react-native-busy-indicator/LoaderHandler';
import ProjectList from '../projects/ProjectList';
import GlobalStyles from '../../settings/styles';
const { const {
StyleSheet, StyleSheet,
Text, Text,
View, View,
ScrollView,
BackAndroid, BackAndroid,
} = React; } = React;
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
flex: 1, flex: 1,
backgroundColor: '#333', backgroundColor: GlobalStyles.get('CIRCLE_BG'),
}, },
contentWrapper: {
flex: 0.85,
justifyContent: 'flex-start',
alignItems: 'center'
},
text: {
color: 'white'
}
}); });
export default class Home extends React.Component { export default class Home extends React.Component {
@ -39,20 +33,30 @@ export default class Home extends React.Component {
componentWillMount() { componentWillMount() {
BackAndroid.addEventListener('hardwareBackPress', () => true); BackAndroid.addEventListener('hardwareBackPress', () => true);
loaderHandler.showLoader('Fetching Data');
} }
componentDidMount() { componentDidMount() {
getProjects().then(function (data) {
this.setState({
projects: data
});
}.bind(this));
} }
render() { render() {
const data = JSON.stringify(this.state.projects) || 'No Data'; let list;
if (this.state.projects) {
list = (
<ProjectList data={this.state.projects} />
);
loaderHandler.hideLoader();
} else {
list = ( <View /> );
}
return ( return (
<View style={styles.container}> <View style={styles.container}>
<ScrollView keyboardShouldPersistTaps={false} contentContainerStyle={styles.container}> { list }
<View style={styles.contentWrapper}>
<Text style={styles.text}>{data}</Text>
</View>
</ScrollView>
</View> </View>
); );
} }

View file

@ -16,7 +16,8 @@ const styles = StyleSheet.create({
}, },
contentWrapper: { contentWrapper: {
justifyContent: 'flex-start', justifyContent: 'flex-start',
alignItems: 'center' alignItems: 'center',
padding: 10
}, },
text: { text: {
color: GlobalStyles.get('CIRCLE_TEXT') color: GlobalStyles.get('CIRCLE_TEXT')

View file

@ -5,7 +5,6 @@ import RouteMaster from './RouteMaster';
import { checkToken } from '../../api/CircleCI'; import { checkToken } from '../../api/CircleCI';
import token from '../../api/token'; import token from '../../api/token';
import loaderHandler from 'react-native-busy-indicator/LoaderHandler'; import loaderHandler from 'react-native-busy-indicator/LoaderHandler';
import BusyIndicator from 'react-native-busy-indicator';
const dismissKeyboard = require('dismissKeyboard'); const dismissKeyboard = require('dismissKeyboard');
@ -212,7 +211,6 @@ export default class Login extends React.Component {
</TouchableHighlight> </TouchableHighlight>
</View> </View>
<TokenHelp open={this.state.showTokenHelp} onClose={this.hideTokenHelp} /> <TokenHelp open={this.state.showTokenHelp} onClose={this.hideTokenHelp} />
<BusyIndicator />
</View> </View>
); );
} }