Repository navigation
Expand file tree
/
Copy pathApp.js
More file actions
94 lines (85 loc) · 3.63 KB
/
Copy pathApp.js
File metadata and controls
94 lines (85 loc) · 3.63 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
import React, { useState, useCallback } from 'react'
import { NavigationContainer } from '@react-navigation/native'
import { createNativeStackNavigator } from '@react-navigation/native-stack'
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'
import { Ionicons } from '@expo/vector-icons'
import { useFonts, Sora_700Bold, Sora_600SemiBold } from '@expo-google-fonts/sora'
import { Manrope_400Regular, Manrope_500Medium, Manrope_600SemiBold } from '@expo-google-fonts/manrope'
import * as SplashScreen from 'expo-splash-screen'
import LoginScreen from './src/screens/LoginScreen'
import SignUpScreen from './src/screens/SignUpScreen'
import FeedScreen from './src/screens/FeedScreen'
import ChatsScreen from './src/screens/ChatsScreen'
import ProfileScreen from './src/screens/ProfileScreen'
import ErrorScreen from './src/screens/ErrorScreen'
import LoadingScreen from './src/screens/LoadingScreen'
import NotificationsScreen from './src/screens/NotificationsScreen'
import SettingsScreen from './src/screens/SettingsScreen'
import ChatConversationScreen from './src/screens/ChatConversationScreen'
import EditProfileScreen from './src/screens/EditProfileScreen'
import { colors } from './src/theme/tokens'
SplashScreen.preventAutoHideAsync()
const Stack = createNativeStackNavigator()
const Tab = createBottomTabNavigator()
function MainTabs() {
return (
<Tab.Navigator
screenOptions={({ route }) => ({
headerShown: false,
tabBarStyle: { backgroundColor: colors.surfaceLow, borderTopColor: colors.border, height: 60 },
tabBarActiveTintColor: colors.accent,
tabBarInactiveTintColor: colors.textSecondary,
tabBarIcon: ({ color, size }) => {
const icons = { Feed: 'grid', Chats: 'chatbubble', Profile: 'person' }
return <Ionicons name={icons[route.name]} size={size} color={color} />
},
})}
>
<Tab.Screen name="Feed" component={FeedScreen} />
<Tab.Screen name="Chats" component={ChatsScreen} />
<Tab.Screen name="Profile" component={ProfileScreen} />
</Tab.Navigator>
)
}
export default function App() {
const [isLoggedIn, setIsLoggedIn] = useState(false)
const [fontsLoaded] = useFonts({
Sora_700Bold,
Sora_600SemiBold,
Manrope_400Regular,
Manrope_500Medium,
Manrope_600SemiBold,
})
const onLayoutRootView = useCallback(async () => {
if (fontsLoaded) await SplashScreen.hideAsync()
}, [fontsLoaded])
if (!fontsLoaded) return null
return (
<NavigationContainer onReady={onLayoutRootView}>
<Stack.Navigator screenOptions={{ headerShown: false }}>
{!isLoggedIn ? (
<>
<Stack.Screen name="Login">
{(props) => <LoginScreen {...props} onLogin={() => setIsLoggedIn(true)} />}
</Stack.Screen>
<Stack.Screen name="SignUp">
{(props) => <SignUpScreen {...props} onSignUp={() => setIsLoggedIn(true)} />}
</Stack.Screen>
</>
) : (
<>
<Stack.Screen name="Main" component={MainTabs} />
<Stack.Screen name="Notifications" component={NotificationsScreen} />
<Stack.Screen name="Settings">
{(props) => <SettingsScreen {...props} onLogout={() => setIsLoggedIn(false)} />}
</Stack.Screen>
<Stack.Screen name="ChatConversation" component={ChatConversationScreen} />
<Stack.Screen name="EditProfile" component={EditProfileScreen} />
</>
)}
<Stack.Screen name="Error" component={ErrorScreen} />
<Stack.Screen name="Loading" component={LoadingScreen} />
</Stack.Navigator>
</NavigationContainer>
)
}