import { Ionicons } from "@expo/vector-icons"; import { router } from "expo-router"; import { Pressable, View } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { Avatar } from "@/components/ui/Avatar"; import { Text } from "@/components/ui/Text"; import { routes } from "@/lib/routes"; import { useAuthStore } from "@/lib/stores/authStore"; import { useNotificationStore } from "@/lib/stores/notificationStore"; import { colors, gutter } from "@/lib/theme"; function greetingForNow() { const hour = new Date().getHours(); if (hour < 12) return "Good morning"; if (hour < 17) return "Good afternoon"; return "Good evening"; } /** Shared top bar for all bottom-tab screens (avatar → profile, bell → notifications). */ export function TabTopBar({ subtitle, }: { /** Optional line under the user name, e.g. the current tab context */ subtitle?: string; }) { const insets = useSafeAreaInsets(); const user = useAuthStore((s) => s.user); const unread = useNotificationStore((s) => s.unreadCount()); return ( router.push(routes.profile)} style={{ flexDirection: "row", alignItems: "center", gap: 12, flex: 1 }} accessibilityRole="button" accessibilityLabel="Open profile" > {subtitle || greetingForNow()} {user?.name?.split(" ")[0] || "Guest"} router.push(routes.notifications)} accessibilityRole="button" accessibilityLabel="Notifications" style={{ width: 44, height: 44, borderRadius: 22, backgroundColor: colors.surface, borderWidth: 1, borderColor: colors.line, alignItems: "center", justifyContent: "center", }} > {unread > 0 ? ( {unread > 9 ? "9+" : unread} ) : null} ); }