Showing
6 changed files
with
132 additions
and
118 deletions
@@ -40,6 +40,10 @@ import { | @@ -40,6 +40,10 @@ import { | ||
40 | setGlobalHost, | 40 | setGlobalHost, |
41 | } from './reducers/app/appActions'; | 41 | } from './reducers/app/appActions'; |
42 | 42 | ||
43 | +import { | ||
44 | + setCurrentTab, | ||
45 | +} from './reducers/product/productActions'; | ||
46 | + | ||
43 | 47 | ||
44 | function getInitialState() { | 48 | function getInitialState() { |
45 | const _initState = { | 49 | const _initState = { |
@@ -72,6 +76,7 @@ export default function native(platform) { | @@ -72,6 +76,7 @@ export default function native(platform) { | ||
72 | store.dispatch(setHost(this.props.host)); | 76 | store.dispatch(setHost(this.props.host)); |
73 | store.dispatch(setServiceHost(this.props.serviceHost)); | 77 | store.dispatch(setServiceHost(this.props.serviceHost)); |
74 | store.dispatch(setGlobalHost(this.props.globalHost)); | 78 | store.dispatch(setGlobalHost(this.props.globalHost)); |
79 | + store.dispatch(setCurrentTab(this.props.productType)); | ||
75 | 80 | ||
76 | return ( | 81 | return ( |
77 | <Provider store={store}> | 82 | <Provider store={store}> |
@@ -24,11 +24,11 @@ export default class Product extends Component { | @@ -24,11 +24,11 @@ export default class Product extends Component { | ||
24 | super(props); | 24 | super(props); |
25 | 25 | ||
26 | this.renderRow = this.renderRow.bind(this); | 26 | this.renderRow = this.renderRow.bind(this); |
27 | - this.renderHeader = this.renderHeader.bind(this); | 27 | + // this.renderHeader = this.renderHeader.bind(this); |
28 | this.handleScroll = this.handleScroll.bind(this); | 28 | this.handleScroll = this.handleScroll.bind(this); |
29 | this.onOpen = this.onOpen.bind(this); | 29 | this.onOpen = this.onOpen.bind(this); |
30 | this.onClose = this.onClose.bind(this); | 30 | this.onClose = this.onClose.bind(this); |
31 | - this.renderSectionHeader = this.renderSectionHeader.bind(this); | 31 | + // this.renderSectionHeader = this.renderSectionHeader.bind(this); |
32 | this.renderFooter = this.renderFooter.bind(this); | 32 | this.renderFooter = this.renderFooter.bind(this); |
33 | 33 | ||
34 | this.dataSource = new ListView.DataSource({ | 34 | this.dataSource = new ListView.DataSource({ |
@@ -164,72 +164,61 @@ export default class Product extends Component { | @@ -164,72 +164,61 @@ export default class Product extends Component { | ||
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | - renderHeader() { | ||
168 | - let { | ||
169 | - commonProduct, | ||
170 | - globalProduct, | ||
171 | - editing, | ||
172 | - currentTab, | ||
173 | - } = this.props.data; | ||
174 | - let {productList} = globalProduct; | ||
175 | - let {selectedProductList, categoryList, selectedCategoryIndex} = commonProduct; | ||
176 | - let isShow = currentTab === 'common' && selectedProductList.size > 0; | ||
177 | - | ||
178 | - return ( | ||
179 | - <View> | ||
180 | - {productList.size > 0 ? <TabHeader | ||
181 | - currentTab={currentTab} | ||
182 | - onPressTab={(tab)=>{ | ||
183 | - if (tab == currentTab) { | ||
184 | - return; | ||
185 | - } | ||
186 | - this.state.currentlyOpenSwipeable && this.state.currentlyOpenSwipeable.recenter(); | ||
187 | - this.setState({currentlyOpenSwipeable: null}); | ||
188 | - this.props.onPressTab && this.props.onPressTab(tab); | ||
189 | - }} | ||
190 | - /> : null} | ||
191 | - {isShow ? <CategorySelector | ||
192 | - data={categoryList} | ||
193 | - selectedCategoryIndex={selectedCategoryIndex} | ||
194 | - onPressCategory={(rowData, rowID) => { | ||
195 | - this.listView && this.listView.scrollTo({x: 0, y: 0, animated: false}); | ||
196 | - this.props.onPressCategory && this.props.onPressCategory(rowData, rowID); | ||
197 | - }} | ||
198 | - /> : null} | ||
199 | - </View> | ||
200 | - ) | ||
201 | - } | ||
202 | - | ||
203 | - renderSectionHeader(sectionData, sectionID) { | ||
204 | - let { | ||
205 | - commonProduct, | ||
206 | - globalProduct, | ||
207 | - editing, | ||
208 | - currentTab, | ||
209 | - } = this.props.data; | ||
210 | - | ||
211 | - if (currentTab == 'global') { | ||
212 | - return null; | ||
213 | - } | ||
214 | - | ||
215 | - if (currentTab == 'common') { | ||
216 | - let {isFetching, selectedProductList, categoryList, selectedCategoryIndex} = commonProduct; | ||
217 | - if (selectedProductList.size == 0) { | ||
218 | - return null; | ||
219 | - } | ||
220 | - return ( | ||
221 | - <CategorySelector | ||
222 | - data={categoryList} | ||
223 | - selectedCategoryIndex={selectedCategoryIndex} | ||
224 | - onPressCategory={(rowData, rowID) => { | ||
225 | - this.listView && this.listView.scrollTo({x: 0, y: 0, animated: false}); | ||
226 | - this.props.onPressCategory && this.props.onPressCategory(rowData, rowID); | ||
227 | - }} | ||
228 | - /> | ||
229 | - ); | ||
230 | - } | ||
231 | - return null; | ||
232 | - } | 167 | + // renderHeader() { |
168 | + // let { | ||
169 | + // commonProduct, | ||
170 | + // globalProduct, | ||
171 | + // editing, | ||
172 | + // currentTab, | ||
173 | + // } = this.props.data; | ||
174 | + // let {productList} = globalProduct; | ||
175 | + // let {selectedProductList, categoryList, selectedCategoryIndex} = commonProduct; | ||
176 | + // let isShow = currentTab === 'common' && selectedProductList.size > 0; | ||
177 | + | ||
178 | + // return ( | ||
179 | + // <View> | ||
180 | + // {isShow ? <CategorySelector | ||
181 | + // data={categoryList} | ||
182 | + // selectedCategoryIndex={selectedCategoryIndex} | ||
183 | + // onPressCategory={(rowData, rowID) => { | ||
184 | + // this.listView && this.listView.scrollTo({x: 0, y: 0, animated: false}); | ||
185 | + // this.props.onPressCategory && this.props.onPressCategory(rowData, rowID); | ||
186 | + // }} | ||
187 | + // /> : null} | ||
188 | + // </View> | ||
189 | + // ) | ||
190 | + // } | ||
191 | + | ||
192 | + // renderSectionHeader(sectionData, sectionID) { | ||
193 | + // let { | ||
194 | + // commonProduct, | ||
195 | + // globalProduct, | ||
196 | + // editing, | ||
197 | + // currentTab, | ||
198 | + // } = this.props.data; | ||
199 | + | ||
200 | + // if (currentTab == 'global') { | ||
201 | + // return null; | ||
202 | + // } | ||
203 | + | ||
204 | + // if (currentTab == 'common') { | ||
205 | + // let {isFetching, selectedProductList, categoryList, selectedCategoryIndex} = commonProduct; | ||
206 | + // if (selectedProductList.size == 0) { | ||
207 | + // return null; | ||
208 | + // } | ||
209 | + // return ( | ||
210 | + // <CategorySelector | ||
211 | + // data={categoryList} | ||
212 | + // selectedCategoryIndex={selectedCategoryIndex} | ||
213 | + // onPressCategory={(rowData, rowID) => { | ||
214 | + // this.listView && this.listView.scrollTo({x: 0, y: 0, animated: false}); | ||
215 | + // this.props.onPressCategory && this.props.onPressCategory(rowData, rowID); | ||
216 | + // }} | ||
217 | + // /> | ||
218 | + // ); | ||
219 | + // } | ||
220 | + // return null; | ||
221 | + // } | ||
233 | 222 | ||
234 | render() { | 223 | render() { |
235 | 224 | ||
@@ -266,7 +255,7 @@ export default class Product extends Component { | @@ -266,7 +255,7 @@ export default class Product extends Component { | ||
266 | enableEmptySections={true} | 255 | enableEmptySections={true} |
267 | dataSource={this.dataSource.cloneWithRows(dataArray)} | 256 | dataSource={this.dataSource.cloneWithRows(dataArray)} |
268 | renderRow={this.renderRow} | 257 | renderRow={this.renderRow} |
269 | - renderHeader={this.renderHeader} | 258 | + //renderHeader={this.renderHeader} |
270 | // renderSectionHeader={this.renderSectionHeader} | 259 | // renderSectionHeader={this.renderSectionHeader} |
271 | onScroll={this.handleScroll} | 260 | onScroll={this.handleScroll} |
272 | renderFooter={this.renderFooter} | 261 | renderFooter={this.renderFooter} |
@@ -141,60 +141,61 @@ export default class Product extends Component { | @@ -141,60 +141,61 @@ export default class Product extends Component { | ||
141 | } | 141 | } |
142 | 142 | ||
143 | renderHeader() { | 143 | renderHeader() { |
144 | - let { | ||
145 | - commonProduct, | ||
146 | - globalProduct, | ||
147 | - editing, | ||
148 | - currentTab, | ||
149 | - } = this.props.data; | ||
150 | - let {productList} = globalProduct; | ||
151 | - if (productList.size == 0) { | ||
152 | return null; | 144 | return null; |
153 | - } | ||
154 | - return (<TabHeader | ||
155 | - currentTab={currentTab} | ||
156 | - onPressTab={(tab)=>{ | ||
157 | - if (tab == currentTab) { | ||
158 | - return; | ||
159 | - } | ||
160 | - this.props.onPressTab && this.props.onPressTab(tab); | ||
161 | - }} | ||
162 | - />) | 145 | + // let { |
146 | + // commonProduct, | ||
147 | + // globalProduct, | ||
148 | + // editing, | ||
149 | + // currentTab, | ||
150 | + // } = this.props.data; | ||
151 | + // let {productList} = globalProduct; | ||
152 | + // if (productList.size == 0) { | ||
153 | + // return null; | ||
154 | + // } | ||
155 | + // return (<TabHeader | ||
156 | + // currentTab={currentTab} | ||
157 | + // onPressTab={(tab)=>{ | ||
158 | + // if (tab == currentTab) { | ||
159 | + // return; | ||
160 | + // } | ||
161 | + // this.props.onPressTab && this.props.onPressTab(tab); | ||
162 | + // }} | ||
163 | + // />) | ||
163 | } | 164 | } |
164 | 165 | ||
165 | renderSectionHeader(sectionData, sectionID) { | 166 | renderSectionHeader(sectionData, sectionID) { |
166 | - let { | ||
167 | - commonProduct, | ||
168 | - globalProduct, | ||
169 | - editing, | ||
170 | - currentTab, | ||
171 | - } = this.props.data; | ||
172 | - | ||
173 | - if (currentTab == 'global') { | ||
174 | - return null; | ||
175 | - } | ||
176 | - let realHeight = 44; | ||
177 | - let {productList} = globalProduct; | ||
178 | - if (productList.size != 0) { | ||
179 | - realHeight += 45; | ||
180 | - } | ||
181 | - if (currentTab == 'common') { | ||
182 | - let {isFetching, selectedProductList, categoryList, selectedCategoryIndex} = commonProduct; | ||
183 | - if (selectedProductList.size == 0) { | ||
184 | - return null; | ||
185 | - } | ||
186 | - return ( | ||
187 | - <CategorySelector | ||
188 | - data={categoryList} | ||
189 | - selectedCategoryIndex={selectedCategoryIndex} | ||
190 | - onPressCategory={(rowData, rowID) => { | ||
191 | - this.sectionList && this.sectionList.scrollToLocation({itemIndex: 0,sectionIndex: 0, viewOffset: realHeight, animated: false}); | ||
192 | - this.props.onPressCategory && this.props.onPressCategory(rowData, rowID); | ||
193 | - }} | ||
194 | - /> | ||
195 | - ); | ||
196 | - } | ||
197 | return null; | 167 | return null; |
168 | + // let { | ||
169 | + // commonProduct, | ||
170 | + // globalProduct, | ||
171 | + // editing, | ||
172 | + // currentTab, | ||
173 | + // } = this.props.data; | ||
174 | + | ||
175 | + // if (currentTab == 'global') { | ||
176 | + // return null; | ||
177 | + // } | ||
178 | + // let realHeight = 44; | ||
179 | + // let {productList} = globalProduct; | ||
180 | + // if (productList.size != 0) { | ||
181 | + // realHeight += 45; | ||
182 | + // } | ||
183 | + // if (currentTab == 'common') { | ||
184 | + // let {isFetching, selectedProductList, categoryList, selectedCategoryIndex} = commonProduct; | ||
185 | + // if (selectedProductList.size == 0) { | ||
186 | + // return null; | ||
187 | + // } | ||
188 | + // return ( | ||
189 | + // <CategorySelector | ||
190 | + // data={categoryList} | ||
191 | + // selectedCategoryIndex={selectedCategoryIndex} | ||
192 | + // onPressCategory={(rowData, rowID) => { | ||
193 | + // this.sectionList && this.sectionList.scrollToLocation({itemIndex: 0,sectionIndex: 0, viewOffset: realHeight, animated: false}); | ||
194 | + // this.props.onPressCategory && this.props.onPressCategory(rowData, rowID); | ||
195 | + // }} | ||
196 | + // /> | ||
197 | + // ); | ||
198 | + // } | ||
198 | } | 199 | } |
199 | 200 | ||
200 | render() { | 201 | render() { |
@@ -28,8 +28,17 @@ const { | @@ -28,8 +28,17 @@ const { | ||
28 | SET_EDITING, | 28 | SET_EDITING, |
29 | SET_EDITED_INDEX, | 29 | SET_EDITED_INDEX, |
30 | SET_CATEGORY_LIST, | 30 | SET_CATEGORY_LIST, |
31 | + | ||
32 | + SET_CURRENT_TAB, | ||
31 | } = require('../../constants/actionTypes').default; | 33 | } = require('../../constants/actionTypes').default; |
32 | 34 | ||
35 | +export function setCurrentTab(tab) { | ||
36 | + return { | ||
37 | + type: SET_CURRENT_TAB, | ||
38 | + payload: tab | ||
39 | + }; | ||
40 | +} | ||
41 | + | ||
33 | export function setCategoryList(categoryList) { | 42 | export function setCategoryList(categoryList) { |
34 | return (dispatch) => { | 43 | return (dispatch) => { |
35 | dispatch({ | 44 | dispatch({ |
@@ -26,13 +26,21 @@ const { | @@ -26,13 +26,21 @@ const { | ||
26 | SET_EDITING, | 26 | SET_EDITING, |
27 | SET_EDITED_INDEX, | 27 | SET_EDITED_INDEX, |
28 | SET_CATEGORY_LIST, | 28 | SET_CATEGORY_LIST, |
29 | + | ||
30 | + SET_CURRENT_TAB, | ||
31 | + | ||
29 | } = require('../../constants/actionTypes').default; | 32 | } = require('../../constants/actionTypes').default; |
30 | 33 | ||
31 | const initialState = new InitialState; | 34 | const initialState = new InitialState; |
32 | 35 | ||
33 | export default function productReducer(state=initialState, action) { | 36 | export default function productReducer(state=initialState, action) { |
34 | switch(action.type) { | 37 | switch(action.type) { |
38 | + case SET_CURRENT_TAB: { | ||
39 | + console.log("chenlin") | ||
40 | + console.log(action.payload) | ||
35 | 41 | ||
42 | + return state.set('currentTab', action.payload); | ||
43 | + } | ||
36 | case SET_EDITED_INDEX: { | 44 | case SET_EDITED_INDEX: { |
37 | let rowID = action.payload; | 45 | let rowID = action.payload; |
38 | let { | 46 | let { |
-
Please register or login to post a comment