1
- import React , { Component } from 'react' ;
1
+ import React , { Component } from 'react'
2
2
import {
3
3
View ,
4
4
Text ,
@@ -7,117 +7,117 @@ import {
7
7
Image ,
8
8
ListView ,
9
9
RefreshControl
10
- } from 'react-native' ;
10
+ } from 'react-native'
11
11
import NavigationBar from './NavigationBar'
12
- import Toast , { DURATION } from 'react-native-easy-toast'
12
+ import Toast , { DURATION } from 'react-native-easy-toast'
13
13
14
14
var data = {
15
- " result" : [
15
+ ' result' : [
16
16
{
17
- " email" : " laclys@126.com" ,
18
- " fullName" : " Lac"
17
+ ' email' : ' laclys@126.com' ,
18
+ ' fullName' : ' Lac'
19
19
} , {
20
- " email" : " sylcal@126.com" ,
21
- " fullName" : " Cal"
20
+ ' email' : ' sylcal@126.com' ,
21
+ ' fullName' : ' Cal'
22
22
} , {
23
- " email" : " zyy@126.com" ,
24
- " fullName" : " Zyy"
23
+ ' email' : ' zyy@126.com' ,
24
+ ' fullName' : ' Zyy'
25
25
} , {
26
- " email" : " 421084802@126.com" ,
27
- " fullName" : " Zhang"
26
+ ' email' : ' 421084802@126.com' ,
27
+ ' fullName' : ' Zhang'
28
28
} , {
29
- " email" : " yoyo@126.com" ,
30
- " fullName" : " Yoyo"
29
+ ' email' : ' yoyo@126.com' ,
30
+ ' fullName' : ' Yoyo'
31
31
} , {
32
- " email" : " 123321@126.com" ,
33
- " fullName" : " Bill"
32
+ ' email' : ' 123321@126.com' ,
33
+ ' fullName' : ' Bill'
34
34
} , {
35
- " email" : " swonwhite@126.com" ,
36
- " fullName" : " Swon"
35
+ ' email' : ' swonwhite@126.com' ,
36
+ ' fullName' : ' Swon'
37
37
} , {
38
- " email" : " Mac@126.com" ,
39
- " fullName" : " Mac"
38
+ ' email' : ' Mac@126.com' ,
39
+ ' fullName' : ' Mac'
40
40
} , {
41
- " email" : " laclys1@126.com" ,
42
- " fullName" : " Lac"
41
+ ' email' : ' laclys1@126.com' ,
42
+ ' fullName' : ' Lac'
43
43
} , {
44
- " email" : " sylcal1@126.com" ,
45
- " fullName" : " Cal"
44
+ ' email' : ' sylcal1@126.com' ,
45
+ ' fullName' : ' Cal'
46
46
} , {
47
- " email" : " zyy1@126.com" ,
48
- " fullName" : " Zyy"
47
+ ' email' : ' zyy1@126.com' ,
48
+ ' fullName' : ' Zyy'
49
49
} , {
50
- " email" : " 4210848021@126.com" ,
51
- " fullName" : " Zhang"
50
+ ' email' : ' 4210848021@126.com' ,
51
+ ' fullName' : ' Zhang'
52
52
} , {
53
- " email" : " yoyo1@126.com" ,
54
- " fullName" : " Yoyo"
53
+ ' email' : ' yoyo1@126.com' ,
54
+ ' fullName' : ' Yoyo'
55
55
} , {
56
- " email" : " 1233211@126.com" ,
57
- " fullName" : " Bill"
56
+ ' email' : ' 1233211@126.com' ,
57
+ ' fullName' : ' Bill'
58
58
} , {
59
- " email" : " swonwhite1@126.com" ,
60
- " fullName" : " Swon"
59
+ ' email' : ' swonwhite1@126.com' ,
60
+ ' fullName' : ' Swon'
61
61
} , {
62
- " email" : " Mac1@126.com" ,
63
- " fullName" : " Mac"
62
+ ' email' : ' Mac1@126.com' ,
63
+ ' fullName' : ' Mac'
64
64
}
65
65
] ,
66
- " statusCode" : 0
67
- } ;
66
+ ' statusCode' : 0
67
+ }
68
68
69
69
export default class ListViewTest extends Component {
70
- constructor ( props ) {
71
- super ( props ) ;
70
+ constructor ( props ) {
71
+ super ( props )
72
72
const ds = new ListView . DataSource ( {
73
73
rowHasChanged : ( r1 , r2 ) => r1 !== r2
74
74
} )
75
75
this . state = {
76
76
dataScource : ds . cloneWithRows ( data . result ) ,
77
- isLoading :true ,
77
+ isLoading : true
78
78
}
79
- this . onLoad ( ) ;
79
+ this . onLoad ( )
80
80
}
81
- renderRow ( item , sectionID , rowID , highlightRow ) {
81
+ renderRow ( item , sectionID , rowID , highlightRow ) {
82
82
return < View key = { rowID } style = { styles . row } >
83
83
< TouchableOpacity
84
- onPress = { ( ) => {
85
- this . toast . show ( 'clicked!' + item . fullName , DURATION . LENGTH_LONG )
84
+ onPress = { ( ) => {
85
+ this . toast . show ( 'clicked!' + item . fullName , DURATION . LENGTH_LONG )
86
86
} }
87
87
>
88
88
< Text style = { styles . text } > { item . fullName } </ Text >
89
89
< Text style = { styles . text } > { item . email } </ Text >
90
90
</ TouchableOpacity >
91
91
</ View >
92
92
}
93
- renderSeparator ( sectionID , rowID , adjacentRowHighlighted ) {
94
- return < View key = { rowID } style = { styles . line } > </ View >
93
+ renderSeparator ( sectionID , rowID , adjacentRowHighlighted ) {
94
+ return < View key = { rowID } style = { styles . line } / >
95
95
}
96
- renderFooter ( ) {
97
- return < Image style = { { width :50 , height :50 } } source = { { uri :'https://avatars1.githubusercontent.com/u/22010181?v=3&s=460' } } />
96
+ renderFooter ( ) {
97
+ return < Image style = { { width : 50 , height : 50 } } source = { { uri : 'https://avatars1.githubusercontent.com/u/22010181?v=3&s=460' } } />
98
98
}
99
- onLoad ( ) {
100
- setTimeout ( ( ) => {
99
+ onLoad ( ) {
100
+ setTimeout ( ( ) => {
101
101
this . setState ( {
102
- isLoading :false
102
+ isLoading : false
103
103
} )
104
- } , 2000 ) ;
104
+ } , 2000 )
105
105
}
106
- render ( ) {
106
+ render ( ) {
107
107
return (
108
108
< View style = { styles . container } >
109
- < NavigationBar title = { 'ListViewTest' } />
109
+ < NavigationBar title = { 'ListViewTest' } />
110
110
< ListView
111
111
dataSource = { this . state . dataScource }
112
- renderRow = { ( item , sectionID , rowID , highlightRow ) => this . renderRow ( item , sectionID , rowID , highlightRow ) }
113
- renderSeparator = { ( sectionID , rowID , adjacentRowHighlighted ) => this . renderSeparator ( sectionID , rowID , adjacentRowHighlighted ) }
114
- renderFooter = { ( ) => this . renderFooter ( ) }
112
+ renderRow = { ( item , sectionID , rowID , highlightRow ) => this . renderRow ( item , sectionID , rowID , highlightRow ) }
113
+ renderSeparator = { ( sectionID , rowID , adjacentRowHighlighted ) => this . renderSeparator ( sectionID , rowID , adjacentRowHighlighted ) }
114
+ renderFooter = { ( ) => this . renderFooter ( ) }
115
115
refreshControl = { < RefreshControl
116
116
refreshing = { this . state . isLoading }
117
- onRefresh = { ( ) => this . onLoad ( ) }
117
+ onRefresh = { ( ) => this . onLoad ( ) }
118
118
/> }
119
119
/>
120
- < Toast ref = { toast => { this . toast = toast } } />
120
+ < Toast ref = { toast => { this . toast = toast } } />
121
121
</ View >
122
122
)
123
123
}
@@ -134,8 +134,8 @@ const styles = StyleSheet.create({
134
134
row : {
135
135
height : 50
136
136
} ,
137
- line :{
138
- height :1 ,
139
- backgroundColor :'black'
137
+ line : {
138
+ height : 1 ,
139
+ backgroundColor : 'black'
140
140
}
141
- } )
141
+ } )
0 commit comments