-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
57 lines (53 loc) · 1.9 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
import Ionicons from "@expo/vector-icons/Ionicons";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { NavigationContainer } from "@react-navigation/native";
import HabitProvider from "@/providers/HabitProvider";
import UserProvider from "@/providers/UserProvider";
import HabitsScreen from "@/screens/HabitsScreen";
import HistoryScreen from "@/screens/HistoryScreen";
import HomeScreen from "@/screens/HomeScreen";
import ProfileScreen from "@/screens/ProfileScreen";
const getIconName = (
routeName: string,
focused: boolean,
): keyof typeof Ionicons.glyphMap => {
switch (routeName) {
case "Home":
return focused ? "home" : "home-outline";
case "Profile":
return focused ? "person-circle" : "person-circle-outline";
case "Habits":
return focused ? "list" : "list-outline";
case "History":
return focused ? "calendar" : "calendar-outline";
default:
return "caret-up";
}
};
const Tab = createBottomTabNavigator();
export default function App() {
return (
<UserProvider>
<HabitProvider>
<NavigationContainer>
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
const iconName = getIconName(route.name, focused);
return <Ionicons name={iconName} size={size} color={color} />;
},
tabBarActiveTintColor: "#908BE8",
tabBarInactiveTintColor: "gray",
headerShown: false,
})}
>
<Tab.Screen name="Home" component={HomeScreen} />
<Tab.Screen name="Habits" component={HabitsScreen} />
<Tab.Screen name="History" component={HistoryScreen} />
<Tab.Screen name="Profile" component={ProfileScreen} />
</Tab.Navigator>
</NavigationContainer>
</HabitProvider>
</UserProvider>
);
}