parent
1ca78c34f1
commit
9f9f8affe0
8 changed files with 129 additions and 10 deletions
@ -0,0 +1,37 @@ |
||||
import React from 'react' |
||||
import { View, Text, ListView, RefreshControl, TouchableOpacity } from 'react-native' |
||||
|
||||
const ds = new ListView.DataSource({ |
||||
rowHasChanged: (r1, r2) => { |
||||
return r1.name != r2.name |
||||
} |
||||
}) |
||||
|
||||
export default ItemsPage = ({ dev, show, list, refresh, getList, backPage }) => { |
||||
if (!show) return null |
||||
console.log('Items') |
||||
return ( |
||||
<View style={{ flex: 1 }}> |
||||
<View style={{ |
||||
height: 25, |
||||
marginTop: 5, |
||||
marginLeft: 10, |
||||
marginRight: 10, |
||||
marginBottom: 5 |
||||
}}> |
||||
<TouchableOpacity onPress={() => backPage()}> |
||||
<Text style={{fontSize: 20}}><<Back</Text> |
||||
</TouchableOpacity> |
||||
</View> |
||||
<ListView |
||||
refreshControl={<RefreshControl refreshing={refresh} onRefresh={getList} />} |
||||
enableEmptySections={true} |
||||
dataSource={ds.cloneWithRows(list)} |
||||
renderRow={data => { |
||||
return ( |
||||
<Text>{data.name} / {data.price}</Text> |
||||
) |
||||
}} /> |
||||
</View> |
||||
) |
||||
} |
@ -0,0 +1,23 @@ |
||||
import {connect} from 'react-redux' |
||||
import ItemsPage from '../components/ItemsPage' |
||||
import {toPage, getStoreList, clearItems} from '../actions' |
||||
|
||||
const mapStateToProps = (state) => ({ |
||||
dev: state.sys.dev, |
||||
show: state.ui.page == 1, |
||||
refresh: state.ui.loading, |
||||
list: state.sys.items || [] |
||||
}) |
||||
|
||||
const mapDispatchToProps = (dispatch, ownProps) => ({ |
||||
getList: () => { |
||||
dispatch(getItems()) |
||||
}, |
||||
backPage: () => { |
||||
dispatch(clearItems()) |
||||
dispatch(toPage(0)) |
||||
dispatch(getStoreList()) |
||||
} |
||||
}) |
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ItemsPage) |
Loading…
Reference in new issue