-
Notifications
You must be signed in to change notification settings - Fork 3
/
App.js
103 lines (93 loc) · 2.54 KB
/
App.js
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
import { StyleSheet, TouchableOpacity } from 'react-native'
import { NavigationContainer } from '@react-navigation/native'
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'
import { createNativeStackNavigator } from '@react-navigation/native-stack'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import Icon from 'react-native-vector-icons/Ionicons'
import Favorites from './screens/Favorites'
import Discover from './screens/Discover'
import Settings from './screens/Settings'
import { colors, sizes } from './lib/styles'
const Tab = createBottomTabNavigator()
const Stack = createNativeStackNavigator()
const tabOptions = ({ route }) => ({
tabBarActiveTintColor: colors.primary,
tabBarInactiveTintColor: colors.neutral,
tabBarIcon: ({ focused, color }) => {
let iconName
if (route.name === 'Home') {
if (focused) {
iconName = 'home'
} else {
iconName = 'home-outline'
}
}
if (route.name === 'Discover') {
if (focused) {
iconName = 'compass'
} else {
iconName = 'compass-outline'
}
}
if (route.name === 'Favorites') {
if (focused) {
iconName = 'heart'
} else {
iconName = 'heart-outline'
}
}
return <Icon name={iconName} size={20} color={color} />
}
})
const stackOptions = ({ route, navigation }) => ({
title: route.params?.name,
headerBackVisible: false,
headerLeft: ({ canGoBack }) => {
if (!canGoBack) {
return null
}
return (
<TouchableOpacity
style={styles.button}
onPress={() => navigation.goBack()}
>
<Icon name="chevron-back" size={sizes.xxl} color={colors.black} />
</TouchableOpacity>
)
}
})
function Main() {
return (
<Tab.Navigator screenOptions={tabOptions}>
<Tab.Screen
name="Discover"
component={Discover}
options={{ headerTitle: 'Discover' }}
/>
<Tab.Screen name="Favorites" component={Favorites} />
</Tab.Navigator>
)
}
function App() {
return (
<SafeAreaProvider>
<NavigationContainer>
<Stack.Navigator screenOptions={stackOptions}>
<Stack.Screen
name="Main"
component={Main}
options={{ headerShown: false }}
/>
<Stack.Screen name="Settings" component={Settings} />
</Stack.Navigator>
</NavigationContainer>
</SafeAreaProvider>
)
}
const styles = StyleSheet.create({
button: {
paddingHorizontal: 12,
paddingVertical: 5
}
})
export default App