1
+ import React , { Component } from 'react' ;
2
+ import {
3
+ StyleSheet ,
4
+ Text ,
5
+ View ,
6
+ ListView ,
7
+ Image ,
8
+ Dimensions ,
9
+ AlertIOS
10
+ } from 'react-native' ;
11
+ import Icon from 'react-native-vector-icons/Ionicons' ;
12
+
13
+ import News from './news.js'
14
+
15
+
16
+ import Header from './header.js'
17
+
18
+ const { width, height} = Dimensions . get ( 'window' ) ;
19
+
20
+ class Home extends Component {
21
+ constructor ( props ) {
22
+ super ( props ) ;
23
+
24
+ var ds = new ListView . DataSource ( { rowHasChanged : ( r1 , r2 ) => r1 !== r2 } ) ;
25
+ var data = [
26
+ {
27
+ "id" : "54000019900401137X" ,
28
+ "img" : "http://dummyimage.com/1280x768/b5523b" ,
29
+ "title" : "Gqpvkv Klwmmxpk Ufxld Phkuwhcy"
30
+ } ,
31
+ {
32
+ "id" : "540000198803081433" ,
33
+ "img" : "http://dummyimage.com/1280x768/c80f23" ,
34
+ "title" : "Inkkg Ckpns Rhevir VfoudLviioyd Wfgwite Uhuyszoka"
35
+ } ,
36
+ {
37
+ "id" : "230000197410118592" ,
38
+ "img" : "http://dummyimage.com/1280x768/babc54" ,
39
+ "title" : "Mudvcb Nbkl Abg Thkp Nbw BneHjmuwnigt Tmg Tkcttcusp Ojfyeyysgp"
40
+ } ,
41
+ {
42
+ "id" : "530000199803284823" ,
43
+ "img" : "http://dummyimage.com/1280x768/ed6c02" ,
44
+ "title" : "Etxmi Cqpjgr Txibn Wufojjdcvj Rzjkn"
45
+ } ,
46
+ {
47
+ "id" : "340000197911205980" ,
48
+ "img" : "http://dummyimage.com/1280x768/6e10b8" ,
49
+ "title" : "Lrdvybtj Dimwgqslgk Jmzlxy Tvxia Wzebvsfbz Bleywe"
50
+ } ,
51
+ {
52
+ "id" : "520000200310174574" ,
53
+ "img" : "http://dummyimage.com/1280x768/410cbd" ,
54
+ "title" : "Pwo Ihcf Iybpssfbw Fgnqyiluic Fxipb"
55
+ } ,
56
+ {
57
+ "id" : "350000200502166040" ,
58
+ "img" : "http://dummyimage.com/1280x768/d2a04c" ,
59
+ "title" : "Csguqzn Gtmf Lhewpmyr Mqgi Hprn"
60
+ } ,
61
+ {
62
+ "id" : "350000201502060224" ,
63
+ "img" : "http://dummyimage.com/1280x768/4bf2aa" ,
64
+ "title" : "Ivboggg Sizvmdpsx Ebbn FwxhjIdaf Nkssufhe Ojdwhjo Uyjjlxx"
65
+ }
66
+ ] ;
67
+ this . state = {
68
+ dataSource : ds . cloneWithRows ( data ) ,
69
+ } ;
70
+ }
71
+ _changePage = ( rowItem ) => {
72
+ this . props . navigator . push ( {
73
+ name :'news' ,
74
+ component :News ,
75
+ passProps :{
76
+ data :rowItem
77
+ }
78
+ } ) ;
79
+ }
80
+ _renderRow = ( rowItem ) => {
81
+ return ( < View style = { styles . rowBox } >
82
+ < View style = { styles . title } >
83
+ < Text > { rowItem . title } </ Text >
84
+ </ View >
85
+ < View >
86
+ < Image resizeMode = "cover" source = { { uri :rowItem . img } } style = { styles . img } />
87
+ < Icon onPress = { this . _changePage . bind ( this , rowItem ) } style = { styles . icon } size = { 100 } name = "ios-play" color = "#4F8EF7" />
88
+ </ View >
89
+ </ View > )
90
+ }
91
+
92
+ render ( ) {
93
+ return ( < View style = { styles . container } >
94
+ < Header title = "Home" />
95
+ < ListView
96
+ dataSource = { this . state . dataSource }
97
+ renderRow = { this . _renderRow }
98
+ automaticallyAdjustContentInsets = { false }
99
+ showsVerticalScrollIndicator = { false }
100
+ />
101
+ </ View > )
102
+ }
103
+ }
104
+
105
+ const styles = StyleSheet . create ( {
106
+ icon :{
107
+ position :'absolute' ,
108
+ backgroundColor :'transparent' ,
109
+ left :( width ) / 2 ,
110
+ top :( width * 0.6 - 100 ) / 2
111
+ } ,
112
+ img :{
113
+ width :width ,
114
+ height :width * 0.6
115
+ } ,
116
+ container :{
117
+ flex :1 ,
118
+ backgroundColor :'#fff' ,
119
+ marginTop :20
120
+ } ,
121
+ rowBox :{
122
+ alignItems :'center' ,
123
+ justifyContent :'center'
124
+ } ,
125
+ title :{
126
+ height :40 ,
127
+ alignItems :'center' ,
128
+ justifyContent :'center'
129
+ }
130
+ } ) ;
131
+
132
+
133
+ export default Home ;
0 commit comments