-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
59 lines (46 loc) · 2.05 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
import { Provider } from "react-native-paper";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import Auth from "./Screens/Auth";
import { DiaryContext } from "./Contexts/DiaryContext";
import { useState } from "react";
import Login from "./Screens/Login";
import Signup from "./Screens/Signup";
import HomeTabScreen from "./components/HomeStackScreen";
import Loading from "./Screens/Loading";
import Overview from './Screens/MacroNutrients'
import RecoverPassword from "./Screens/RecoverPassword";
//fix for "can't find variable: atob"
import {decode, encode} from 'base-64'
if (!global.btoa) { global.btoa = encode }
if (!global.atob) { global.atob = decode }
const Stack = createNativeStackNavigator();
const options = { headerShown: false };
export default function App() {
const [diary, setDiary] = useState([])
return (
<Provider>
<DiaryContext.Provider value={{diary, setDiary}}>
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name = "Loading" component = {Loading} options = {options} />
<Stack.Screen name = "Login" component = {Login} options = {options} />
<Stack.Screen name = "Signup" component = {Signup} options = {options} />
<Stack.Screen name = "Auth" component = {Auth} options = {options} />
<Stack.Screen name = "Home" component = {HomeTabScreen} options = {options} />
<Stack.Screen name="NutritionalOverview" component={Overview} options={{ title: "" }}/>
<Stack.Screen name="RecoverPassword" component={RecoverPassword} options={{ title: "Recover Password" }}/>
</Stack.Navigator>
</NavigationContainer>
</DiaryContext.Provider>
</Provider>
);
}
export function getNutrientValue(foods , nutrientName) {
let nutrientValue = 0
let nutrient = foods.foodNutrients.find(item => item.nutrientName == nutrientName)
if(nutrient !== undefined){
nutrientValue = nutrient.value
}
return nutrientValue
}