@@ -28,6 +28,7 @@ const ScrollableTabBar = React.createClass({
28
28
tabStyle : View . propTypes . style ,
29
29
tabsContainerStyle : View . propTypes . style ,
30
30
textStyle : Text . propTypes . style ,
31
+ renderTabName : React . PropTypes . func ,
31
32
} ,
32
33
33
34
getDefaultProps ( ) {
@@ -41,6 +42,7 @@ const ScrollableTabBar = React.createClass({
41
42
style : { } ,
42
43
tabStyle : { } ,
43
44
tabsContainerStyle : { } ,
45
+ renderTabName : this . renderTabName ,
44
46
} ;
45
47
} ,
46
48
@@ -124,9 +126,6 @@ const ScrollableTabBar = React.createClass({
124
126
125
127
renderTabOption ( name , page ) {
126
128
const isTabActive = this . props . activeTab === page ;
127
- const { activeTextColor, inactiveTextColor, textStyle, } = this . props ;
128
- const textColor = isTabActive ? activeTextColor : inactiveTextColor ;
129
- const fontWeight = isTabActive ? 'bold' : 'normal' ;
130
129
131
130
return < Button
132
131
key = { `${ name } _${ page } ` }
@@ -136,14 +135,22 @@ const ScrollableTabBar = React.createClass({
136
135
onPress = { ( ) => this . props . goToPage ( page ) }
137
136
onLayout = { this . measureTab . bind ( this , page ) }
138
137
>
139
- < View style = { [ styles . tab , this . props . tabStyle , ] } >
140
- < Text style = { [ { color : textColor , fontWeight, } , textStyle , ] } >
141
- { name }
142
- </ Text >
143
- </ View >
138
+ { this . renderTabName ( name , page , isTabActive ) }
144
139
</ Button > ;
145
140
} ,
146
141
142
+ renderTabName ( name , page , isTabActive ) {
143
+ const { activeTextColor, inactiveTextColor, textStyle, } = this . props ;
144
+ const textColor = isTabActive ? activeTextColor : inactiveTextColor ;
145
+ const fontWeight = isTabActive ? 'bold' : 'normal' ;
146
+
147
+ return < View style = { [ styles . tab , this . props . tabStyle , ] } >
148
+ < Text style = { [ { color : textColor , fontWeight, } , textStyle , ] } >
149
+ { name }
150
+ </ Text >
151
+ </ View > ;
152
+ } ,
153
+
147
154
measureTab ( page , event ) {
148
155
const { x, width, height, } = event . nativeEvent . layout ;
149
156
this . _tabsMeasurements [ page ] = { left : x , right : x + width , width, height, } ;
@@ -163,7 +170,7 @@ const ScrollableTabBar = React.createClass({
163
170
width : this . state . _widthTabUnderline ,
164
171
} ;
165
172
166
- return < View
173
+ return < View
167
174
style = { [ styles . container , { backgroundColor : this . props . backgroundColor , } , this . props . style , ] }
168
175
onLayout = { this . onContainerLayout }
169
176
>
0 commit comments