import React from 'react'; import { ActivityIndicator, View, StyleSheet, Linking } from 'react-native'; import { NavigationContainer, LinkingOptions } from '@react-navigation/native'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; import { Text } from 'react-native'; import { useAuth } from '../contexts/AuthContext'; import { colors, fontSize } from '../constants/theme'; // Deep linking configuration const linking: LinkingOptions = { prefixes: ['michangarrito://', 'https://michangarrito.com'], config: { screens: { Main: { screens: { Dashboard: 'dashboard', POS: 'pos', Reports: 'reports', More: 'more', }, }, Products: 'products', Inventory: 'inventory', Customers: 'customers', Settings: 'settings', BarcodeScanner: 'scan', }, }, async getInitialURL() { // Handle app opened from deep link const url = await Linking.getInitialURL(); if (url != null) { return url; } return null; }, subscribe(listener) { // Listen to incoming links while app is open const subscription = Linking.addEventListener('url', ({ url }) => { listener(url); }); return () => { subscription.remove(); }; }, }; // Screens import LoginScreen from '../screens/LoginScreen'; import DashboardScreen from '../screens/DashboardScreen'; import POSScreen from '../screens/POSScreen'; import MoreScreen from '../screens/MoreScreen'; import ProductsScreen from '../screens/ProductsScreen'; import InventoryScreen from '../screens/InventoryScreen'; import CustomersScreen from '../screens/CustomersScreen'; import ReportsScreen from '../screens/ReportsScreen'; import SettingsScreen from '../screens/SettingsScreen'; import BarcodeScannerScreen from '../screens/BarcodeScannerScreen'; // Type definitions export type RootStackParamList = { Auth: undefined; Main: undefined; Products: undefined; Inventory: undefined; Customers: undefined; Reports: undefined; Settings: undefined; BarcodeScanner: { onScan?: (barcode: string) => void }; }; export type MainTabParamList = { Dashboard: undefined; POS: undefined; Reports: undefined; More: undefined; }; const Stack = createNativeStackNavigator(); const Tab = createBottomTabNavigator(); // Tab Icon Component const TabIcon = ({ name, focused }: { name: string; focused: boolean }) => { const icons: Record = { Dashboard: '🏠', POS: '🛒', Reports: '📊', More: '☰', }; return ( {icons[name] || '•'} ); }; // Main Tab Navigator function MainTabs() { return ( ({ tabBarIcon: ({ focused }) => ( ), tabBarActiveTintColor: colors.primary, tabBarInactiveTintColor: colors.textMuted, tabBarStyle: { backgroundColor: colors.surface, borderTopColor: colors.border, paddingTop: 8, height: 60, }, tabBarLabelStyle: { fontSize: fontSize.xs, fontWeight: '500', }, headerShown: false, })} > ); } // Loading Screen function LoadingScreen() { return ( ); } // Main App Navigator export default function AppNavigator() { const { isAuthenticated, isLoading } = useAuth(); if (isLoading) { return ; } return ( {isAuthenticated ? ( <> ) : ( )} ); } const styles = StyleSheet.create({ loadingContainer: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: colors.background, }, });