-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrendingTest.js
More file actions
73 lines (69 loc) · 1.66 KB
/
TrendingTest.js
File metadata and controls
73 lines (69 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* Created by penn on 2016/12/14.
*/
import React, { Component } from "react";
import {
View,
StyleSheet,
Text,
AsyncStorage,
TextInput,
Button,
TouchableOpacity
} from "react-native";
import Girl from "./Girl";
import NavigationBar from "./js/common/NavigationBar";
import Toast, { DURATION } from "react-native-easy-toast";
import GithubTrending from "./js/util/trending/GitHubTrending";
const URL = "https://github.com/trending/";
export default class TrendingTest extends Component {
constructor(props) {
super(props);
this.trending = new GithubTrending();
this.state = {
result:''
};
}
onLoad() {
let url = URL + this.text;
this.trending.fetchTrending(url).then(result => {
this.setState({
result:JSON.stringify(result),
})
}).catch(error=>{
this.setState({
result:JSON.stringify(error)
})
})
}
render() {
return (
<View style={styles.container}>
<NavigationBar
title="GithubTrending"
style={{ backgroundColor: "#6495ED" }}
/>
<TextInput
style={{ borderWidth: 1, height: 40, margin: 6 }}
onChangeText={text => (this.text = text)}
/>
<View style={{ flexDirection: "row" }}>
<TouchableOpacity onPress={() => this.onLoad()}>
<Text style={styles.tips}>加载数据</Text>
</TouchableOpacity>
</View>
<Text style={{height:600}}>{this.state.result}</Text>
<Toast ref={toast => (this.toast = toast)} />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1
},
tips: {
fontSize: 29,
margin: 5
}
});