|
| 1 | +import React from "react"; |
| 2 | +import { Tabs } from "expo-router"; |
| 3 | +import { TextStyle, ViewStyle } from "react-native"; |
| 4 | +import { useSafeAreaInsets } from "react-native-safe-area-context"; |
| 5 | +import { useTheme } from "tamagui"; |
| 6 | +import { useTranslation } from "react-i18next"; |
| 7 | +import { useNetInfoContext } from "../../../../../contexts/net-info-banner/NetInfoContext"; |
| 8 | +import { Icon } from "../../../../../components/Icon"; |
| 9 | + |
| 10 | +export default function TabLayout() { |
| 11 | + const insets = useSafeAreaInsets(); |
| 12 | + const theme = useTheme(); |
| 13 | + const { t } = useTranslation("tabs"); |
| 14 | + |
| 15 | + const { shouldDisplayBanner } = useNetInfoContext(); |
| 16 | + |
| 17 | + return ( |
| 18 | + <Tabs |
| 19 | + screenOptions={{ |
| 20 | + tabBarActiveTintColor: theme.purple5?.val, |
| 21 | + tabBarHideOnKeyboard: true, |
| 22 | + headerShown: false, |
| 23 | + tabBarStyle: [ |
| 24 | + $tabBar, |
| 25 | + { |
| 26 | + height: insets.bottom + 60, |
| 27 | + ...(shouldDisplayBanner && insets?.bottom ? { marginBottom: -insets.bottom + 10 } : {}), |
| 28 | + }, |
| 29 | + ], |
| 30 | + tabBarLabelStyle: $tabBarLabel, |
| 31 | + tabBarAllowFontScaling: false, |
| 32 | + }} |
| 33 | + > |
| 34 | + <Tabs.Screen |
| 35 | + name="index" |
| 36 | + options={{ |
| 37 | + title: "Report", |
| 38 | + tabBarIcon: ({ color }) => <Icon icon="observation" color={color} />, |
| 39 | + }} |
| 40 | + /> |
| 41 | + <Tabs.Screen |
| 42 | + name="resources" |
| 43 | + options={{ |
| 44 | + title: "Resources", |
| 45 | + tabBarIcon: ({ color }) => <Icon icon="quickReport" color={color} />, |
| 46 | + href: "/resources", |
| 47 | + }} |
| 48 | + /> |
| 49 | + <Tabs.Screen |
| 50 | + name="more" |
| 51 | + options={{ |
| 52 | + title: t("more"), |
| 53 | + tabBarIcon: ({ color }) => <Icon icon="more" color={color} />, |
| 54 | + }} |
| 55 | + /> |
| 56 | + </Tabs> |
| 57 | + ); |
| 58 | +} |
| 59 | + |
| 60 | +const $tabBar: ViewStyle = { |
| 61 | + backgroundColor: "white", |
| 62 | +}; |
| 63 | + |
| 64 | +const $tabBarLabel: TextStyle = { |
| 65 | + marginBottom: 11, |
| 66 | + marginTop: -5, |
| 67 | + fontFamily: "Roboto", |
| 68 | + fontSize: 12, |
| 69 | +}; |
0 commit comments