-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example.js
executable file
·254 lines (238 loc) · 7.99 KB
/
Example.js
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
import React from 'react';
import { Platform, StyleSheet, Text, View } from 'react-native';
import Launch from './components/Launch';
import Register from './components/Register';
import Login from './components/Login';
import Login2 from './components/Login2';
import Login3 from './components/Login3';
import CardStackStyleInterpolator from 'react-navigation/src/views/CardStack/CardStackStyleInterpolator';
import {
Scene,
Router,
Actions,
Reducer,
ActionConst,
Overlay,
Tabs,
Modal,
Drawer,
Stack,
Lightbox,
} from 'react-native-router-flux';
import Home from './components/Home';
import DrawerContent from './components/drawer/DrawerContent';
import TabView from './components/TabView';
import TabIcon from './components/TabIcon';
import EchoView from './components/EchoView';
import MessageBar from './components/MessageBar';
import ErrorModal from './components/modal/ErrorModal';
import DemoLightbox from './components/lightbox/DemoLightbox';
import MenuIcon from './images/menu_burger.png';
import CustomNavBarView from "./components/CustomNavBarView";
import CustomNavBar from "./components/CustomNavBar";
import CustomNavBar2 from "./components/CustomNavBar2";
const styles = StyleSheet.create({
container: {
flex: 1, backgroundColor: 'transparent', justifyContent: 'center',
alignItems: 'center',
},
tabBarStyle: {
backgroundColor: '#eee',
},
tabBarSelectedItemStyle: {
backgroundColor: '#ddd',
},
});
const reducerCreate = params => {
const defaultReducer = new Reducer(params);
return (state, action) => {
console.log('ACTION:', action);
return defaultReducer(state, action);
};
};
const getSceneStyle = () => ({
backgroundColor: '#F5FCFF',
shadowOpacity: 1,
shadowRadius: 3,
});
// on Android, the URI prefix typically contains a host in addition to scheme
const prefix = Platform.OS === 'android' ? 'mychat://mychat/' : 'mychat://';
const Example = () => (
<Router
createReducer={reducerCreate}
getSceneStyle={getSceneStyle}
uriPrefix={prefix}>
<Overlay key="overlay">
<Modal key="modal"
hideNavBar
transitionConfig={() => ({ screenInterpolator: CardStackStyleInterpolator.forFadeFromBottomAndroid })}
>
<Lightbox key="lightbox">
<Stack
hideNavBar
key="root"
titleStyle={{ alignSelf: 'center' }}
>
<Scene key="echo" back clone component={EchoView} getTitle={({ navigation }) => navigation.state.key} />
<Scene key="launch" component={Launch} title="Launch" initial />
<Stack key="customNavBar" hideTabBar titleStyle={{alignSelf: 'center'}}>
<Scene
key="customNavBar1"
title="CustomNavBar 1"
navBar={CustomNavBar}
component={CustomNavBarView}
back
/>
<Scene
key="customNavBar2"
title="CustomNavBar 2"
navBar={CustomNavBar}
component={CustomNavBarView}
back
/>
<Scene
key="customNavBar3"
title="Another CustomNavBar"
navBar={CustomNavBar2}
component={CustomNavBarView}
back
/>
<Scene
key="hiddenNavBar"
title="hiddenNavBar"
component={CustomNavBarView}
hideNavBar={true}
back
/>
</Stack>
<Stack
back
backTitle="Back"
key="register"
duration={0}
navTransparent
>
<Scene key="_register" component={Register} title="Register" />
<Scene key="register2" component={Register} title="Register2" />
<Scene key="home" component={Home} title="Replace" type={ActionConst.REPLACE} />
</Stack>
<Drawer
hideNavBar
key="drawer"
contentComponent={DrawerContent}
drawerImage={MenuIcon}
drawerWidth={300}
>
{/*
Wrapper Scene needed to fix a bug where the tabs would
reload as a modal ontop of itself
*/}
<Scene hideNavBar panHandlers={null}>
<Tabs
key="tabbar"
swipeEnabled
showLabel={false}
tabBarStyle={styles.tabBarStyle}
activeBackgroundColor="white"
inactiveBackgroundColor="rgba(255, 0, 0, 0.5)"
>
<Stack
key="tab_1"
title="Tab #1"
tabBarLabel="TAB #1"
inactiveBackgroundColor="#FFF"
activeBackgroundColor="#DDD"
icon={TabIcon}
navigationBarStyle={{ backgroundColor: 'green' }}
titleStyle={{ color: 'white', alignSelf: 'center' }}
>
<Scene
key="tab_1_1"
component={TabView}
title="Tab #1_1"
onRight={() => alert('Right button')}
rightTitle="Right"
/>
<Scene
key="tab1_2"
component={TabView}
title="Tab #1_2"
back
titleStyle={{ color: 'black', alignSelf: 'center' }}
/>
</Stack>
<Stack
key="tab_2"
title="Tab #2"
icon={TabIcon}
initial
>
<Scene
key="tab_2_1"
component={TabView}
title="Tab #2_1"
renderRightButton={() => <Text>Right</Text>}
/>
<Scene
key="tab_2_2"
component={TabView}
title="Tab #2_2"
onBack={() => alert('onBack button!')}
hideDrawerButton
backTitle="Back!"
panHandlers={null}
/>
</Stack>
<Stack key="tab_3">
<Scene
key="tab_3_1"
component={TabView}
title="Tab #3"
icon={TabIcon}
rightTitle="Right3"
onRight={() => { }}
/>
</Stack>
<Scene key="tab_4_1" component={TabView} title="Tab #4" hideNavBar icon={TabIcon} />
<Stack key="tab_5">
<Scene key="tab_5_1" component={TabView} title="Tab #5" icon={TabIcon} />
</Stack>
</Tabs>
</Scene>
</Drawer>
</Stack>
<Scene key="demo_lightbox" component={DemoLightbox} />
</Lightbox>
<Scene key="error" component={ErrorModal} />
<Stack key="login" path="login/:data" titleStyle={{ alignSelf: 'center' }}>
<Scene
key="loginModal"
component={Login}
title="Login"
onExit={() => console.log('onExit')}
leftTitle="Cancel"
onLeft={Actions.pop}
/>
<Scene
key="loginModal2"
component={Login2}
title="Login2"
backTitle="Back"
panHandlers={null}
duration={1}
/>
<Scene
key="loginModal3"
hideNavBar
component={Login3}
title="Login3"
panHandlers={null}
duration={1}
/>
</Stack>
</Modal>
<Scene component={MessageBar} />
</Overlay>
</Router>
);
export default Example;