import React from 'react'; import { Text, View, StyleSheet, TouchableOpacity, ActivityIndicator, Image } from 'react-native'; import { NavigationContainer } from '@react-navigation/native'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; import { BottomTabBarProps } from '@react-navigation/bottom-tabs'; import { RootStackParamList, MainTabParamList } from './types'; import { LoginScreen, SignUpScreen, OnboardingScreen, HomeScreen, ProjectsScreen, ProjectDetailScreen, StepEditorScreen, NewsScreen, SettingsScreen, GlazePickerScreen, UserListScreen, } from '../screens'; import { colors, spacing } from '../lib/theme'; import { useAuth } from '../contexts/AuthContext'; const RootStack = createNativeStackNavigator(); const MainTab = createBottomTabNavigator(); const homeIcon = require('../../assets/images/home_icon.png'); const projectIcon = require('../../assets/images/project_icon.png'); const tipsIcon = require('../../assets/images/tips_icon.png'); const settingsIcon = require('../../assets/images/settings_icon.png'); function CustomTabBar({ state, descriptors, navigation }: BottomTabBarProps) { const tabs = [ { name: 'Home', label: 'Home', iconType: 'image' as const, iconSource: homeIcon }, { name: 'Projects', label: 'Projects', iconType: 'image' as const, iconSource: projectIcon }, { name: 'News', label: 'Tips', iconType: 'image' as const, iconSource: tipsIcon }, { name: 'Settings', label: 'Settings', iconType: 'image' as const, iconSource: settingsIcon }, ]; return ( {tabs.map((tab, index) => { const isFocused = state.index === index; const isFirst = index === 0; const isLast = index === tabs.length - 1; const isMiddle = !isFirst && !isLast; const onPress = () => { const event = navigation.emit({ type: 'tabPress', target: state.routes[index].key, canPreventDefault: true, }); if (!isFocused && !event.defaultPrevented) { navigation.navigate(state.routes[index].name); } }; return ( {tab.label} ); })} ); } function MainTabs() { return ( } screenOptions={{ headerShown: false, }} initialRouteName="Home" > ); } const styles = StyleSheet.create({ tabBarContainer: { flexDirection: 'row', backgroundColor: colors.background, height: 65, position: 'absolute', bottom: 20, left: 10, right: 10, borderRadius: 25, shadowColor: colors.text, shadowOffset: { width: 0, height: -2 }, shadowOpacity: 0.1, shadowRadius: 8, elevation: 8, }, tabItem: { flex: 1, alignItems: 'center', justifyContent: 'center', paddingVertical: 8, }, tabItemActive: { backgroundColor: colors.primaryLight, borderWidth: 2, borderColor: colors.primary, }, tabItemActiveFirst: { borderRadius: 25, }, tabItemActiveLast: { borderRadius: 25, }, tabItemActiveMiddle: { borderRadius: 25, }, imageIconContainer: { width: 40, height: 40, borderRadius: 0, overflow: 'hidden', backgroundColor: 'transparent', justifyContent: 'center', alignItems: 'center', marginBottom: 2, }, tabIconImage: { width: 40, height: 40, opacity: 0.8, backgroundColor: 'transparent', }, tabIconImageActive: { opacity: 1, backgroundColor: 'transparent', }, tabLabel: { fontSize: 10, fontWeight: '700', letterSpacing: 0.3, color: colors.textSecondary, }, tabLabelActive: { color: colors.text, }, loadingContainer: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: colors.background, }, }); export function AppNavigator() { const { user, loading, hasCompletedOnboarding } = useAuth(); if (loading) { return ( ); } return ( {!user ? ( // Auth screens - not logged in <> ) : ( // App screens - logged in (initial route determined by hasCompletedOnboarding) <> ({ title: route.params.type === 'shopping' ? 'Shopping List' : 'Wish List', })} /> )} ); }