|
@@ -8,7 +8,9 @@ import ReactNative, { |
|
@@ -8,7 +8,9 @@ import ReactNative, { |
8
|
ListView,
|
8
|
ListView,
|
9
|
TouchableOpacity,
|
9
|
TouchableOpacity,
|
10
|
StyleSheet,
|
10
|
StyleSheet,
|
11
|
- Dimensions
|
11
|
+ Dimensions,
|
|
|
12
|
+ Animated,
|
|
|
13
|
+ Easing
|
12
|
} from 'react-native';
|
14
|
} from 'react-native';
|
13
|
import Immutable, {Map, List} from 'immutable';
|
15
|
import Immutable, {Map, List} from 'immutable';
|
14
|
|
16
|
|
|
@@ -21,6 +23,10 @@ export default class ProductCell extends Component { |
|
@@ -21,6 +23,10 @@ export default class ProductCell extends Component { |
21
|
super(props);
|
23
|
super(props);
|
22
|
|
24
|
|
23
|
this.renderReduce = this.renderReduce.bind(this);
|
25
|
this.renderReduce = this.renderReduce.bind(this);
|
|
|
26
|
+
|
|
|
27
|
+ this.state = {
|
|
|
28
|
+ marginLeft: new Animated.Value(0)
|
|
|
29
|
+ }
|
24
|
}
|
30
|
}
|
25
|
|
31
|
|
26
|
renderReduce() {
|
32
|
renderReduce() {
|
|
@@ -48,6 +54,14 @@ export default class ProductCell extends Component { |
|
@@ -48,6 +54,14 @@ export default class ProductCell extends Component { |
48
|
);
|
54
|
);
|
49
|
}
|
55
|
}
|
50
|
|
56
|
|
|
|
57
|
+ // componentWillReceiveProps(nextProps) {
|
|
|
58
|
+ // if (this.props.data.isDeleting
|
|
|
59
|
+ // && this.props.data.isDeleting != nextProps.data.isDeleting) {
|
|
|
60
|
+ // this.state.currentlyOpenSwipeable && this.state.currentlyOpenSwipeable.recenter();
|
|
|
61
|
+ // this.setState({currentlyOpenSwipeable: null});
|
|
|
62
|
+ // }
|
|
|
63
|
+ // }
|
|
|
64
|
+
|
51
|
render() {
|
65
|
render() {
|
52
|
|
66
|
|
53
|
let data = this.props.data;
|
67
|
let data = this.props.data;
|
|
@@ -77,62 +91,78 @@ export default class ProductCell extends Component { |
|
@@ -77,62 +91,78 @@ export default class ProductCell extends Component { |
77
|
let {editing, editedRow, rowID} = this.props;
|
91
|
let {editing, editedRow, rowID} = this.props;
|
78
|
let showLeft = editing && editedRow != rowID;
|
92
|
let showLeft = editing && editedRow != rowID;
|
79
|
let showTail = editing && editedRow == rowID;
|
93
|
let showTail = editing && editedRow == rowID;
|
80
|
- let marginLeft = showTail?-70:0;
|
94
|
+ let marginLeft = showTail
|
|
|
95
|
+ ? -70
|
|
|
96
|
+ : 0;
|
|
|
97
|
+
|
|
|
98
|
+ Animated.timing(this.state.marginLeft, {
|
|
|
99
|
+ toValue: marginLeft,
|
|
|
100
|
+ duration: 150,
|
|
|
101
|
+ easing: Easing.linear
|
|
|
102
|
+ }).start();
|
81
|
return (
|
103
|
return (
|
82
|
<View style={styles.fatherContainer}>
|
104
|
<View style={styles.fatherContainer}>
|
83
|
{showLeft
|
105
|
{showLeft
|
84
|
? <TouchableOpacity activeOpacity={1} style={styles.deleteContainer} onPress={() => {
|
106
|
? <TouchableOpacity activeOpacity={1} style={styles.deleteContainer} onPress={() => {
|
85
|
- this.props.setEditedIndex && this.props.setEditedIndex(rowID);
|
|
|
86
|
- }}>
|
107
|
+ this.props.setEditedIndex && this.props.setEditedIndex(rowID);
|
|
|
108
|
+ }}>
|
87
|
<View style={styles.deleteCircle}>
|
109
|
<View style={styles.deleteCircle}>
|
88
|
<View style={styles.deleteBar}/>
|
110
|
<View style={styles.deleteBar}/>
|
89
|
</View>
|
111
|
</View>
|
90
|
</TouchableOpacity>
|
112
|
</TouchableOpacity>
|
91
|
: null}
|
113
|
: null}
|
92
|
|
114
|
|
93
|
- <TouchableOpacity activeOpacity={1} style={[styles.container, {marginLeft}]} onPress={() => {
|
|
|
94
|
- this.props.onPressProduct && this.props.onPressProduct(data);
|
|
|
95
|
- }}>
|
|
|
96
|
- <View style={styles.container}>
|
|
|
97
|
- <View style={styles.leftContainer}>
|
|
|
98
|
- <YH_Image style={styles.prdImage} url={prdImage}/>
|
|
|
99
|
- <View>
|
|
|
100
|
- <Text style={styles.prdName} numberOfLines={2}>{data.get('product_name', '')}</Text>
|
|
|
101
|
- {this.renderReduce()}
|
|
|
102
|
- </View>
|
|
|
103
|
- </View>
|
|
|
104
|
- <Image style={styles.arrow} source={require('../../images/browse/shared_next_icon.png')}/>
|
115
|
+ <Animated.View style={[
|
|
|
116
|
+ styles.container, {
|
|
|
117
|
+ marginLeft: this.state.marginLeft
|
|
|
118
|
+ }
|
|
|
119
|
+ ]}>
|
105
|
|
120
|
|
106
|
- <View style={styles.priceContainer}>
|
|
|
107
|
- <Text style={[
|
|
|
108
|
- styles.nowPrice, {
|
|
|
109
|
- color: salePriceColor
|
|
|
110
|
- }
|
|
|
111
|
- ]} numberOfLines={1}>{salePriceStr}</Text>
|
|
|
112
|
- {showOriginPrice
|
|
|
113
|
- ? <DeleteLineText style={styles.oldPriceContainer} textStyle={styles.oldPrice} lineStyle={styles.deleteLine} text={originPriceStr}/>
|
|
|
114
|
- : null}
|
|
|
115
|
- </View>
|
|
|
116
|
- {showSoldOut
|
|
|
117
|
- ? <View style={styles.soldOutContainer}>
|
|
|
118
|
- <Text style={styles.soldOut}>{'已售罄'}</Text>
|
121
|
+ <TouchableOpacity activeOpacity={1} style={[styles.container]} onPress={() => {
|
|
|
122
|
+ this.props.onPressProduct && this.props.onPressProduct(data);
|
|
|
123
|
+ }}>
|
|
|
124
|
+ <View style={styles.container}>
|
|
|
125
|
+ <View style={styles.leftContainer}>
|
|
|
126
|
+ <YH_Image style={styles.prdImage} url={prdImage}/>
|
|
|
127
|
+ <View>
|
|
|
128
|
+ <Text style={styles.prdName} numberOfLines={2}>{data.get('product_name', '')}</Text>
|
|
|
129
|
+ {this.renderReduce()}
|
119
|
</View>
|
130
|
</View>
|
120
|
- : null}
|
131
|
+ </View>
|
|
|
132
|
+ <Image style={styles.arrow} source={require('../../images/browse/shared_next_icon.png')}/>
|
121
|
|
133
|
|
122
|
- <TouchableOpacity activeOpacity={1} style={styles.similar} onPress={() => {
|
|
|
123
|
- this.props.onPressFindSimilar && this.props.onPressFindSimilar(data);
|
|
|
124
|
- }}>
|
|
|
125
|
- <Image source={require('../../images/browse/shopcart_findResemblance.png')}/>
|
|
|
126
|
- </TouchableOpacity>
|
134
|
+ <View style={styles.priceContainer}>
|
|
|
135
|
+ <Text style={[
|
|
|
136
|
+ styles.nowPrice, {
|
|
|
137
|
+ color: salePriceColor
|
|
|
138
|
+ }
|
|
|
139
|
+ ]} numberOfLines={1}>{salePriceStr}</Text>
|
|
|
140
|
+ {showOriginPrice
|
|
|
141
|
+ ? <DeleteLineText style={styles.oldPriceContainer} textStyle={styles.oldPrice} lineStyle={styles.deleteLine} text={originPriceStr}/>
|
|
|
142
|
+ : null}
|
|
|
143
|
+ </View>
|
|
|
144
|
+ {showSoldOut
|
|
|
145
|
+ ? <View style={styles.soldOutContainer}>
|
|
|
146
|
+ <Text style={styles.soldOut}>{'已售罄'}</Text>
|
|
|
147
|
+ </View>
|
|
|
148
|
+ : null}
|
|
|
149
|
+ {this.props.currentTab != 'global'
|
|
|
150
|
+ ? <TouchableOpacity activeOpacity={1} style={styles.similar} onPress={() => {
|
|
|
151
|
+ this.props.onPressFindSimilar && this.props.onPressFindSimilar(data);
|
|
|
152
|
+ }}>
|
|
|
153
|
+ <Image source={require('../../images/browse/shopcart_findResemblance.png')}/>
|
|
|
154
|
+ </TouchableOpacity>
|
|
|
155
|
+ : null}
|
127
|
|
156
|
|
128
|
- <View style={styles.separator}/>
|
|
|
129
|
- </View>
|
|
|
130
|
- </TouchableOpacity>
|
157
|
+ <View style={styles.separator}/>
|
|
|
158
|
+ </View>
|
|
|
159
|
+ </TouchableOpacity>
|
|
|
160
|
+ </Animated.View>
|
131
|
|
161
|
|
132
|
{showTail
|
162
|
{showTail
|
133
|
? <TouchableOpacity activeOpacity={1} style={styles.tailContainer} onPress={() => {
|
163
|
? <TouchableOpacity activeOpacity={1} style={styles.tailContainer} onPress={() => {
|
134
|
- this.props.onPressDelete && this.props.onPressDelete(data, rowID);
|
|
|
135
|
- }}>
|
164
|
+ this.props.onPressDelete && this.props.onPressDelete(data, rowID);
|
|
|
165
|
+ }}>
|
136
|
<Text style={styles.tailText}>删除</Text>
|
166
|
<Text style={styles.tailText}>删除</Text>
|
137
|
</TouchableOpacity>
|
167
|
</TouchableOpacity>
|
138
|
: null}
|
168
|
: null}
|
|
@@ -155,27 +185,28 @@ let styles = StyleSheet.create({ |
|
@@ -155,27 +185,28 @@ let styles = StyleSheet.create({ |
155
|
fatherContainer: {
|
185
|
fatherContainer: {
|
156
|
flexDirection: 'row',
|
186
|
flexDirection: 'row',
|
157
|
alignItems: 'center',
|
187
|
alignItems: 'center',
|
158
|
- backgroundColor: 'white',
|
188
|
+ backgroundColor: 'white'
|
159
|
},
|
189
|
},
|
160
|
deleteContainer: {
|
190
|
deleteContainer: {
|
161
|
- width: 50,
|
191
|
+ width: 40,
|
162
|
height: 70,
|
192
|
height: 70,
|
163
|
alignItems: 'center',
|
193
|
alignItems: 'center',
|
164
|
justifyContent: 'center',
|
194
|
justifyContent: 'center',
|
165
|
- backgroundColor : 'white',
|
195
|
+ backgroundColor: 'white',
|
|
|
196
|
+ paddingLeft: 5
|
166
|
},
|
197
|
},
|
167
|
deleteCircle: {
|
198
|
deleteCircle: {
|
168
|
- width: 15,
|
|
|
169
|
- height: 15,
|
|
|
170
|
- borderRadius: 7.5,
|
199
|
+ width: 22,
|
|
|
200
|
+ height: 22,
|
|
|
201
|
+ borderRadius: 11,
|
171
|
backgroundColor: 'red',
|
202
|
backgroundColor: 'red',
|
172
|
flexDirection: 'row',
|
203
|
flexDirection: 'row',
|
173
|
alignItems: 'center',
|
204
|
alignItems: 'center',
|
174
|
justifyContent: 'center'
|
205
|
justifyContent: 'center'
|
175
|
},
|
206
|
},
|
176
|
deleteBar: {
|
207
|
deleteBar: {
|
177
|
- width: 6,
|
|
|
178
|
- height: 1,
|
208
|
+ width: 11,
|
|
|
209
|
+ height: 1.5,
|
179
|
backgroundColor: 'white'
|
210
|
backgroundColor: 'white'
|
180
|
},
|
211
|
},
|
181
|
tailContainer: {
|
212
|
tailContainer: {
|