Community.js
2.93 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
'use strict';
import React from 'react';
import {AppRegistry, Platform, StyleSheet, Dimensions} 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 homeInitialState from './reducers/home/homeInitialState';
import HomeContainer from './containers/HomeContainer';
import SubjectPostContainer from './containers/SubjectPostContainer'
import NavBar from './components/NavBar';
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 = {
home: (new homeInitialState()),
};
return _initState;
}
export default function community(platform) {
let YH_Community = 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);
// setup the router table with App selected as the initial component
return (
<Provider store={store}>
<NewRouter hideNavBar={true} sceneStyle={styles.scene}>
<Scene key="root" hideNavBar={true} hideTabBar={true}>
<Scene
key="Home"
title="首页"
hideNavBar={false}
component={HomeContainer}
initial={true}
navBar={NavBar}
titleStyle={styles.navTitle}
getSceneStyle={(props) => {
return this.navPushStyle(props);
}}
/>
<Scene
key="SubjectPost"
title="主题帖"
hideNavBar={false}
component={SubjectPostContainer}
initial={false}
navBar={NavBar}
titleStyle={styles.navTitle}
type="push"
/>
</Scene>
</NewRouter>
</Provider>
);
}
});
AppRegistry.registerComponent('YH_Community', () => YH_Community);
}
let styles = StyleSheet.create({
scene: {
backgroundColor:'#F0F0F0',
},
navTitle: {
color: 'white',
marginLeft: 60,
marginRight: 60,
},
});