5
5
Animated ,
6
6
StyleSheet ,
7
7
View ,
8
+ Text ,
8
9
} from 'react-native' ;
9
10
import shallowCompare from 'react-addons-shallow-compare' ;
10
11
import TouchableItem from './TouchableItem' ;
@@ -18,6 +19,10 @@ const styles = StyleSheet.create({
18
19
flexWrap : 'nowrap' ,
19
20
elevation : 4 ,
20
21
} ,
22
+ tablabel : {
23
+ color : 'white' ,
24
+ margin : 8 ,
25
+ } ,
21
26
tab : {
22
27
flex : 1 ,
23
28
} ,
@@ -29,16 +34,20 @@ const styles = StyleSheet.create({
29
34
} ,
30
35
} ) ;
31
36
37
+ type DefaultProps = {
38
+ renderLabel : ( scene : Scene ) => ?React . Element < any > ;
39
+ }
40
+
32
41
type Props = SceneRendererProps & {
33
42
pressColor ?: string ;
34
- renderLabel: ( scene : Scene ) => React . Element < any > ;
35
- renderIcon: ( scene : Scene ) => React . Element < any > ;
36
- renderIndicator: ( props : SceneRendererProps ) => React . Element < any > ;
43
+ renderLabel ? : ( scene : Scene ) => ? React . Element < any > ;
44
+ renderIcon ? : ( scene : Scene ) => ? React . Element < any > ;
45
+ renderIndicator ? : ( props : SceneRendererProps ) => ? React . Element < any > ;
37
46
tabStyle ?: any ;
38
47
style ? : any ;
39
48
}
40
49
41
- export default class TabBarTop extends Component < void , Props , void > {
50
+ export default class TabBarTop extends Component < DefaultProps , Props , void > {
42
51
static propTypes = {
43
52
...SceneRendererPropType ,
44
53
pressColor : TouchableItem . propTypes . pressColor ,
@@ -49,6 +58,10 @@ export default class TabBarTop extends Component<void, Props, void> {
49
58
style : View . propTypes . style ,
50
59
} ;
51
60
61
+ static defaultProps = {
62
+ renderLabel : ( { route } ) => route . title ? < Text style = { styles . tablabel } > { route . title } </ Text > : null ,
63
+ } ;
64
+
52
65
shouldComponentUpdate ( nextProps : Props , nextState : void ) {
53
66
return shallowCompare ( this , nextProps, nextState) ;
54
67
}
0 commit comments