diff --git a/src/components/TabSelector/TabSelector.js b/src/components/TabSelector/TabSelector.js index 79cd1a6dd17d..4efa033c60d0 100644 --- a/src/components/TabSelector/TabSelector.js +++ b/src/components/TabSelector/TabSelector.js @@ -82,7 +82,6 @@ const getBackgroundColor = (position, routesLength, tabIndex) => { function TabSelector({state, navigation, onTabPress, position}) { const {translate} = useLocalize(); - return ( {_.map(state.routes, (route, index) => { @@ -120,6 +119,7 @@ function TabSelector({state, navigation, onTabPress, position}) { activeOpacity={activeOpacity} inactiveOpacity={inactiveOpacity} backgroundColor={backgroundColor} + isFocused={isFocused} /> ); })} diff --git a/src/components/TabSelector/TabSelectorItem.js b/src/components/TabSelector/TabSelectorItem.js index d0ea8fcc773b..6611b8acf914 100644 --- a/src/components/TabSelector/TabSelectorItem.js +++ b/src/components/TabSelector/TabSelectorItem.js @@ -1,4 +1,4 @@ -import {Animated} from 'react-native'; +import {Animated, StyleSheet} from 'react-native'; import React from 'react'; import PropTypes from 'prop-types'; import styles from '../../styles/styles'; @@ -27,6 +27,9 @@ const propTypes = { /** Animated opacity value while the label is in active state */ // eslint-disable-next-line activeOpacity: PropTypes.any, + + /** Whether this tab is active */ + isFocused: PropTypes.bool, }; const defaultProps = { @@ -36,29 +39,32 @@ const defaultProps = { backgroundColor: '', inactiveOpacity: 1, activeOpacity: 0, + isFocused: false, }; -const AnimatedPressableWithFeedback = Animated.createAnimatedComponent(PressableWithFeedback); - -function TabSelectorItem({icon, title, onPress, backgroundColor, activeOpacity, inactiveOpacity}) { +function TabSelectorItem({icon, title, onPress, backgroundColor, activeOpacity, inactiveOpacity, isFocused}) { return ( - - - - + {({hovered}) => ( + + + + + )} + ); } diff --git a/src/styles/styles.js b/src/styles/styles.js index f36e552c2ecd..d4aacfff96aa 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -3486,11 +3486,17 @@ const styles = (theme) => ({ tabText: (isSelected) => ({ marginLeft: 8, - fontFamily: isSelected ? fontFamily.EXP_NEUE_BOLD : fontFamily.EXP_NEUE, - fontWeight: isSelected ? fontWeightBold : 400, + fontFamily: fontFamily.EXP_NEUE_BOLD, + fontWeight: fontWeightBold, color: isSelected ? theme.textLight : theme.textSupporting, }), + tabBackground: (hovered, isFocused, background) => ({ + backgroundColor: hovered && !isFocused ? theme.highlightBG : background, + }), + + tabOpacity: (hovered, isFocused, activeOpacityValue, inactiveOpacityValue) => (hovered && !isFocused ? inactiveOpacityValue : activeOpacityValue), + /** * @param {String} backgroundColor * @param {Number} height