This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
Sphere/app/components/routes/home.js

63 lines
1.3 KiB
JavaScript

import React from 'react-native';
import { getProjects } from '../../api/CircleCI';
import loaderHandler from 'react-native-busy-indicator/LoaderHandler';
import ProjectList from '../projects/ProjectList';
import GlobalStyles from '../../settings/styles';
const {
StyleSheet,
Text,
View,
BackAndroid,
} = React;
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: GlobalStyles.get('CIRCLE_BG'),
},
});
export default class Home extends React.Component {
constructor() {
super();
this.state = {
projects: ''
};
}
componentWillUnmount() {
BackAndroid.removeEventListener('hardwareBackPress', () => true);
}
componentWillMount() {
BackAndroid.addEventListener('hardwareBackPress', () => true);
loaderHandler.showLoader('Fetching Data');
}
componentDidMount() {
getProjects().then(function (data) {
this.setState({
projects: data
});
}.bind(this));
}
render() {
let list;
if (this.state.projects) {
list = (
<ProjectList data={this.state.projects} />
);
loaderHandler.hideLoader();
} else {
list = ( <View /> );
}
return (
<View style={styles.container}>
{ list }
</View>
);
}
};