@@ -6,6 +6,8 @@ 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 loginActions from '../../actions/loginActions'
10+ import { bindActionCreators } from 'redux'
911const styles = StyleSheet . create ( {
1012 row : {
1113 borderBottomColor : '#E0E0E0' ,
@@ -29,20 +31,26 @@ const styles = StyleSheet.create({
2931 marginLeft : 3
3032 }
3133} ) ;
32- const listView = ( props ) => {
33- const ds = new ListView . DataSource ( { rowHasChanged : ( r1 , r2 ) => r1 !== r2 } ) ;
34- const dataSource = ds . cloneWithRows ( [ {
35- url : '../image/logo.png' , title : '第四代活塞,谁发的第四代活塞,谁发的第四代活塞,谁发的' , author : '张三' , data : '2016-01-01'
36- } , {
37- url : '/src/image/login.png' ,
38- title : '库克将怒火几年级' ,
39- author : 'lily' ,
40- data : '2016-08-08'
41- } ] ) ;
42- return (
43- < ListView
44- dataSource = { dataSource }
45- renderRow = { ( rowData ) =>
34+ class listView extends Component {
35+ constructor ( props ) {
36+ super ( props ) ;
37+ let ds = new ListView . DataSource ( { rowHasChanged : ( r1 , r2 ) => r1 !== r2 } ) ;
38+ this . state = {
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+ } ] )
47+ } ;
48+ }
49+ render ( ) {
50+ return (
51+ < ListView
52+ dataSource = { this . state . dataSource }
53+ renderRow = { ( rowData ) =>
4654 < Swipeout right = { [ { text :'删除' , backgroundColor :'red' } ] } backgroundColor = { '#FFF' } >
4755 < View style = { styles . row } >
4856 < View >
@@ -63,11 +71,23 @@ const listView = (props) => {
6371 </ View >
6472 </ Swipeout >
6573 }
66- />
67- ) ;
74+ />
75+ ) ;
76+ }
77+ }
78+
79+ function mapStateToProps ( state ) {
80+ return {
81+ state :{
82+ }
83+ }
84+ }
85+
86+ function mapDispatchToProps ( dispatch ) {
87+ return bindActionCreators ( loginActions , dispatch ) ;
6888}
6989
7090export default connect (
71- ( state ) => ( {
72- } )
91+ mapStateToProps ,
92+ mapDispatchToProps
7393) ( listView )
0 commit comments