import { Ionicons } from '@expo/vector-icons' import { Block, Text } from '@share/components' import { Tabs } from 'expo-router' import { observer } from 'mobx-react-lite' import React, { useEffect } from 'react' import { useSafeAreaInsets } from 'react-native-safe-area-context' import { Colors } from '@/constants/theme' import { userStore } from '@/stores' import { configureWebBrowser } from '@/utils' interface BottomNavProps { currentRoute: string onRouteChange: (route: string) => void theme?: 'light' | 'dark' } const navItems = [ { id: 'index', label: '探索', iconName: 'compass-outline' }, { id: 'generate', label: '生成', iconName: 'image-outline' }, { id: 'sync', label: '同步', iconName: 'refresh' }, // { id: 'explore', label: '蓝牙调试', iconName: 'person-outline' }, ] function renderNavItem(item: (typeof navItems)[0], isActive: boolean, onRouteChange: (route: string) => void) { const { id, label, iconName } = item return ( onRouteChange(id)} > {isActive && ( )} {isActive && ( {label} )} ) } export const BottomNav = ({ currentRoute, onRouteChange }: BottomNavProps) => { const insets = useSafeAreaInsets() return ( {navItems.map((item) => renderNavItem(item, currentRoute === item.id, onRouteChange))} ) } const CustomTabBar = observer(function CustomTabBar(props: any) { const routes = props.state.routes const activeIndex: number = props.state.index const activeRouteName = routes[activeIndex]?.name || 'index' const isAuthenticated = userStore.isAuthenticated console.log('isAuthenticated==========', isAuthenticated) const handleChange = (route: string) => { if (!isAuthenticated && route !== 'index') { props.navigation.push('auth') return } props.navigation.navigate(route) } return }) export default function Layout() { useEffect(() => { // 配置WebBrowser const setupWebBrowser = async () => { try { await configureWebBrowser() } catch (error) { console.warn('Failed to configure WebBrowser:', error) } } setupWebBrowser() }, []) return }> }