@@ -20,6 +20,7 @@ const {Code, Value, interpolate, block, set} = Reanimated;
20
20
21
21
const DEFAULT_HEIGHT = 48 ;
22
22
const INDICATOR_INSET = Spacings . s4 ;
23
+ const DEFAULT_BACKGROUND_COLOR = Colors . white ;
23
24
24
25
const DEFAULT_LABEL_STYLE = {
25
26
...Typography . text80 ,
@@ -54,6 +55,10 @@ class TabBar extends PureComponent {
54
55
* Show Tab Bar bottom shadow
55
56
*/
56
57
enableShadow : PropTypes . bool ,
58
+ /**
59
+ * custom shadow style
60
+ */
61
+ shadowStyle : ViewPropTypes . style ,
57
62
// /**
58
63
// * The minimum number of tabs to render in scroll mode
59
64
// */
@@ -95,6 +100,10 @@ class TabBar extends PureComponent {
95
100
* Apply background color on press for TouchableOpacity
96
101
*/
97
102
activeBackgroundColor : PropTypes . string ,
103
+ /**
104
+ * The TabBar background Color
105
+ */
106
+ backgroundColor : PropTypes . string ,
98
107
/**
99
108
* The TabBar container width
100
109
*/
@@ -107,7 +116,9 @@ class TabBar extends PureComponent {
107
116
108
117
static defaultProps = {
109
118
labelStyle : DEFAULT_LABEL_STYLE ,
110
- selectedLabelStyle : DEFAULT_SELECTED_LABEL_STYLE
119
+ selectedLabelStyle : DEFAULT_SELECTED_LABEL_STYLE ,
120
+ backgroundColor : DEFAULT_BACKGROUND_COLOR
121
+
111
122
// containerWidth: Constants.screenWidth
112
123
} ;
113
124
@@ -384,18 +395,22 @@ class TabBar extends PureComponent {
384
395
return block ( nodes ) ;
385
396
} ;
386
397
398
+ getShadowStyle ( ) {
399
+ const { enableShadow, shadowStyle} = this . props ;
400
+ return enableShadow && ( shadowStyle || styles . containerShadow ) ;
401
+ }
402
+
387
403
render ( ) {
388
- const { height, enableShadow , containerStyle, testID} = this . props ;
404
+ const { height, containerStyle, testID, backgroundColor } = this . props ;
389
405
const { itemsWidths, scrollEnabled, fadeLeft, fadeRight} = this . state ;
390
406
return (
391
407
< View
392
- style = { [ styles . container , enableShadow && styles . containerShadow , { width : this . containerWidth } , containerStyle ] }
408
+ style = { [ styles . container , this . getShadowStyle ( ) , { width : this . containerWidth } , containerStyle ] }
393
409
>
394
410
< ScrollView
395
411
ref = { this . tabBar }
396
412
horizontal
397
413
showsHorizontalScrollIndicator = { false }
398
- style = { styles . tabBarScroll }
399
414
contentContainerStyle = { { minWidth : this . containerWidth } }
400
415
scrollEnabled = { scrollEnabled }
401
416
onScroll = { this . onScroll }
@@ -404,7 +419,7 @@ class TabBar extends PureComponent {
404
419
snapToOffsets = { this . getSnapBreakpoints ( ) }
405
420
decelerationRate = { 'fast' }
406
421
>
407
- < View style = { [ styles . tabBar , height && { height} , { paddingHorizontal : this . centerOffset } ] } >
422
+ < View style = { [ styles . tabBar , height && { height} , { paddingHorizontal : this . centerOffset , backgroundColor } ] } >
408
423
{ this . renderTabBarItems ( ) }
409
424
</ View >
410
425
{ this . renderSelectedIndicator ( ) }
@@ -423,14 +438,10 @@ const styles = StyleSheet.create({
423
438
} ,
424
439
tabBar : {
425
440
flex : 1 ,
426
- backgroundColor : Colors . white ,
427
441
height : DEFAULT_HEIGHT ,
428
442
flexDirection : 'row' ,
429
443
justifyContent : 'space-between'
430
444
} ,
431
- tabBarScroll : {
432
- backgroundColor : Colors . white
433
- } ,
434
445
tabBarScrollContent : {
435
446
minWidth : Constants . screenWidth
436
447
} ,
0 commit comments