-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.jsx
More file actions
109 lines (99 loc) · 3.41 KB
/
App.jsx
File metadata and controls
109 lines (99 loc) · 3.41 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
import * as React from 'react';
import { StyleSheet, View, Text, Settings } from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';
import LoadingIndicator from './components/loadingIndicator';
// Navigation
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
// Screens
import FeedScreen from './screens/feedScreen/feedScreen';
import ProfileScreen from './screens/profileScreen/profileScreen';
import TrackerScreen from './screens/trackerScreen/trackerScreen';
// Context
import GlobalContextProvider, { Context } from './components/globalContextProvider';
import SettingsScreen from './screens/profileScreen/settingsScreen/settingsScreen';
const globalStyles = require('./globalStyles.json');
const Tab = createBottomTabNavigator();
const Stack = createNativeStackNavigator();
const BottomNavBar = ({ user }) => (
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
let iconName;
if (route.name === 'Feed') {
iconName = 'inbox';
} else if (route.name === 'Tracker') {
iconName = 'plus-circle';
} else if (route.name === 'Profile') {
iconName = 'user';
}
return <Icon name={iconName} size={globalStyles.bottomBarIconSize} color={focused ? globalStyles.activePrimaryColor : globalStyles.inactivePrimaryColor} />;
},
tabBarActiveTintColor: globalStyles.activePrimaryColor,
tabBarInactiveTintColor: globalStyles.inactivePrimaryColor,
tabBarStyle: {
backgroundColor: globalStyles.backgroundColor,
position: 'absolute',
bottom: 20,
left: 70,
right: 70,
elevation: 0,
borderRadius: 40,
height: 60,
paddingBottom: 5,
paddingTop: 5,
},
tabBarLabelStyle: {
display: 'none',
},
headerStyle: {
backgroundColor: 'white',
height: 60,
},
headerTitleStyle: {
color: 'white',
fontSize: 26,
},
tabBarAndroidRipple: true,
headerTitle: (props) => <Text {...props} style={styles.header}>{route.name}</Text>,
})}
>
<Tab.Screen name="Feed" component={FeedScreen} />
<Tab.Screen name="Tracker" component={TrackerScreen} />
<Tab.Screen name="Profile" component={ProfileScreen} initialParams={{ passedUser: user }} />
</Tab.Navigator>
);
const App = () => {
const { user, isUserLoading } = React.useContext(Context);
if (isUserLoading) {
return <LoadingIndicator />;
}
return (
<NavigationContainer style={styles.container}>
<Stack.Navigator>
<Stack.Screen name="Home" component={BottomNavBar} initialParams={{ user: user }} options={{ headerShown: false }} />
<Stack.Screen name="ProfileScreen" component={ProfileScreen} />
<Stack.Screen name="Settings" component={SettingsScreen} />
</Stack.Navigator>
</NavigationContainer>
);
};
export default function AppWrapper() {
return (
<GlobalContextProvider>
<App />
</GlobalContextProvider>
);
}
const styles = StyleSheet.create({
container: {
backgroundColor: globalStyles.backgroundColor,
},
header: {
color: globalStyles.headerColor,
fontSize: globalStyles.headerSize,
fontWeight: 'bold',
textAlign: 'right',
},
});