Skip to content

Commit 9180d9d

Browse files
committed
added basic router
1 parent 25d8d8a commit 9180d9d

File tree

9 files changed

+109
-7
lines changed

9 files changed

+109
-7
lines changed

mobile/ReactNativeTutorial/app/App.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22
import React from 'react';
33
import { Provider } from 'react-redux';
44
import store from './setup/store';
5-
import Comments from './bundles/comments/Comments';
5+
import Router from './setup/Router';
66

7-
type PropsType = {
8-
9-
}
10-
11-
const App = (props: PropsType) => (
7+
const App = () => (
128
<Provider store={store}>
13-
<Comments />
9+
<Router />
1410
</Provider>
1511
);
1612

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// @flow
2+
import React from 'react';
3+
import { View, Text } from 'react-native';
4+
5+
import styles from './FooterStyle';
6+
7+
type PropsType = {
8+
9+
}
10+
11+
const Footer = (props: PropsType) => (
12+
<View style={styles.container}>
13+
</View>
14+
);
15+
16+
export default Footer;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { StyleSheet } from 'react-native';
2+
3+
const styles = StyleSheet.create({
4+
container: {
5+
height: 50,
6+
backgroundColor: '#EFEFF2'
7+
},
8+
});
9+
10+
export default styles;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// @flow
2+
import React from 'react';
3+
import { View } from 'react-native';
4+
import List from './List/List';
5+
import Footer from './Footer/Footer';
6+
7+
import styles from './IndexStyle';
8+
9+
type PropsType = {
10+
11+
}
12+
13+
const Index = (props: PropsType) => (
14+
<View style={styles.container}>
15+
<List {...props} />
16+
<Footer />
17+
</View>
18+
);
19+
20+
export default Index;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { StyleSheet } from 'react-native';
2+
3+
const styles = StyleSheet.create({
4+
container: {
5+
flex: 1,
6+
},
7+
});
8+
9+
export default styles;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// @flow
2+
import React from 'react';
3+
import { ListView } from 'react-native';
4+
5+
import styles from './ListStyle';
6+
7+
type PropsType = {
8+
9+
}
10+
11+
const List = (props: PropsType) => (
12+
<ListView
13+
style={styles.container}
14+
dataSource={new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 })}
15+
renderRow={() => null}
16+
>
17+
</ListView>
18+
);
19+
20+
export default List;
21+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { StyleSheet } from 'react-native';
2+
3+
const styles = StyleSheet.create({
4+
container: {
5+
},
6+
});
7+
8+
export default styles;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import Add from '../bundles/comments/components/Add/Add';
3+
import Index from '../bundles/comments/components/Index/Index';
4+
import { Scene, Router, Reducer } from 'react-native-router-flux'
5+
6+
const reducerCreate = params => {
7+
const defaultReducer = Reducer(params);
8+
return (state, action)=>{
9+
console.log(`Executing navigation action %c${action.type}`, 'color: #519C00');
10+
return defaultReducer(state, action);
11+
}
12+
};
13+
14+
export default () => (
15+
<Router createReducer={reducerCreate} sceneStyle={{backgroundColor:'#F7F7F7', paddingTop: 66}}>
16+
<Scene key="root">
17+
<Scene key="comments/index" component={Index} title="Comments" initial={true} />
18+
<Scene key="comments/add" component={Add} title="Add Comments" />
19+
</Scene>
20+
</Router>
21+
)

mobile/ReactNativeTutorial/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"react": "15.3.2",
1313
"react-native": "0.37.0",
1414
"react-native-elements": "^0.6.3",
15+
"react-native-router-flux": "^3.37.0",
1516
"react-native-vector-icons": "^2.1.0",
1617
"react-redux": "^4.4.6",
1718
"redux": "^3.6.0",

0 commit comments

Comments
 (0)