File tree Expand file tree Collapse file tree 5 files changed +33
-15
lines changed Expand file tree Collapse file tree 5 files changed +33
-15
lines changed Original file line number Diff line number Diff line change @@ -3,26 +3,23 @@ import {
3
3
AppRegistry ,
4
4
} from 'react-native' ;
5
5
import App from './src/App'
6
- import { StackNavigator } from 'react-navigation' ;
6
+ import { TabNavigator } from 'react-navigation' ;
7
7
import SecondScreen from './src/SecondScreen'
8
8
9
9
class reactNavigationSample extends Component {
10
- static navigationOptions = {
11
- title : 'Home Screen' ,
12
- } ;
13
10
14
11
render ( ) {
15
12
const { navigation } = this . props ;
16
13
17
14
return (
18
- < App navigation = { navigation } />
15
+ < App />
19
16
) ;
20
17
}
21
18
}
22
19
23
- const SimpleApp = StackNavigator ( {
24
- Home : { screen : reactNavigationSample } ,
25
- SecondScreen : { screen : SecondScreen , title : 'ss' } ,
20
+ const SimpleApp = TabNavigator ( {
21
+ Home : { screen : App } ,
22
+ SecondScreen : { screen : SecondScreen }
26
23
} ) ;
27
24
28
25
AppRegistry . registerComponent ( 'reactNavigationSample' , ( ) => SimpleApp ) ;
Original file line number Diff line number Diff line change 3
3
StyleSheet ,
4
4
Text ,
5
5
Button ,
6
+ Image ,
6
7
View
7
8
} from 'react-native' ;
8
9
import { StackNavigator } from 'react-navigation' ;
@@ -24,22 +25,31 @@ const styles = StyleSheet.create({
24
25
color : '#333333' ,
25
26
marginBottom : 5 ,
26
27
} ,
28
+ tabIcon : {
29
+ width : 16 ,
30
+ height : 16 ,
31
+ } ,
27
32
} ) ;
28
33
29
- const App = ( props ) => {
30
- const { navigate } = props . navigation ;
34
+ const App = ( ) => {
31
35
32
36
return (
33
37
< View style = { styles . container } >
34
38
< Text style = { styles . welcome } >
35
39
Welcome to React Native Navigation Sample!
36
40
</ Text >
37
- < Button
38
- onPress = { ( ) => navigate ( 'SecondScreen' ) }
39
- title = "Go to Second Screen"
40
- />
41
41
</ View >
42
42
) ;
43
43
}
44
44
45
+ App . navigationOptions = {
46
+ tabBar : {
47
+ icon : ( ) => (
48
+ < Image
49
+ source = { require ( '../imgs/home.png' ) }
50
+ style = { [ styles . tabIcon , { tintColor : 'black' } ] }
51
+ />
52
+ ) }
53
+ } ;
54
+
45
55
export default App
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import React, { Component } from 'react';
2
2
import {
3
3
StyleSheet ,
4
4
Text ,
5
+ Image ,
5
6
View
6
7
} from 'react-native' ;
7
8
@@ -17,6 +18,10 @@ const styles = StyleSheet.create({
17
18
textAlign : 'center' ,
18
19
margin : 10 ,
19
20
} ,
21
+ tabIcon : {
22
+ width : 16 ,
23
+ height : 16 ,
24
+ } ,
20
25
} ) ;
21
26
22
27
const SecondScreen = ( ) => {
@@ -30,7 +35,13 @@ const SecondScreen = () => {
30
35
}
31
36
32
37
SecondScreen . navigationOptions = {
33
- title : 'Second Screen Title' ,
38
+ tabBar : {
39
+ icon : ( ) => (
40
+ < Image
41
+ source = { require ( '../imgs/home.png' ) }
42
+ style = { [ styles . tabIcon , { tintColor : 'black' } ] }
43
+ />
44
+ ) }
34
45
} ;
35
46
36
47
export default SecondScreen
You can’t perform that action at this time.
0 commit comments