-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
174 lines (163 loc) · 6.94 KB
/
Copy pathApp.tsx
File metadata and controls
174 lines (163 loc) · 6.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import React, { useEffect, useState } from 'react';
import { NavigationContainer, DefaultTheme } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { StatusBar } from 'expo-status-bar';
import { View, Platform } from 'react-native';
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context';
import { Home, ScanBarcode, Package, User, Clock } from 'lucide-react-native';
import HomeScanScreen from './src/screens/HomeScanScreen';
import ScanScreen from './src/screens/ScanScreen';
import ResultScreen from './src/screens/ResultScreen';
import CompareScreen from './src/screens/CompareScreen';
import HistoryScreen from './src/screens/HistoryScreen';
import SettingsScreen from './src/screens/SettingsScreen';
import IngredientsSnap from './src/screens/IngredientsSnap';
import OnboardingScreen from './src/screens/OnboardingScreen';
import PantryScreen from './src/screens/PantryScreen';
import ProfileScreen from './src/screens/ProfileScreen';
import { RootStackParamList } from './src/types';
import { Colors, Shadow } from './src/theme';
import { isOnboardingDone } from './src/services/userProfileService';
const Stack = createNativeStackNavigator<RootStackParamList>();
const Tab = createBottomTabNavigator<RootStackParamList>();
const NavTheme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
background: Colors.background,
card: Colors.card,
border: Colors.border,
primary: Colors.primary,
text: Colors.textPrimary,
},
};
// ─── Bottom Tab Navigator ──────────────────────────────────────────────────
function MainTabs() {
const insets = useSafeAreaInsets();
const bottomPad = Math.max(insets.bottom, Platform.OS === 'android' ? 8 : 6);
return (
<Tab.Navigator
screenOptions={{
headerShown: false,
tabBarActiveTintColor: Colors.primary,
tabBarInactiveTintColor: Colors.textMuted,
tabBarStyle: {
backgroundColor: Colors.card,
borderTopWidth: 1,
borderTopColor: Colors.border,
paddingBottom: bottomPad,
paddingTop: 6,
height: 58 + bottomPad,
},
tabBarLabelStyle: { fontSize: 10, fontWeight: '700', marginTop: 2 },
}}
>
<Tab.Screen
name="Home"
component={HomeScanScreen}
options={{
tabBarLabel: 'Home',
tabBarIcon: ({ color }) => <Home color={color} size={22} />,
}}
/>
<Tab.Screen
name="History"
component={HistoryScreen}
options={{
tabBarLabel: 'History',
tabBarIcon: ({ color }) => <Clock color={color} size={22} />,
}}
/>
<Tab.Screen
name="Scan"
component={ScanScreen}
options={{
tabBarLabel: () => null,
tabBarIcon: () => (
<View
style={{
backgroundColor: Colors.primary,
width: 54,
height: 54,
borderRadius: 27,
alignItems: 'center',
justifyContent: 'center',
marginTop: -18,
borderWidth: 4,
borderColor: Colors.card,
...Shadow.md,
}}
>
<ScanBarcode color="#fff" size={26} />
</View>
),
}}
/>
<Tab.Screen
name="Pantry"
component={PantryScreen}
options={{
tabBarLabel: 'Pantry',
tabBarIcon: ({ color }) => <Package color={color} size={22} />,
}}
/>
<Tab.Screen
name="Profile"
component={ProfileScreen}
options={{
tabBarLabel: 'Profile',
tabBarIcon: ({ color }) => <User color={color} size={22} />,
}}
/>
</Tab.Navigator>
);
}
// ─── Root Stack ──────────────────────────────────────────────────────────────
export default function App() {
const [ready, setReady] = useState(false);
const [showOnboarding, setShowOnboarding] = useState(false);
useEffect(() => {
isOnboardingDone().then(done => {
setShowOnboarding(!done);
setReady(true);
});
}, []);
// Hold first render until we know whether onboarding is needed (avoids a flash).
if (!ready) return null;
return (
<SafeAreaProvider>
<NavigationContainer theme={NavTheme}>
{/* Dark text/icons by default — most screens are light. The scan
screens (black camera background) override this locally. */}
<StatusBar style="dark" />
<Stack.Navigator
initialRouteName={showOnboarding ? 'Onboarding' : 'MainTabs'}
screenOptions={{ headerShown: false }}
>
<Stack.Screen name="Onboarding" component={OnboardingScreen} />
<Stack.Screen name="MainTabs" component={MainTabs} />
{/* Detail / modal screens */}
<Stack.Screen name="Result" component={ResultScreen} />
<Stack.Screen name="Compare" component={CompareScreen} />
<Stack.Screen
name="IngredientsSnap"
component={IngredientsSnap}
options={{ animation: 'slide_from_bottom' }}
/>
<Stack.Screen
name="Settings"
component={SettingsScreen}
options={{
headerShown: true,
title: 'Settings',
headerStyle: { backgroundColor: Colors.card },
headerTintColor: Colors.textPrimary,
headerShadowVisible: false,
}}
/>
</Stack.Navigator>
</NavigationContainer>
</SafeAreaProvider>
);
}