MyOrderList.js
2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
'use strict';
import React from 'react';
import ReactNative, {
View,
Text,
Image,
StyleSheet,
Dimensions,
PixelRatio,
TouchableOpacity,
ListView,
LayoutAnimation,
} from 'react-native';
import Immutable, {Map} from 'immutable';
import LoadingIndicator from '../../../common/components/LoadingIndicator';
import MyOrderListCell from './MyOrderListCell';
import OrderTypeSelector from './OrderTypeSelector';
export default class MyOrderList extends React.Component {
constructor(props) {
super(props);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
this.renderRow = this.renderRow.bind(this);
}
renderRow(rowData, sectionID, rowID, highlightRow) {
return (
<MyOrderListCell
orderData={rowData}
onPressOrder={this.props.onPressOrder}
/>
);
}
render() {
let orderList = this.props.orderList;
let array = orderList ? orderList.toArray() : [];
return (
<View style={styles.container}>
<OrderTypeSelector selectedTypeId={this.props.orderType} onSelectType={this.props.onSelectType} />
<View style={styles.splitLine}></View>
<ListView
style={styles.listContainer}
dataSource={this.dataSource.cloneWithRows(array)}
enableEmptySections={true}
renderRow={this.renderRow}
onEndReached={this.props.onEndReached}
onEndReachedThreshold = {500}
/>
</View>
);
}
};
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'column',
},
splitLine: {
width: width,
height: 15 * DEVICE_WIDTH_RATIO,
borderBottomColor: '#e0e0e0',
borderBottomWidth: 0.5,
backgroundColor:'#f0f0f0',
},
listContainer: {
width: width,
height: 300 * DEVICE_WIDTH_RATIO,
backgroundColor:'#ffffff',
},
});