-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHomepage.js
58 lines (46 loc) · 1.16 KB
/
Homepage.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
import { Text, StyleSheet, SafeAreaView } from "react-native";
import { useNavigation } from "@react-navigation/native";
import userContext from "./userContext";
import { useContext } from "react";
import Button from "./Button";
/** Homepage to render after successful login.
*
* State:
* none
*
* Props:
* user:string
*/
function Homepage() {
const { user } = useContext(userContext);
const navigation = useNavigation();
//Navigates to the lecture view upon press
function lecturePress() {
navigation.navigate('LectureView');
}
//Navigates to the exercise view upon press
function exercisePress() {
navigation.navigate('ExerciseView');
}
return (
<SafeAreaView style={styles.container}>
<Text style={styles.text}>Welcome {user}!</Text>
<Button onPress={lecturePress} text="Lectures"/>
<Button onPress={exercisePress} text="Exercises"/>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
maxWidth: '70%',
minWidth: '70%',
alignSelf: 'center',
justifyContent: 'center',
},
text: {
fontSize: 20,
alignSelf: 'center'
},
});
export default Homepage;