Vendor.js
9.44 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
'use strict';
import React, {
AppRegistry,
Navigator,
View,
Text,
Image,
Platform,
StyleSheet,
Animated
} from 'react-native';
import {
Provider,
connect
} from 'react-redux';
import RNRF, {
Router,
Scene,
TabBar,
Actions
} from 'react-native-router-flux';
import configureStore from './store/configureStore';
import {
setPlatform,
setVersion,
setDot
} from './reducers/device/deviceActions';
import deviceInitialState from './reducers/device/deviceInitialState';
import guideInitialState from './reducers/guide/guideInitialState';
import homeInitialState from './reducers/home/homeInitialState';
import messageInitialState from './reducers/message/messageInitialState';
import userInitialState from './reducers/user/userInitialState';
import accountSettlementInitialState from './reducers/accountSettlement/accountSettlementInitialState';
import saleStatisticsInitialState from './reducers/saleStatistics/saleStatisticsInitialState';
import stockStatsInitialState from './reducers/stockStats/stockStatsInitialState';
import deliveryStatsInitialState from './reducers/deliveryStats/deliveryStatsInitialState';
import requestStatsInitialState from './reducers/requestStats/requestStatsInitialState';
import refoundStatisticsInitialState from './reducers/refoundStatistics/refoundStatisticsInitialState';
import NavigationCardStackStyleInterpolator from 'NavigationCardStackStyleInterpolator';
import App from './containers/App';
import GuideContainer from './containers/GuideContainer';
import DrawerContainer from './containers/DrawerContainer';
import HomeContainer from './containers/HomeContainer';
import MessageContainer from './containers/MessageContainer';
import UserContainer from './containers/UserContainer';
import LoginContainer from './containers/LoginContainer'
import LogoutContainer from './containers/LogoutContainer'
import ModifyPasswordContainer from './containers/ModifyPasswordContainer'
import AccountSettlementContainer from './containers/AccountSettlementContainer'
import AboutUsContainer from './containers/AboutUsContainer'
import StockStatsContainer from './containers/StockStatsContainer'
import SaleStatisticsContainer from './containers/SaleStatisticsContainer'
import DeliveryStatsContainer from './containers/DeliveryStatsContainer'
import MessageDetailContainer from './containers/MessageDetailContainer'
import RequestStatsContainer from './containers/RequestStatsContainer'
import RefoundStatisticsContainer from './containers/RefoundStatisticsContainer'
import NavBar from './components/NavBar';
import TabIcon from './containers/TabIcon';
let VERSION = '0.0.1';
/**
*
* ## Initial state
* Create instances for the keys of each structure in snowflake
* @returns {Object} object with 4 keys
*/
function getInitialState() {
const _initState = {
device: (new deviceInitialState).set('isMobile',true),
guide: (new guideInitialState),
home: (new homeInitialState),
message: (new messageInitialState),
user: (new userInitialState),
actStmt: (new accountSettlementInitialState),
saleStats: (new saleStatisticsInitialState()),
stockStats: (new stockStatsInitialState()),
deliveryStats: (new deliveryStatsInitialState()),
requestStats: (new requestStatsInitialState()),
refoundStats: (new refoundStatisticsInitialState()),
};
return _initState;
}
export default function native(platform) {
let Vendor = React.createClass({
/*
* 自定义导航push动画
*
* 参考 node_modules/react-native/Libraries/CustomComponents/
* Navgationxperimental/NavigationCardStackStyleInterpolator
* function forHorizontal(props)
*/
navPushStyle(props) {
const {
layout,
position,
scene,
} = props;
const index = scene.index;
const inputRange = [index - 1, index, index + 1];
const width = layout.initWidth;
const opacity = position.interpolate({
inputRange,
outputRange: [1, 1, 0.3],
});
const scale = position.interpolate({
inputRange,
outputRange: [1, 1, 1],
});
const translateY = 0;
const translateX = position.interpolate({
inputRange,
outputRange: [width, 0, -10],
});
return {
opacity,
transform: [
{ scale },
{ translateX },
{ translateY },
],
};
},
render() {
const store = configureStore(getInitialState());
//Connect w/ the Router
const NewRouter = connect()(Router);
// configureStore will combine reducers from snowflake and main application
// it will then create the store based on aggregate state from all reducers
store.dispatch(setPlatform(platform));
// setup the router table with App selected as the initial component
return (
<Provider store={store}>
<NewRouter hideNavBar={false} sceneStyle={styles.scene}>
<Scene key="root">
<Scene
key="App"
component={App}
title="App"
hideNavBar={true}
initial={true}
/>
<Scene
key="Guide"
component={GuideContainer}
title="Guide"
hideNavBar={true}
initial={false}
type="replace"
/>
<Scene
key="Login"
component={LoginContainer}
hideNavBar={true}
type="replace"
/>
<Scene
key="Logout"
component={LogoutContainer}
hideNavBar={false}
navBar={NavBar}
title={'修改密码'}
titleStyle={styles.navTitle}
type="push"
/>
<Scene
key="Modify"
component={ModifyPasswordContainer}
hideNavBar={false}
navBar={NavBar}
title={'修改密码'}
titleStyle={styles.navTitle}
type="push"
/>
<Scene
key="SaleStats"
component={SaleStatisticsContainer}
title='销售统计'
hideNavBar={false}
navBar={NavBar}
titleStyle={styles.navTitle}
type="push"
/>
<Scene
key="RefoundStats"
component={RefoundStatisticsContainer}
title='退货统计'
hideNavBar={false}
navBar={NavBar}
titleStyle={styles.navTitle}
type="push"
/>
<Scene
key="MessageDetail"
component={MessageDetailContainer}
hideNavBar={false}
navBar={NavBar}
title={'消息'}
titleStyle={styles.navTitle}
type="push"
/>
<Scene
key='DeliveryStats'
component={DeliveryStatsContainer}
title='发货入库'
hideNavBar={false}
initial={false}
navBar={NavBar}
titleStyle={styles.navTitle}
type='push'
/>
<Scene
key='RequestStats'
component={RequestStatsContainer}
title='请退统计'
hideNavBar={false}
initial={false}
navBar={NavBar}
titleStyle={styles.navTitle}
type='push'
/>
<Scene
key='StockStats'
component={StockStatsContainer}
title='库存统计'
hideNavBar={false}
initial={false}
navBar={NavBar}
titleStyle={styles.navTitle}
type='push'
/>
<Scene
key='AccountSettlement'
component={AccountSettlementContainer}
title='对账结算'
hideNavBar={false}
initial={false}
navBar={NavBar}
titleStyle={styles.navTitle}
type='push'
/>
<Scene
key='AboutUs'
component={AboutUsContainer}
title='关于我们'
hideNavBar={false}
initial={false}
navBar={NavBar}
titleStyle={styles.navTitle}
type='push'
/>
<Scene key="Drawer" component={DrawerContainer} type="replace" hideNavBar={true} getSceneStyle={(props) => {
return this.navPushStyle(props);
}}>
<Scene key="Tabbar" tabs={true} initial={false} type="replace" component={TabBar}>
<Scene
key="Home"
title="首页"
icon={TabIcon}
iconNormal={require('./images/tabbar/home_normal.png')}
iconSelected={require('./images/tabbar/home.png')}
hideNavBar={false}
component={HomeContainer}
initial={true}
navBar={NavBar}
titleStyle={styles.navTitle}
drawerImage={require('./images/menu_burger.png')}
backButtonImage={require('./images/menu_back.png')}
getTitle={(childState) => {
return store.getState().home.get('brandName');
}}
/>
<Scene
key="Message"
title="消息"
iconNormal={require('./images/tabbar/message_normal.png')}
iconSelected={require('./images/tabbar/message.png')}
icon={TabIcon}
hideNavBar={false}
component={MessageContainer}
navBar={NavBar}
titleStyle={styles.navTitle}
renderLeftButton={()=>{}}
/>
<Scene
key="User"
title="我的"
icon={TabIcon}
iconNormal={require('./images/tabbar/user_normal.png')}
iconSelected={require('./images/tabbar/user.png')}
hideNavBar={false}
component={UserContainer}
navBar={NavBar}
titleStyle={styles.navTitle}
renderLeftButton={()=>{}}
/>
</Scene>
</Scene>
</Scene>
</NewRouter>
</Provider>
);
}
});
AppRegistry.registerComponent('YH_Vendor', () => Vendor);
}
let styles = StyleSheet.create({
scene: {
backgroundColor:'#F0F0F0',
},
navTitle: {
color: 'white',
},
});