-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
93 lines (84 loc) · 3.05 KB
/
Copy pathApp.js
File metadata and controls
93 lines (84 loc) · 3.05 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
import React, { useEffect, useCallback } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { StatusBar } from 'expo-status-bar';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import * as SplashScreen from 'expo-splash-screen';
import { ThemeProvider } from './src/context/ThemeContext';
import HomeScreen from './src/screens/HomeScreen';
import CameraScreen from './src/screens/CameraScreen';
import ResultsScreen from './src/screens/ResultsScreen';
import HistoryScreen from './src/screens/HistoryScreen';
import InsightsScreen from './src/screens/InsightsScreen';
import ProfileScreen from './src/screens/ProfileScreen';
import NotificationsScreen from './src/screens/NotificationsScreen';
import CustomTabBar from './src/components/CustomTabBar';
const Stack = createStackNavigator();
const Tab = createBottomTabNavigator();
// Keep the splash screen visible while we prepare the app
SplashScreen.preventAutoHideAsync();
// Bottom Tab Navigator for main screens
function MainTabs() {
return (
<Tab.Navigator
tabBar={(props) => <CustomTabBar {...props} />}
screenOptions={{
headerShown: false,
}}
>
<Tab.Screen name="Home" component={HomeScreen} />
<Tab.Screen name="History" component={HistoryScreen} />
<Tab.Screen name="Insights" component={InsightsScreen} />
<Tab.Screen name="Profile" component={ProfileScreen} />
</Tab.Navigator>
);
}
export default function App() {
const [appIsReady, setAppIsReady] = React.useState(false);
useEffect(() => {
async function prepare() {
try {
// Pre-load any resources or data here
await new Promise(resolve => setTimeout(resolve, 100));
} catch (e) {
console.warn(e);
} finally {
setAppIsReady(true);
}
}
prepare();
}, []);
const onLayoutRootView = useCallback(async () => {
if (appIsReady) {
await SplashScreen.hideAsync();
}
}, [appIsReady]);
if (!appIsReady) {
return null;
}
return (
<GestureHandlerRootView style={{ flex: 1 }}>
<ThemeProvider>
<SafeAreaProvider onLayout={onLayoutRootView}>
<NavigationContainer>
<StatusBar style="auto" />
<Stack.Navigator
initialRouteName="MainTabs"
screenOptions={{
headerShown: false,
presentation: 'card',
}}
>
<Stack.Screen name="MainTabs" component={MainTabs} />
<Stack.Screen name="Camera" component={CameraScreen} />
<Stack.Screen name="Results" component={ResultsScreen} />
<Stack.Screen name="Notifications" component={NotificationsScreen} />
</Stack.Navigator>
</NavigationContainer>
</SafeAreaProvider>
</ThemeProvider>
</GestureHandlerRootView>
);
}