-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
110 lines (89 loc) · 3.68 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
104
105
106
107
108
109
110
import 'react-native-gesture-handler';
import React, { useState } from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'
import { app } from './firebase';
import { Feather } from '@expo/vector-icons';
import { PortalProvider } from '@gorhom/portal';
// screen
import LoginScreen from './screens/LoginScreen';
import ReceipesScreen from './screens/ReceipesScreen';
import MoreScreen from './screens/MoreScreen';
import ToDoListScreen from './screens/ToDoListScreen';
import ReceipeDetailScreen from './screens/ReceipeDetailScreen';
import EditCategories from './screens/more-screens/EditCategories';
// Onboarding
import Onboarding from './components/Onboarding';
// nagivator definitions
const Stack = createNativeStackNavigator();
const Tab = createBottomTabNavigator();
{ /* Might be super dirty, but this calls the firebase.js and initializes the app with it */ }
app
{ /* Defining a tab navigation for the main screen, get's called in the App function */ }
function TabScreenNavigation() {
return(
<Tab.Navigator screenOptions={{
tabBarStyle: { position: 'absolute', backgroundColor: '#eaeaea', borderTopWidth: 0, elevation: 0 },
}}>
<Tab.Screen name="Rezepte" component={ReceipesScreenNavigation} options={{ headerShown: false, tabBarIcon: ({ color }) => (<Feather name="book-open" size={24} color={color} />) }} />
<Tab.Screen name="Einkaufsliste" component={ToDoListNavigation} options={{ headerShown: false, tabBarIcon: ({ color }) => (<Feather name="list" size={24} color={color} />) }} />
<Tab.Screen name="Mehr" component={MoreScreenNavigation} options={{ headerShown: false, tabBarIcon: ({ color }) => (<Feather name="more-horizontal" size={24} color={color} />) }} />
</Tab.Navigator>
)
}
{ /* Nested stack navigators for more, todolist & receipes */ }
function ReceipesScreenNavigation() {
return(
<Stack.Navigator>
<Stack.Screen name="ReceipesScreenNav" component={ReceipesScreen} options={{ headerShown: false }} />
<Stack.Screen name="ReceipeDetailsScreen" component={ReceipeDetailScreen} options={{ headerShown: false }} />
</Stack.Navigator>
)
}
function ToDoListNavigation() {
return(
<Stack.Navigator>
<Stack.Screen name="ToDoListNav" component={ToDoListScreen} options={{ headerShown: false }}/>
</Stack.Navigator>
)
}
function MoreScreenNavigation() {
return (
<Stack.Navigator>
<Stack.Screen name="More" component={MoreScreen} options={{ headerShown: false, title: 'Mehr' }} />
<Stack.Screen name="EditCategoriesScreen" component={EditCategories} options={{ headerShown: false, title: 'Kategorien' }} />
</Stack.Navigator>
)
}
{ /* main navigator stack*/ }
export default function App() {
// setup for the onboarding
const [ showOnboard, setShowOnboard ] = useState(true);
const handleOnboardFinish = () => {
setShowOnboard(false);
}
return (
<>
{ showOnboard && <Onboarding handleDone={handleOnboardFinish} />}
{ !showOnboard &&
<PortalProvider>
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Login" component={LoginScreen} options={{ headerShown: false}} />
<Stack.Screen name="TabScreenNav" component={TabScreenNavigation} options={{ headerShown: false }} />
</Stack.Navigator>
</NavigationContainer>
</PortalProvider>
}
</>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}
});