diff --git a/DefaultTabBar.js b/DefaultTabBar.js index 4cb92de9..d10b8ab9 100644 --- a/DefaultTabBar.js +++ b/DefaultTabBar.js @@ -16,6 +16,8 @@ const DefaultTabBar = createReactClass({ activeTab: PropTypes.number, tabs: PropTypes.array, backgroundColor: PropTypes.string, + activeBackgroundColor: PropTypes.string, + inactiveBackgroundColor: PropTypes.string, activeTextColor: PropTypes.string, inactiveTextColor: PropTypes.string, textStyle: Text.propTypes.style, @@ -26,6 +28,8 @@ const DefaultTabBar = createReactClass({ getDefaultProps() { return { + activeBackgroundColor: 'white', + inactiveBackgroundColor: 'white', activeTextColor: 'navy', inactiveTextColor: 'black', backgroundColor: null, @@ -36,7 +40,8 @@ const DefaultTabBar = createReactClass({ }, renderTab(name, page, isTabActive, onPressHandler) { - const { activeTextColor, inactiveTextColor, textStyle, } = this.props; + const { activeBackgroundColor, inactiveBackgroundColor, activeTextColor, inactiveTextColor, textStyle, } = this.props; + const backgroundColor = isTabActive ? activeBackgroundColor : inactiveBackgroundColor; const textColor = isTabActive ? activeTextColor : inactiveTextColor; const fontWeight = isTabActive ? 'bold' : 'normal'; @@ -48,7 +53,7 @@ const DefaultTabBar = createReactClass({ accessibilityTraits='button' onPress={() => onPressHandler(page)} > - + {name} diff --git a/ScrollableTabBar.js b/ScrollableTabBar.js index 0a491608..a9800450 100644 --- a/ScrollableTabBar.js +++ b/ScrollableTabBar.js @@ -21,6 +21,8 @@ const ScrollableTabBar = createReactClass({ activeTab: PropTypes.number, tabs: PropTypes.array, backgroundColor: PropTypes.string, + activeBackgroundColor: PropTypes.string, + inactiveBackgroundColor: PropTypes.string, activeTextColor: PropTypes.string, inactiveTextColor: PropTypes.string, scrollOffset: PropTypes.number, @@ -36,6 +38,8 @@ const ScrollableTabBar = createReactClass({ getDefaultProps() { return { scrollOffset: 52, + activeBackgroundColor: 'white', + inactiveBackgroundColor: 'white', activeTextColor: 'navy', inactiveTextColor: 'black', backgroundColor: null, @@ -125,7 +129,8 @@ const ScrollableTabBar = createReactClass({ }, renderTab(name, page, isTabActive, onPressHandler, onLayoutHandler) { - const { activeTextColor, inactiveTextColor, textStyle, } = this.props; + const { activeBackgroundColor, inactiveBackgroundColor, activeTextColor, inactiveTextColor, textStyle, } = this.props; + const backgroundColor = isTabActive ? activeBackgroundColor : inactiveBackgroundColor; const textColor = isTabActive ? activeTextColor : inactiveTextColor; const fontWeight = isTabActive ? 'bold' : 'normal'; @@ -137,7 +142,7 @@ const ScrollableTabBar = createReactClass({ onPress={() => onPressHandler(page)} onLayout={onLayoutHandler} > - + {name} diff --git a/index.js b/index.js index af94d866..9511761c 100644 --- a/index.js +++ b/index.js @@ -332,7 +332,7 @@ const ScrollableTabView = createReactClass({ if (!width || width <= 0 || Math.round(width) === Math.round(this.state.containerWidth)) { return; } - + if (Platform.OS === 'ios') { const containerWidthAnimatedValue = new Animated.Value(width); // Need to call __makeNative manually to avoid a native animated bug. See @@ -365,6 +365,12 @@ const ScrollableTabView = createReactClass({ if (this.props.tabBarBackgroundColor) { tabBarProps.backgroundColor = this.props.tabBarBackgroundColor; } + if (this.props.tabBarActiveBackgroundColor) { + tabBarProps.activeBackgroundColor = this.props.tabBarActiveBackgroundColor; + } + if (this.props.tabBarInactiveBackgroundColor) { + tabBarProps.inactiveBackgroundColor = this.props.tabBarInactiveBackgroundColor; + } if (this.props.tabBarActiveTextColor) { tabBarProps.activeTextColor = this.props.tabBarActiveTextColor; } @@ -377,6 +383,12 @@ const ScrollableTabView = createReactClass({ if (this.props.tabBarUnderlineStyle) { tabBarProps.underlineStyle = this.props.tabBarUnderlineStyle; } + if (this.props.tabBarTabStyle) { + tabBarProps.tabStyle = this.props.tabBarTabStyle; + } + if (this.props.tabBarContainerStyle) { + tabBarProps.style = this.props.tabBarContainerStyle; + } if (overlayTabs) { tabBarProps.style = { position: 'absolute',