diff --git a/src/components/SearchBar.jsx b/src/components/SearchBar.jsx index b6c76ee2..f8f40f7b 100644 --- a/src/components/SearchBar.jsx +++ b/src/components/SearchBar.jsx @@ -137,7 +137,7 @@ export const SearchBar = ({ }} {...searchbarProps} /> - {showCancelButton && ( + {showCancelButton && searchText.length > 0 && ( { - const handleOnPress = useCallback( - () => navigation.navigate(value), - [navigation, value] - ); +export const Tab = forwardRef( + ({ label, value, navigation, flex, count }, ref) => { + const handleOnPress = useCallback( + () => navigation.navigate(value), + [navigation, value] + ); - return ( - - - + - {label} - - - - ); -}); + + {label} + + {count !== undefined && ( + + ({count}) + + )} + + + ); + } +); Tab.displayName = "Tab"; @@ -34,4 +55,5 @@ Tab.propTypes = { label: PropTypes.string.isRequired, value: PropTypes.string.isRequired, navigation: PropTypes.object, + count: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), }; diff --git a/src/components/SegmentedTopBar/index.jsx b/src/components/SegmentedTopBar/index.jsx index 028a3e05..86bbb0cc 100644 --- a/src/components/SegmentedTopBar/index.jsx +++ b/src/components/SegmentedTopBar/index.jsx @@ -42,11 +42,13 @@ import { Tab } from "./Tab"; * * * * * @@ -70,10 +72,11 @@ export const SegmentedTopBar = ({ routes.map(({ key, name }) => { const { options } = descriptors[key]; const label = options.tabBarLabel ?? options.title ?? name; + const count = options.count; - return { label, value: name, ref: createRef() }; + return { label, value: name, ref: createRef(), count }; }), - [] + [descriptors, routes] ); useLayoutEffect(() => { @@ -93,8 +96,9 @@ export const SegmentedTopBar = ({ return ( {measures.length > 0 && } - {tabsData.map(({ label, value, ref }) => ( + {tabsData.map(({ label, value, ref, count }) => ( 3 ? label.length : 1} key={value} label={label} @@ -124,5 +128,5 @@ SegmentedTopBar.propTypes = { SegmentedTopBar.defaultProps = { tabs: [], - height: moderateScale(36), + height: moderateScale(48), };