Skip to content
Draft
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
18 changes: 15 additions & 3 deletions packages/mobile/src/components/bottom-tab-bar/BottomTabBar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback } from 'react'
import { useCallback, useEffect, useRef } from 'react'

import type {
BottomTabNavigationEventMap,
Expand Down Expand Up @@ -69,6 +69,18 @@ export const BottomTabBar = (props: BottomTabBarProps) => {
const { translationAnim, navigation, state } = props
const { routes, index: activeIndex } = state
const insets = useSafeAreaInsets()
const lastNonZeroBottomInset = useRef(insets.bottom)

useEffect(() => {
if (insets.bottom > 0) {
lastNonZeroBottomInset.current = insets.bottom
}
}, [insets.bottom])

// Preserve the previous non-zero inset to avoid brief 0 inset flashes,
// which can expose the view behind the tab bar safe area.
const effectiveBottomInset =
insets.bottom === 0 ? lastNonZeroBottomInset.current : insets.bottom

const handlePress = useCallback(
(isFocused: boolean, routeName: string, routeKey: string) => {
Expand Down Expand Up @@ -100,7 +112,7 @@ export const BottomTabBar = (props: BottomTabBarProps) => {
<Animated.View
style={[
{ zIndex: 4, elevation: 4 },
interpolatePostion(translationAnim, insets.bottom)
interpolatePostion(translationAnim, effectiveBottomInset)
]}
>
<Flex
Expand All @@ -110,7 +122,7 @@ export const BottomTabBar = (props: BottomTabBarProps) => {
backgroundColor='surface1'
wrap='nowrap'
justifyContent='space-evenly'
pb={insets.bottom}
pb={effectiveBottomInset}
>
{routes.map(({ name, key }, index) => {
const BottomTabBarButton = bottomTabBarButtons[name]
Expand Down