This repository has been archived by the owner on May 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
65 lines (55 loc) · 1.73 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
import { StyleSheet, View } from "react-native";
import React, { useState, useEffect} from "react";
import firebase from './src/firebase';
import TreeGrid from "./src/TreeGrid";
import { createStackNavigator } from "@react-navigation/stack";
import { NavigationContainer } from "@react-navigation/native";
import DetailsScreen from "./src/TreeSummary";
import TreeCamera from "./src/TreeCamera";
import MoreGraphsPage from "./src/MoreGraphsPage";
const db = firebase.database().ref();
const App = () => {
const [treeData, setTreeData] = useState({trees:[]});
useEffect(() => {
const handleData = snap => {
if (snap.val())
setTreeData(snap.val());
}
db.on('value', handleData, error => alert(error));
return () => { db.off('value', handleData); };
}, []);
function Dashboard({ navigation }) {
return (
<View style={styles.MainContainer}>
<TreeGrid treesData={treeData} navigation={navigation} />
</View>
);
}
function HomeScreen({ navigation }) {
return (
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
<Dashboard navigation={navigation} />
</View>
);
}
const Stack = createStackNavigator();
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="My Forest" component={HomeScreen} />
<Stack.Screen name="Health Summary" component={DetailsScreen} />
<Stack.Screen name="Camera" component={TreeCamera} />
<Stack.Screen name="More" component={MoreGraphsPage} />
</Stack.Navigator>
</NavigationContainer>
);
};
const styles = StyleSheet.create({
MainContainer: {
flex: 1,
paddingTop: 30,
width: "100%",
height: "100%",
},
});
export default App;