Skip to content

fix: Blinking of the bottom tab on native platforms #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/components/Navigation/TopLevelBottomTabBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ function TopLevelBottomTabBar() {
return SCREENS_WITH_BOTTOM_TAB_BAR.includes(focusedRoute?.name ?? '') || isSplitNavigatorName(focusedRoute?.name);
});

// That means it's visible and it's not covered by the overlay.
const isBottomTabVisibleDirectly = useIsBottomTabVisibleDirectly();

const shouldDisplayTopLevelBottomTabBar = isAfterClosingTransition && shouldUseNarrowLayout ? isScreenWithBottomTabFocused : isBottomTabVisibleDirectly;
const shouldDisplayBottomBar = shouldUseNarrowLayout ? isScreenWithBottomTabFocused : isBottomTabVisibleDirectly;
const isReadyToDisplayBottomBar = isAfterClosingTransition && shouldDisplayBottomBar;

useEffect(() => {
cancelAfterInteractions.current?.cancel();

if (!shouldDisplayTopLevelBottomTabBar) {
if (!shouldDisplayBottomBar) {
// If the bottom tab is not visible, that means there is a screen covering it.
// In that case we need to set the flag to true because there will be a transition for which we need to wait.
setIsAfterClosingTransition(false);
Expand All @@ -61,16 +63,16 @@ function TopLevelBottomTabBar() {
setIsAfterClosingTransition(true);
});
}
}, [shouldDisplayTopLevelBottomTabBar]);
}, [shouldDisplayBottomBar]);

return (
<View style={styles.topLevelBottomTabBar(shouldDisplayTopLevelBottomTabBar, shouldUseNarrowLayout, paddingBottom)}>
<View style={styles.topLevelBottomTabBar(isReadyToDisplayBottomBar, shouldUseNarrowLayout, paddingBottom)}>
{/* We are not rendering BottomTabBar conditionally for two reasons
1. It's faster to hide/show it than mount a new when needed.
2. We need to hide tooltips as well if they were displayed. */}
<BottomTabBar
selectedTab={selectedTab}
isTooltipAllowed={shouldDisplayTopLevelBottomTabBar}
isTooltipAllowed={isReadyToDisplayBottomBar}
/>
</View>
);
Expand Down
5 changes: 1 addition & 4 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,8 @@ const styles = (theme: ThemeColors) =>
// We have to use position fixed to make sure web on safari displays the bottom tab bar correctly.
// On natives we can use absolute positioning.
position: Platform.OS === 'web' ? 'fixed' : 'absolute',
display: shouldDisplayTopLevelBottomTabBar ? 'flex' : 'none',
width: shouldUseNarrowLayout ? '100%' : variables.sideBarWidth,
transform: [
// This conditional style is here to hide the bottom tab bar when it's not needed.
shouldDisplayTopLevelBottomTabBar ? {translateY: 0} : {translateY: bottomSafeAreaOffset + variables.bottomTabHeight},
],
paddingBottom: bottomSafeAreaOffset,
bottom: 0,

Expand Down
Loading