-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
103 lines (94 loc) · 3.46 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 { useNavigation } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { NavigationContainer } from '@react-navigation/native';
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { MaterialCommunityIcons } from '@expo/vector-icons';
import { HomeScreen } from './screens/HomeScreen.js';
import FeaturedMealsOverviewScreen from './screens/FeaturedMealsOverviewScreen.js';
import PancakesDetailScreen from './screens/FeaturedMealScreens/PancakesDetails.js';
import CreamyIndianDetailScreen from './screens/FeaturedMealScreens/CreamyIndian.js';
import RecipeDetailsScreen from './screens/FeaturedMealScreens/RecipeDetailsScreen.js';
import AsparagusDetailScreen from './screens/FeaturedMealScreens/AsparagusDetails.js';
import SaladDetailScreen from './screens/FeaturedMealScreens/SaladDetails.js';
import LoginScreen from './screens/LoginScreen.js';
import SignUpScreen from './screens/SignUpScreen.js';
import IngredientList from './screens/IngredientList.js';
import { View, Text, Button, StyleSheet, TouchableOpacity } from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';
import Hamburger from './components/Hamburger.js';
const Stack = createNativeStackNavigator();
const CustomHeader = () => {
const navigation = useNavigation();
const handleLogout = async () => {
// handle logout logic here
// navigate back to Login screen
await AsyncStorage.setItem('isLoggedIn', 'false');
await AsyncStorage.setItem('id', '');
navigation.navigate('Login');
};
return (
<View style={styles.container}>
<TouchableOpacity onPress={handleLogout} style={styles.button}>
<MaterialCommunityIcons name="logout" size={24} color="black" />
</TouchableOpacity>
</View>
);
};
const App = () => {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen options={{ headerShown: false, animation: 'fade' }} name="Login" component={LoginScreen}/>
<Stack.Screen options={{ headerShown: false, animation: 'fade' }} name="SignUp" component={SignUpScreen}/>
<Stack.Screen options={{ header: () => <CustomHeader />, animation: 'fade' }} name="Home" component={HomeScreen} />
<Stack.Screen options={{ header: () => <CustomHeader />, animation: 'fade' }} name="Pantry" component={IngredientList} />
<Stack.Screen options={{ headerShown: false, animation: 'fade' }} name="Recipe Details" component={RecipeDetailsScreen} />
</Stack.Navigator>
<StatusBar style="auto" />
</NavigationContainer>
);
}
const styles = StyleSheet.create({
container: {
flexDirection: 'row',
justifyContent: 'flex-end',
alignItems: 'center',
paddingHorizontal: 16,
paddingVertical: 8,
backgroundColor: '#fff',
top: '10%'
},
title: {
fontSize: 20,
fontWeight: 'bold',
},
button: {
backgroundColor: '#32CD32',
borderColor: '#32CD32',
borderRadius: 8,
borderWidth: 2,
paddingHorizontal: 12,
paddingVertical: 8,
width: 50, // increase width
height: 40, // increase height
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.23,
shadowRadius: 2.62,
elevation: 4,
justifyContent: 'center',
alignItems: 'center',
},
buttonText: {
color: '#fff',
fontWeight: 'bold',
textTransform: 'uppercase',
fontSize: 16,
letterSpacing: 1,
}
});
export default App;