22 * Created by zhaohang on 2016/7/25.
33 */
44import React , { Component } from 'react' ;
5- import { View , Text , StyleSheet , TextInput , Image , ListView , TouchableHighlight } from "react-native" ;
5+ import { View , Text , StyleSheet , TextInput , Image , ListView } from "react-native" ;
66import { connect } from 'react-redux'
77import Button from "react-native-button" ;
88import Swipeout from "react-native-swipeout" ;
9- import listViewActions from '../../actions/listViewActions '
9+ import loginActions from '../../actions/loginActions '
1010import { bindActionCreators } from 'redux'
1111const styles = StyleSheet . create ( {
1212 row : {
@@ -34,42 +34,27 @@ const styles = StyleSheet.create({
3434class listView extends Component {
3535 constructor ( props ) {
3636 super ( props ) ;
37- // let ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
37+ let ds = new ListView . DataSource ( { rowHasChanged : ( r1 , r2 ) => r1 !== r2 } ) ;
3838 this . state = {
39-
39+ dataSource :ds . cloneWithRows ( [ {
40+ url : '../image/logo.png' , title : '第四代活塞,谁发的第四代活塞,谁发的第四代活塞,谁发的' , author : '张三' , data : '2016-01-01'
41+ } , {
42+ url : '/src/image/login.png' ,
43+ title : '库克将怒火几年级' ,
44+ author : 'lily' ,
45+ data : '2016-08-08'
46+ } ] )
4047 } ;
41- this . getAllList = this . getAllList . bind ( this ) ;
42- this . pressRow = this . pressRow . bind ( this ) ;
43- }
44- componentWillReceiveProps ( nextProps ) {
45- this . setState ( {
46-
47- } ) ;
48- }
49-
50- componentWillMount ( ) {
51- //控件加载的时候先发起服务请求
52- this . props . getListRequest ( 1 ) ;
53- }
54- pressRow ( id ) {
55- this . props . toDesOfList ( id ) ;
56- }
57- getAllList ( aa ) {
58- alert ( aa ) ;
5948 }
6049 render ( ) {
61- let data = this . props . state . listData ;
62- let ds = new ListView . DataSource ( { rowHasChanged : ( r1 , r2 ) => r1 !== r2 } ) ;
63- let dataSource = ds . cloneWithRows ( data ) ;
6450 return (
65- < ListView enableEmptySections = { true } onEndReached = { this . getAllList } onEndReachedThreshold = { 20 }
66- dataSource = { dataSource }
51+ < ListView
52+ dataSource = { this . state . dataSource }
6753 renderRow = { ( rowData ) =>
68- < Swipeout right = { [ { text :'删除' , backgroundColor :'red' } ] } backgroundColor = { '#FFF' } >
69- < TouchableHighlight onPress = { ( ) => this . pressRow ( rowData . id ) } >
54+ < Swipeout right = { [ { text :'删除' , backgroundColor :'red' } ] } backgroundColor = { '#FFF' } >
7055 < View style = { styles . row } >
7156 < View >
72- < Image style = { styles . thumb } source = { { uri : rowData . image } } />
57+ < Image style = { styles . thumb } source = { require ( '../../ image/login.png' ) } />
7358 </ View >
7459 < View >
7560 < View >
@@ -79,15 +64,12 @@ class listView extends Component {
7964 </ View >
8065 < View >
8166 < Text style = { styles . desc } >
82- { rowData . author } { rowData . date }
67+ { rowData . author } { rowData . data }
8368 </ Text >
8469 </ View >
8570 </ View >
8671 </ View >
87- </ TouchableHighlight >
8872 </ Swipeout >
89-
90-
9173 }
9274 />
9375 ) ;
@@ -96,12 +78,13 @@ class listView extends Component {
9678
9779function mapStateToProps ( state ) {
9880 return {
99- state :state . listViewReducer
81+ state :{
82+ }
10083 }
10184}
10285
10386function mapDispatchToProps ( dispatch ) {
104- return bindActionCreators ( listViewActions , dispatch ) ;
87+ return bindActionCreators ( loginActions , dispatch ) ;
10588}
10689
10790export default connect (
0 commit comments