Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | 3x 3x 52x 3x 49x 49x 3x 3x 3x 3x 9x | import React from "react";
import { Ionicons } from "@expo/vector-icons";
import { Tabs } from "expo-router";
import { useAccessibilitySettings } from "../hooks/useAccessibilitySettings";
import { useTheme } from "../hooks/useTheme";
const TABS = [
{
name: "settings",
title: "Settings",
iconFocused: "settings",
iconOutline: "settings-outline",
},
{
name: "(home-page)",
title: "Map",
iconFocused: "location",
iconOutline: "location-outline",
},
{
name: "shuttle-info/index",
title: "Shuttle",
iconFocused: "bus",
iconOutline: "bus-outline",
},
] as const;
type TabConfig = (typeof TABS)[number];
type BottomNavIconProps = {
readonly focused: boolean;
readonly iconFocused: TabConfig["iconFocused"];
readonly iconOutline: TabConfig["iconOutline"];
readonly color: string;
};
type TabBarIconRendererProps = {
readonly focused: boolean;
readonly color: string;
};
function BottomNavIcon({
focused,
iconFocused,
iconOutline,
color,
}: BottomNavIconProps) {
return (
<Ionicons
name={focused ? iconFocused : iconOutline}
color={color}
size={22}
/>
);
}
const TAB_ICON_RENDERERS: Record<
TabConfig["name"],
({ focused, color }: TabBarIconRendererProps) => React.JSX.Element
> = {
settings: ({ focused, color }) => (
<BottomNavIcon
focused={focused}
iconFocused="settings"
iconOutline="settings-outline"
color={color}
/>
),
"(home-page)": ({ focused, color }) => (
<BottomNavIcon
focused={focused}
iconFocused="location"
iconOutline="location-outline"
color={color}
/>
),
"shuttle-info/index": ({ focused, color }) => (
<BottomNavIcon
focused={focused}
iconFocused="bus"
iconOutline="bus-outline"
color={color}
/>
),
};
const createTabBarStyle = (tabBarBackground: string) => ({
position: "absolute" as const,
bottom: 0,
left: 0,
right: 0,
height: 78,
paddingBottom: 18,
paddingTop: 10,
backgroundColor: tabBarBackground,
borderTopLeftRadius: 18,
borderTopRightRadius: 18,
shadowColor: "#000",
shadowOpacity: 0.1,
shadowRadius: 12,
shadowOffset: { width: 0, height: -4 },
elevation: 10,
borderTopWidth: 0,
});
export const tabBarItemStyle = {
width: 52,
alignItems: "center" as const,
justifyContent: "center" as const,
};
/** Used by home page to show tab bar with correct theme (e.g. after hiding during navigation). */
export function useTabBarStyle() {
const { colors } = useTheme();
return createTabBarStyle(colors.tabBarBackground);
}
export default function BottomNav() {
const { colorBlindMode } = useAccessibilitySettings();
const { colors } = useTheme();
const primaryColor = colorBlindMode ? "#005F99" : colors.primary;
return (
<Tabs
screenOptions={{
headerShown: false,
tabBarStyle: createTabBarStyle(colors.tabBarBackground),
tabBarItemStyle,
tabBarActiveTintColor: primaryColor,
tabBarInactiveTintColor: primaryColor,
tabBarShowLabel: false,
}}
>
{TABS.map((tab) => (
<Tabs.Screen
key={tab.name}
name={tab.name}
options={{
title: tab.title,
tabBarIcon: TAB_ICON_RENDERERS[tab.name],
}}
/>
))}
{/* Stack screens like settings/general live under settings/_layout — not tab siblings; do not register them here (causes Expo Router warnings). */}
<Tabs.Screen name="indoor-navigation" options={{ href: null }} />
</Tabs>
);
}
|