Skip to content

Commit

Permalink
publish v3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
crazycodeboy committed Aug 28, 2017
1 parent 040fbcf commit acd8ef9
Show file tree
Hide file tree
Showing 5 changed files with 6,925 additions and 27 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,24 @@ new GitHubTrending().fetchTrending(url)
});
```

TrendingRepoModel
-------

```
export default class TrendingRepoModel {
constructor(fullName, url, description, language, meta, contributors, contributorsUrl, starCount, forkCount) {
this.fullName = fullName;
this.url = url;
this.description = description;
this.language = language;
this.meta = meta;
this.contributors = contributors;
this.contributorsUrl = contributorsUrl;
this.starCount = starCount;
this.forkCount = forkCount;
}
}
```

>More examples can refer to [GitHubPopular](https://github.com/crazycodeboy/GitHubPopular)
73 changes: 48 additions & 25 deletions examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@
*/

import React, {Component} from 'react';
import {
AppRegistry,
StyleSheet,
Text,
TextInput,
View
} from 'react-native';
import GitHubTrending from 'GitHubTrending'
import {ScrollView, StyleSheet, Text, View} from 'react-native';
import GitHubTrending from 'GitHubTrending'

export default class test extends Component {
constructor(props) {
super(props);
this.state = {
data: ''
dataArray: [],
result: "loading"
}
}

Expand All @@ -32,28 +28,51 @@ export default class test extends Component {

test(url) {
new GitHubTrending().fetchTrending(url)
.then((data)=> {
.then((data) => {
this.setState({
data:JSON.stringify(data),
dataArray: data,
result: 'success'
})
}).catch((error)=> {
}).catch((error) => {
this.setState({
data:error,
result: "failure",
})
});
}

render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}
onPress={()=>this.loadData()}
<Text style={styles.button}
onPress={() => this.loadData()}
>
Load Data
</Text>
<Text style={styles.input}>
{this.state.data}
{this.state.result}
</Text>
<ScrollView>
<View style={{flex: 1}}>
{
this.state.dataArray.map((item, index, arr) => {
return <View
style={styles.row}
key={index}>
<Text>fullName:{item.fullName}</Text>
<Text>url:{item.fullName}</Text>
<Text>description:{item.description}</Text>
<Text>language:{item.language}</Text>
<Text>meta:{item.meta}</Text>
<Text>contributors count :{item.contributors.length}</Text>
<Text>contributorsUrl :{item.contributorsUrl}</Text>
<Text>starCount count :{item.starCount}</Text>
<Text>forkCount count :{item.forkCount}</Text>
</View>
})
}
</View>
</ScrollView>

</View>
);
}
Expand All @@ -62,17 +81,21 @@ export default class test extends Component {
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
marginTop: 30

},
row: {
flex: 1,
marginBottom: 10,
borderBottomWidth:1,
borderColor:"gray"
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
button: {
width: 100,
backgroundColor: 'red',
padding: 10
},
input: {
height:200,
backgroundColor:'gray'
backgroundColor: 'gray'
},
});
Loading

0 comments on commit acd8ef9

Please sign in to comment.