-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathApp.tsx
More file actions
218 lines (190 loc) · 6.01 KB
/
App.tsx
File metadata and controls
218 lines (190 loc) · 6.01 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
import { createDrawerNavigator } from '@react-navigation/drawer';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { StatusBar } from 'expo-status-bar';
import React, { Component, useEffect, useState } from 'react';
import { StyleSheet, Text, View, Image, Button, FlatList } from 'react-native';
import NewsPage from './src/tutorials/HttpClientComponent';
import ListViewPage from './src/tutorials/ListComponent';
import { Ionicons } from '@expo/vector-icons';
import SignInScreen from './src/screens/SignInScreen';
import RegisterScreen from './src/screens/RegisterScreen';
import { initializeApp } from 'firebase/app';
import { firebaseCofig } from './src/helper/Constants';
import DishesScreen from './src/screens/DishesScreen';
import AppHomeScreen from './src/screens/HomeScreen';
import { getAuth } from '@firebase/auth';
import CounterComponent from './src/tutorials/CounterComponent';
import { Appbar } from 'react-native-paper';
import CartScreen from './src/screens/CartScreen';
import LocationScreen from './src/screens/LocationScreen';
import MapViewScreen from './src/screens/MapViewScreen';
function HomeScreen({navigation}){
return(
<View style={styles.container}>
<StatusBar style="auto"/>
<Text style={styles.textStyle}>This is a Home Screen</Text>
<Button title="Profile Page"
onPress = {
// ()=> navigation.navigate("Profile")
()=> navigation.push("Profile")
}
>
</Button>
<Text style={styles.textStyle}>List Demo</Text>
{/* <Button title="ListView Page" */}
<Button title="News Page"
onPress = {
()=> navigation.push("List")
}
>
</Button>
</View>
);
}
function ProfileScreen(){
return(
<View style={styles.container}>
<Text style={styles.textStyle}>This is a Profile Screen</Text>
</View>
);
}
const Stack = createNativeStackNavigator();
const Drawer = createDrawerNavigator();
// export default function App(){
// return(
// <NavigationContainer>
// <Stack.Navigator>
// <Stack.Screen name="Home" component={HomeScreen} options={{title:"Home Screen"}}/>
// <Stack.Screen name="Profile" component={ProfileScreen}/>
// {/* <Stack.Screen name="List" component={ListViewPage}/> */}
// <Stack.Screen name="List" component={NewsPage}/>
// </Stack.Navigator>
// </NavigationContainer>
// )
// }
// For Navigation inside the App
// https://reactnavigation.org/docs
function OldApp(){
return(
<NavigationContainer>
<Drawer.Navigator initialRouteName="Home">
<Drawer.Screen name="Home" component={HomeScreen} options={{title:"Home Screen"}}/>
<Drawer.Screen name="Profile" component={ProfileScreen}/>
{/* <Stack.Screen name="List" component={ListViewPage}/> */}
<Drawer.Screen name="List" component={NewsPage}/>
</Drawer.Navigator>
</NavigationContainer>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
splash: {
flex: 1,
// Make the backgroud as a gradient color
backgroundColor: '#aed',
alignItems: 'center',
justifyContent: 'center',
},
textStyle:{
fontSize: 24,
color: "#f00",
marginBottom: 12
},
myBackground:{
backgroundColor: '#fae',
fontSize: 24,
marginBottom: 20
},
image: {
width: 300,
height: 200,
marginBottom: 20
},
item:{
backgroundColor: "#fff",
padding: 16,
margin: 12
},
title:{
fontSize: 16,
color: "#f00"
},
subTitle:{
fontSize: 12,
}
});
const MyAppBar = ({navigation}) => (
<Appbar>
<Appbar.Action
icon="bell"
onPress={() => console.log('Pressed archive')}
/>
<Appbar.Action icon="mail" onPress={() => console.log('Pressed mail')} />
<Appbar.Action icon="label" onPress={() => console.log('Pressed label')} />
<Appbar.Action
icon="cart"
onPress={() => navigation.navigate("Home")}
/>
</Appbar>
);
export default function App({navigation}){
const [showSplash, setShowSplash] = useState(true);
useEffect( ()=>{
// local function
async function showSplashScreen(){
try{
initializeApp(firebaseCofig);
// Check if the user is logged in or not
const auth = getAuth();
if(auth.currentUser != null){
console.log("user is logged in already");
}
await new Promise(resolve => setTimeout(resolve, 2000));
}catch(error){
console.log("Something Went Wrong: "+error);
}finally{
setShowSplash(false);
}
}
showSplashScreen();
}, [] );
if(showSplash){
return (
<View style={styles.splash}>
<Ionicons name="md-heart-circle-sharp" size={32} color="green"/>
<Text>Health Logger</Text>
</View>
);
}
return(
<NavigationContainer>
{/* <Stack.Navigator initialRouteName="Signin" screenOptions={{headerShown: false}}> */}
<Stack.Navigator initialRouteName="Maps" >
<Stack.Screen name="AppBar" component={MyAppBar}/>
<Stack.Screen name="Maps" component={MapViewScreen}/>
<Stack.Screen name="Location" component={LocationScreen}/>
<Stack.Screen name="Signin" component={SignInScreen} options={{title:"Sign In"}}/>
<Stack.Screen name="Register" component={RegisterScreen} options={{title:"Register"}}/>
<Stack.Screen name="Home" component={AppHomeScreen} options={{
title:"Home",
headerRight: ()=>(
// <Text>Cart</Text>
<Appbar.Action
icon="cart"
onPress={() => navigation.navigate("Home")}
/>
)
}}/>
<Stack.Screen name="Dishes" component={DishesScreen}/>
<Stack.Screen name="Cart" component={CartScreen}/>
<Stack.Screen name="Counter" component={CounterComponent}/>
</Stack.Navigator>
</NavigationContainer>
);
}