-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
106 lines (95 loc) · 3.35 KB
/
App.tsx
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
import React, { useContext, useEffect } from "react";
import { NavigationContainer, DefaultTheme } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { House, User, UsersThree } from "phosphor-react-native";
import {
Provider as AuthProvider,
Context as AuthContext,
} from "./src/context/AuthContext";
import { navigationRef } from "./src/RootNavigation";
import Login from "./src/Screens/Login";
import Home from "./src/Screens/Home";
import SignUp from "./src/Screens/SignUp";
import Friends from "./src/Screens/Friends";
import Profile from "./src/Screens/Profile";
import { Loading } from "./src/components/Loading";
import {
useFonts,
Inter_400Regular,
Inter_600SemiBold,
Inter_700Bold,
Inter_900Black
} from "@expo-google-fonts/inter";
import { THEME } from "./src/theme";
const Stack = createNativeStackNavigator();
const Tab = createBottomTabNavigator();
const AppTheme = {
... DefaultTheme,
dark: true,
colors: {
... DefaultTheme.colors,
background: THEME.COLORS.BACKGROUND_900,
},
};
function App() {
const { token, isLoading, tryLocalLogin } = useContext(AuthContext);
const [fontsLoaded] = useFonts({
Inter_400Regular,
Inter_600SemiBold,
Inter_700Bold,
Inter_900Black
});
useEffect(() => {
tryLocalLogin();
}, []);
if (!fontsLoaded || isLoading) {
return <Loading />;
}
return (
<NavigationContainer theme={AppTheme} ref={navigationRef}>
{!token ? (
<Stack.Navigator
screenOptions={{
headerShown: false,
statusBarStyle: "dark",
}}
>
<Stack.Screen name="Login" component={Login} />
<Stack.Screen name="SignUp" component={SignUp} />
</Stack.Navigator>
) : (
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ color, size }) => {
switch (route.name) {
case "Home":
return <House size={size} color={color} />;
case "Friends":
return <UsersThree size={size} color={color} />;
case "Profile":
return <User size={size} color={color} />;
default:
return null;
}
},
tabBarStyle: { backgroundColor: THEME.COLORS.BACKGROUND_800 },
tabBarShowLabel: false,
headerShown: false,
})}
>
<Tab.Screen name="Home" component={Home} />
<Tab.Screen name="Friends" component={Friends} />
<Tab.Screen name="Profile" component={Profile} />
</Tab.Navigator>
)}
</NavigationContainer>
);
}
export default () => {
return (
<AuthProvider>
<App />
</AuthProvider>
);
};