File tree 7 files changed +88
-2
lines changed
7 files changed +88
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
12
12
import TabNavigator from 'react-native-tab-navigator' ;
13
13
import TabPage1 from './TabPage1.js'
14
14
import TabPage2 from './TabPage2.js'
15
+ import TabPage3 from './TabPage3.js'
15
16
16
17
class MainPage extends Component {
17
18
constructor ( props ) {
@@ -49,6 +50,15 @@ class MainPage extends Component {
49
50
onPress = { ( ) => this . setState ( { selectedTab : 'tab2' } ) } >
50
51
< TabPage2 routerCallback = { this . jumpPage } />
51
52
</ TabNavigator . Item >
53
+
54
+ < TabNavigator . Item
55
+ selected = { this . state . selectedTab === 'tab3' }
56
+ title = "Tab3"
57
+ renderIcon = { ( ) => < Image source = { require ( './res/icon_bottomtag_home_n.png' ) } style = { styles . tabImage } /> }
58
+ renderSelectedIcon = { ( ) => < Image source = { require ( './res/icon_bottomtag_home_s.png' ) } style = { styles . tabImage } /> }
59
+ onPress = { ( ) => this . setState ( { selectedTab : 'tab3' } ) } >
60
+ < TabPage3 routerCallback = { this . jumpPage } />
61
+ </ TabNavigator . Item >
52
62
</ TabNavigator >
53
63
</ View >
54
64
) ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Sample React Native App
3
+ * https://github.com/facebook/react-native
4
+ * @flow
5
+ */
6
+ // 'use strict';
7
+ import React , { Component } from 'react' ;
8
+ import {
9
+ View ,
10
+ Text ,
11
+ StyleSheet
12
+ } from 'react-native' ;
13
+
14
+ import SecondPage from './SecondPage.js'
15
+
16
+ class TestPage3 extends Component {
17
+ constructor ( props ) {
18
+ super ( props ) ;
19
+ this . toRoute = this . toRoute . bind ( this ) ;
20
+ }
21
+
22
+ toRoute ( ) {
23
+ var r = { name : 'From TabPage3' ,
24
+ component : SecondPage } ;
25
+ this . props . routerCallback ( 'toRoute' , r ) ;
26
+ }
27
+
28
+ render ( ) {
29
+ return (
30
+ < View style = { { flex : 1 } } >
31
+
32
+ < Text style = { styles . textStyle } onPress = { this . toRoute } > Tab 页面 3</ Text >
33
+
34
+ </ View >
35
+ ) ;
36
+ }
37
+ } ;
38
+
39
+ var styles = StyleSheet . create ( {
40
+ textStyle :{
41
+ backgroundColor :'#eee' ,
42
+ color :'#000' ,
43
+ fontSize :30 ,
44
+ marginTop :30 ,
45
+ } ,
46
+ } ) ;
47
+
48
+ export default TestPage3 ;
Original file line number Diff line number Diff line change
1
+ import React from "react" ;
2
+ import { StyleSheet , Image } from 'react-native' ;
3
+
4
+ export default class NavBackButton extends React . Component {
5
+ render ( ) {
6
+ return (
7
+ < Image source = { require ( '../../res/icon_nav_back.png' ) } style = { styles . backButton } />
8
+ ) ;
9
+ }
10
+ }
11
+
12
+ const styles = StyleSheet . create ( {
13
+ backButton : {
14
+ width : 10 ,
15
+ height : 17 ,
16
+ marginLeft : 10 ,
17
+ marginTop : 3 ,
18
+ marginRight : 10 ,
19
+ } ,
20
+ } ) ;
Original file line number Diff line number Diff line change 6
6
7
7
import Router from 'react-native-simple-router' ;
8
8
import MainPage from './MainPage' ;
9
+ import NavBackButton from './components/icons/NavBackButton.js'
9
10
10
11
// 声明第一个页面
11
12
const firstRoute = {
@@ -19,18 +20,25 @@ class ReactNativeCodeSnippet extends Component {
19
20
< Router
20
21
firstRoute = { firstRoute }
21
22
handleBackAndroid
22
- headerStyle = { styles . header }
23
+ headerStyle = { styles . navHeader }
24
+ titleStyle = { styles . navTitle } // 标题的样式
25
+ backButtonComponent = { NavBackButton } // 返回按钮使用箭头
23
26
ref = { 'router' }
24
27
/>
25
28
) ;
26
29
}
27
30
}
28
31
29
32
const styles = StyleSheet . create ( {
30
- header : {
33
+ navHeader : {
31
34
backgroundColor : '#fcaf17' ,
32
35
} ,
36
+ navTitle : {
37
+ textAlign : 'center' ,
38
+ }
33
39
} ) ;
34
40
35
41
// 一定要注意引号中的'ReactNativeCodeSnippet'必须与MainActivity中getMainComponentName()的返回值一致,否则会报错
36
42
AppRegistry . registerComponent ( 'ReactNativeCodeSnippet' , ( ) => ReactNativeCodeSnippet ) ;
43
+
44
+
You can’t perform that action at this time.
0 commit comments