Showing
5 changed files
with
151 additions
and
7 deletions
1 | +'use strict'; | ||
2 | + | ||
3 | +import React from 'react'; | ||
4 | +import ReactNative from 'react-native'; | ||
5 | +import Immutable, {Map} from 'immutable'; | ||
6 | + | ||
7 | +const { | ||
8 | + View, | ||
9 | + Text, | ||
10 | + ListView, | ||
11 | + TouchableOpacity, | ||
12 | + Dimensions, | ||
13 | + StyleSheet, | ||
14 | + Platform, | ||
15 | +} = ReactNative; | ||
16 | + | ||
17 | + | ||
18 | +export default class BLKCategoryChannelSelector extends React.Component { | ||
19 | + | ||
20 | + constructor(props) { | ||
21 | + super (props); | ||
22 | + | ||
23 | + this._renderRow = this._renderRow.bind(this); | ||
24 | + this._renderSeparator = this._renderSeparator.bind(this); | ||
25 | + | ||
26 | + this.dataSource = new ListView.DataSource({ | ||
27 | + rowHasChanged: (r1, r2) => r1.id != r2.id, | ||
28 | + }); | ||
29 | + | ||
30 | + this.channels = [ | ||
31 | + { | ||
32 | + name: 'MEN男士', | ||
33 | + value: 'boy', | ||
34 | + id: 1, | ||
35 | + isSelect: false, | ||
36 | + }, | ||
37 | + { | ||
38 | + name: 'WOMEN女士', | ||
39 | + value: 'girl', | ||
40 | + id: 2, | ||
41 | + isSelect: false, | ||
42 | + }, | ||
43 | + ]; | ||
44 | + } | ||
45 | + | ||
46 | + shouldComponentUpdate(nextProps){ | ||
47 | + if ((nextProps.selectedChannelId == this.props.selectedChannelId) | ||
48 | + && (nextProps.selectedChannelValue == this.props.selectedChannelValue)) { | ||
49 | + return false; | ||
50 | + } else { | ||
51 | + return true; | ||
52 | + } | ||
53 | + } | ||
54 | + | ||
55 | + _renderRow(rowData, sectionID, rowID) { | ||
56 | + let isRowSelected = false; | ||
57 | + if (this.props.selectedChannelId >= 1) { | ||
58 | + isRowSelected = (rowID == this.props.selectedChannelId - 1); | ||
59 | + } else { | ||
60 | + isRowSelected = (rowData.value == this.props.selectedChannelValue); | ||
61 | + } | ||
62 | + | ||
63 | + let colorStyle = isRowSelected ? {color: '#444444', fontFamily: 'HelveticaNeue', fontSize: 14} : {color: '#b0b0b0', fontFamily: 'HelveticaNeue', fontSize: 13,}; | ||
64 | + | ||
65 | + return ( | ||
66 | + <TouchableOpacity activeOpacity={1} onPress={() => { | ||
67 | + if (isRowSelected) { | ||
68 | + return; | ||
69 | + } | ||
70 | + | ||
71 | + let channel = this.channels[rowID]; | ||
72 | + | ||
73 | + this.props.onSelectChannel && this.props.onSelectChannel(channel); | ||
74 | + }}> | ||
75 | + <View key={'row' + rowID} style={styles.rowContainer}> | ||
76 | + <Text style={[styles.name, colorStyle]}>{rowData.name}</Text> | ||
77 | + </View> | ||
78 | + </TouchableOpacity> | ||
79 | + ); | ||
80 | + } | ||
81 | + | ||
82 | + _renderSeparator(sectionID, rowID, adjacentRowHighlighted) { | ||
83 | + return ( | ||
84 | + <View key={'sep' + rowID} style={styles.separator}> | ||
85 | + </View> | ||
86 | + ); | ||
87 | + } | ||
88 | + | ||
89 | + render() { | ||
90 | + | ||
91 | + let {style} = this.props; | ||
92 | + | ||
93 | + return ( | ||
94 | + <View style={[styles.container, style]}> | ||
95 | + <ListView | ||
96 | + contentContainerStyle={[styles.contentContainer, style]} | ||
97 | + enableEmptySections={true} | ||
98 | + dataSource={this.dataSource.cloneWithRows(this.channels)} | ||
99 | + renderRow={this._renderRow} | ||
100 | + renderSeparator={this._renderSeparator} | ||
101 | + scrollEnabled={false} | ||
102 | + scrollsToTop={false} | ||
103 | + /> | ||
104 | + </View> | ||
105 | + ); | ||
106 | + } | ||
107 | +} | ||
108 | + | ||
109 | +let {width, height} = Dimensions.get('window'); | ||
110 | + | ||
111 | +//let viewHeight = (Platform.OS === 'ios') ? 44 : 50; | ||
112 | +let viewHeight = 44; | ||
113 | + | ||
114 | + | ||
115 | +let styles = StyleSheet.create({ | ||
116 | + container: { | ||
117 | + width: width, | ||
118 | + height: viewHeight, | ||
119 | + borderTopColor: 'transparent', | ||
120 | + borderBottomColor: '#e0e0e0', | ||
121 | + borderBottomWidth: 0.5, | ||
122 | + backgroundColor:'white', | ||
123 | + }, | ||
124 | + contentContainer: { | ||
125 | + flexDirection: 'row', | ||
126 | + }, | ||
127 | + rowContainer: { | ||
128 | + flexDirection: 'row', | ||
129 | + justifyContent: 'center', | ||
130 | + alignItems: 'center', | ||
131 | + width: Math.ceil(width / 2), | ||
132 | + height: viewHeight, | ||
133 | + backgroundColor:'white', | ||
134 | + }, | ||
135 | + name: { | ||
136 | + color: '#b0b0b0', | ||
137 | + }, | ||
138 | + separator: { | ||
139 | + width: 0.5, | ||
140 | + top: 14, | ||
141 | + height: 16, | ||
142 | + backgroundColor: '#e0e0e0', | ||
143 | + }, | ||
144 | +}); |
@@ -11,7 +11,7 @@ import ReactNative, { | @@ -11,7 +11,7 @@ import ReactNative, { | ||
11 | TouchableOpacity, | 11 | TouchableOpacity, |
12 | } from 'react-native'; | 12 | } from 'react-native'; |
13 | 13 | ||
14 | -import ChannelSelector from '../../../common/components/ChannelSelector'; | 14 | +import BLKCategoryChannelSelector from './BLKCategoryChannelSelector'; |
15 | import LoadingIndicator from '../../../common/components/LoadingIndicator'; | 15 | import LoadingIndicator from '../../../common/components/LoadingIndicator'; |
16 | import CategoryList from './CategoryList'; | 16 | import CategoryList from './CategoryList'; |
17 | 17 | ||
@@ -28,8 +28,8 @@ export default class Category extends Component { | @@ -28,8 +28,8 @@ export default class Category extends Component { | ||
28 | 28 | ||
29 | return ( | 29 | return ( |
30 | <View style={styles.container}> | 30 | <View style={styles.container}> |
31 | - <ChannelSelector selectedChannelValue={this.props.currentChannelId} onSelectChannel={this.props.onSelectChannel} /> | ||
32 | - <CategoryList | 31 | + <BLKCategoryChannelSelector selectedChannelValue={this.props.currentChannelId} onSelectChannel={this.props.onSelectChannel} /> |
32 | + <CategoryList | ||
33 | categoryList={this.props.categoryList} | 33 | categoryList={this.props.categoryList} |
34 | pressLeftRow={this.props.pressLeftRow} | 34 | pressLeftRow={this.props.pressLeftRow} |
35 | currentCateId={this.props.currentCateId} | 35 | currentCateId={this.props.currentCateId} |
@@ -85,7 +85,6 @@ export default class CategoryList extends Component { | @@ -85,7 +85,6 @@ export default class CategoryList extends Component { | ||
85 | return ( | 85 | return ( |
86 | <TouchableOpacity onPress={() => this._pressLeftRow(rowData.toJS(),rowID)}> | 86 | <TouchableOpacity onPress={() => this._pressLeftRow(rowData.toJS(),rowID)}> |
87 | <View style={styles.row} > | 87 | <View style={styles.row} > |
88 | - <Image style={styles.logo_icon} source={{uri: newSrc}} /> | ||
89 | <Text style={styles.title} numberOfLines={1}> | 88 | <Text style={styles.title} numberOfLines={1}> |
90 | {selectText} | 89 | {selectText} |
91 | </Text> | 90 | </Text> |
@@ -193,7 +192,7 @@ let styles = StyleSheet.create({ | @@ -193,7 +192,7 @@ let styles = StyleSheet.create({ | ||
193 | width: width, | 192 | width: width, |
194 | height: 0.5, | 193 | height: 0.5, |
195 | backgroundColor: '#e0e0e0', | 194 | backgroundColor: '#e0e0e0', |
196 | - marginLeft: 70, | 195 | + marginLeft: 20, |
197 | }, | 196 | }, |
198 | subSeparator:{ | 197 | subSeparator:{ |
199 | width: width, | 198 | width: width, |
@@ -38,8 +38,8 @@ function parseCategoryList(json) { | @@ -38,8 +38,8 @@ function parseCategoryList(json) { | ||
38 | if(!json){ | 38 | if(!json){ |
39 | return; | 39 | return; |
40 | } | 40 | } |
41 | - let boy = json && json.boy ? json.boy : []; | ||
42 | - let girl = json && json.girl ? json.girl : []; | 41 | + let boy = json && json.MEN男士 ? json.MEN男士 : []; |
42 | + let girl = json && json.WOMEN女士 ? json.WOMEN女士 : []; | ||
43 | let kids = json && json.kids ? json.kids : []; | 43 | let kids = json && json.kids ? json.kids : []; |
44 | let lifestyle = json && json.lifestyle ? json.lifestyle : []; | 44 | let lifestyle = json && json.lifestyle ? json.lifestyle : []; |
45 | 45 |
@@ -18,6 +18,7 @@ export default class CategoryService { | @@ -18,6 +18,7 @@ export default class CategoryService { | ||
18 | method: 'app.sort.get', | 18 | method: 'app.sort.get', |
19 | yh_channel, | 19 | yh_channel, |
20 | fromPage, | 20 | fromPage, |
21 | + app_type: 1, | ||
21 | } | 22 | } |
22 | }) | 23 | }) |
23 | .then((json) => { | 24 | .then((json) => { |
-
Please register or login to post a comment