diff --git a/src/view/com/pager/TabBar.tsx b/src/view/com/pager/TabBar.tsx index 1cdb514b2c..56c1413a49 100644 --- a/src/view/com/pager/TabBar.tsx +++ b/src/view/com/pager/TabBar.tsx @@ -38,8 +38,13 @@ export function TabBar({ const scrollX = useSharedValue(0) const didScroll = useSharedValue(false) + const didLayout = ( + layouts.length === items.length && + layouts.every(l => l !== undefined) + ); + const indicatorStyle = useAnimatedStyle(() => { - if (layouts.length < items.length - 1 || layouts.some(l => l === undefined)) { + if (!didLayout) { return {} } return { @@ -113,11 +118,15 @@ export function TabBar({ }} scrollEventThrottle={16}> {items.map((item, i) => { + const isSelected = i === selectedPage return ( onItemLayout(e, i)} - style={[styles.item]} + style={[styles.item, { + borderBottomColor: (!didLayout && isSelected) ? indicatorColor : 'transparent', + borderBottomWidth: 3 + }]} hoverStyle={pal.viewLight} onPress={() => onPressItem(i)}> ) })} - + />} ) } -export function MaybeHighlightedText({ approxIndex, index, style, type, ...rest }) { +export function MaybeHighlightedText({ approxIndex, index, type, ...rest }) { const pal = usePalette('default') const theme = useTheme() const typography = theme.typography[type] @@ -152,7 +161,7 @@ export function MaybeHighlightedText({ approxIndex, index, style, type, ...rest color: interpolateColor(Math.min(Math.abs(approxIndex.value - index), 1), [0, 1], [pal.text.color, pal.textLight.color]) })) return ( - + ) }