File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,26 +3,23 @@ import {
33 AppRegistry ,
44} from 'react-native' ;
55import App from './src/App'
6- import { StackNavigator } from 'react-navigation' ;
6+ import { TabNavigator } from 'react-navigation' ;
77import SecondScreen from './src/SecondScreen'
88
99class reactNavigationSample extends Component {
10- static navigationOptions = {
11- title : 'Home Screen' ,
12- } ;
1310
1411 render ( ) {
1512 const { navigation } = this . props ;
1613
1714 return (
18- < App navigation = { navigation } />
15+ < App />
1916 ) ;
2017 }
2118}
2219
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 }
2623} ) ;
2724
2825AppRegistry . registerComponent ( 'reactNavigationSample' , ( ) => SimpleApp ) ;
Original file line number Diff line number Diff line change 33 StyleSheet ,
44 Text ,
55 Button ,
6+ Image ,
67 View
78} from 'react-native' ;
89import { StackNavigator } from 'react-navigation' ;
@@ -24,22 +25,31 @@ const styles = StyleSheet.create({
2425 color : '#333333' ,
2526 marginBottom : 5 ,
2627 } ,
28+ tabIcon : {
29+ width : 16 ,
30+ height : 16 ,
31+ } ,
2732} ) ;
2833
29- const App = ( props ) => {
30- const { navigate } = props . navigation ;
34+ const App = ( ) => {
3135
3236 return (
3337 < View style = { styles . container } >
3438 < Text style = { styles . welcome } >
3539 Welcome to React Native Navigation Sample!
3640 </ Text >
37- < Button
38- onPress = { ( ) => navigate ( 'SecondScreen' ) }
39- title = "Go to Second Screen"
40- />
4141 </ View >
4242 ) ;
4343}
4444
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+
4555export default App
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import React, { Component } from 'react';
22import {
33 StyleSheet ,
44 Text ,
5+ Image ,
56 View
67} from 'react-native' ;
78
@@ -17,6 +18,10 @@ const styles = StyleSheet.create({
1718 textAlign : 'center' ,
1819 margin : 10 ,
1920 } ,
21+ tabIcon : {
22+ width : 16 ,
23+ height : 16 ,
24+ } ,
2025} ) ;
2126
2227const SecondScreen = ( ) => {
@@ -30,7 +35,13 @@ const SecondScreen = () => {
3035}
3136
3237SecondScreen . 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+ ) }
3445} ;
3546
3647export default SecondScreen
You can’t perform that action at this time.
0 commit comments