import React from "react"; import { Pressable, View } from "react-native"; import { Ionicons } from "@expo/vector-icons"; import { useColorScheme } from "nativewind"; import { Text } from "./text"; export interface BottomNavItem { id: T; label: string; /** Ionicons glyph name (active state). */ icon: keyof typeof Ionicons.glyphMap; /** Optional outline variant for the inactive state. Defaults to `icon`. */ iconOutline?: keyof typeof Ionicons.glyphMap; /** When false the tab is hidden from the strip. */ visible?: boolean; } export interface BottomNavProps { items: BottomNavItem[]; active: T; onChange: (tab: T) => void; } /** * Sticky tab strip used in the extension popup and small-window * surfaces. Hidden items collapse the strip naturally; supply the * `iconOutline` variant for the inactive state when an icon needs a * different glyph. */ export function BottomNav({ items, active, onChange, }: BottomNavProps) { const { colorScheme } = useColorScheme(); const isDark = colorScheme === "dark"; const borderColor = isDark ? "rgb(38, 38, 38)" : "rgb(229, 229, 229)"; const backgroundColor = isDark ? "rgb(0, 0, 0)" : "rgb(255, 255, 255)"; return ( {items .filter((t) => t.visible !== false) .map((t) => ( onChange(t.id)} /> ))} ); } interface NavTabProps { label: string; iconName: keyof typeof Ionicons.glyphMap; active: boolean; onPress: () => void; } function NavTab({ label, iconName, active, onPress }: NavTabProps) { const { colorScheme } = useColorScheme(); const isDark = colorScheme === "dark"; const tint = active ? isDark ? "rgb(255, 255, 255)" : "rgb(0, 0, 0)" : isDark ? "rgb(163, 163, 163)" : "rgb(115, 115, 115)"; const pressedBg = isDark ? "rgb(38, 38, 38)" : "rgb(245, 245, 245)"; return ( ({ flex: 1, paddingVertical: 8, alignItems: "center", justifyContent: "center", gap: 2, backgroundColor: pressed ? pressedBg : "transparent", })} > {label} ); }