feat: update TabLayout to improve tab bar styling and handle safe area insets
This commit is contained in:
parent
65b61ce05e
commit
533b58ccf4
|
|
@ -1,15 +1,19 @@
|
||||||
import { Tabs } from 'expo-router'
|
import { Tabs } from 'expo-router'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { StyleSheet, View, Text } from 'react-native'
|
import { StyleSheet, View, Text, Platform } from 'react-native'
|
||||||
import { LinearGradient } from 'expo-linear-gradient'
|
import { LinearGradient } from 'expo-linear-gradient'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||||
|
|
||||||
import { HomeIcon, MessageIcon, MyIcon, VideoIcon } from '@/components/icon'
|
import { HomeIcon, MessageIcon, MyIcon, VideoIcon } from '@/components/icon'
|
||||||
|
|
||||||
|
const TAB_BAR_HEIGHT = 60
|
||||||
|
|
||||||
export default function TabLayout() {
|
export default function TabLayout() {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const insets = useSafeAreaInsets()
|
const insets = useSafeAreaInsets()
|
||||||
|
// Android 不需要额外的底部安全区域,iOS 和 Web 需要
|
||||||
|
const bottomInset = Platform.OS === 'android' ? 0 : insets.bottom
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tabs
|
<Tabs
|
||||||
|
|
@ -20,19 +24,26 @@ export default function TabLayout() {
|
||||||
tabBarHideOnKeyboard: true,
|
tabBarHideOnKeyboard: true,
|
||||||
tabBarShowLabel: true,
|
tabBarShowLabel: true,
|
||||||
tabBarStyle: {
|
tabBarStyle: {
|
||||||
backgroundColor: '#1C1E22CC',
|
position: 'absolute',
|
||||||
height: 84 + insets.bottom,
|
backgroundColor: '#1C1E22',
|
||||||
|
height: TAB_BAR_HEIGHT + bottomInset,
|
||||||
paddingTop: 4,
|
paddingTop: 4,
|
||||||
paddingBottom: insets.bottom,
|
paddingBottom: bottomInset,
|
||||||
paddingLeft: 4,
|
paddingLeft: 4,
|
||||||
paddingRight: 4,
|
paddingRight: 4,
|
||||||
borderTopWidth: 0,
|
borderTopWidth: 0,
|
||||||
|
elevation: 0,
|
||||||
|
shadowOpacity: 0,
|
||||||
|
borderTopColor: 'transparent',
|
||||||
},
|
},
|
||||||
tabBarLabelStyle: {
|
tabBarLabelStyle: {
|
||||||
color: '#FFFFFF',
|
color: '#FFFFFF',
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
fontWeight: '400',
|
fontWeight: '400',
|
||||||
},
|
},
|
||||||
|
tabBarBackground: () => (
|
||||||
|
<View style={{ flex: 1, backgroundColor: '#1C1E22' }} />
|
||||||
|
),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Tabs.Screen
|
<Tabs.Screen
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue