forked from Winz18/Online-Learning-Mobile_app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCourseScreen.tsx
71 lines (65 loc) · 1.84 KB
/
CourseScreen.tsx
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
import React from "react";
import { FlatList, StyleSheet, Text, TouchableOpacity, View } from "react-native";
import { NavigationProp } from "@react-navigation/native";
type SectionProps = {
navigation: NavigationProp<any, any>;
route: any;
};
function CourseScreen({ route, navigation }: SectionProps): React.JSX.Element {
const { articles, title } = route.params;
const handlePress = (article: any) => {
navigation.navigate("Module", { article });
};
return (
<View style={styles.container}>
<Text style={styles.title}>{title}</Text>
<FlatList
data={articles}
keyExtractor={(item) => item.id.toString()}
renderItem={({ item }) => (
<View style={styles.articleContainer}>
<TouchableOpacity onPress={() => handlePress(item)}>
<Text style={styles.articleTitle}>{item.name}</Text>
<Text style={{ color: "darkgreen" }}>Author: {item.author}</Text>
<Text style={{ color: "darkgreen" }}>Created at: {item.date.substring(0, 10)}</Text>
<Text style={{ color: "darkgreen" }}>Total views: {item.total_views}</Text>
</TouchableOpacity>
</View>
)}
/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 16,
backgroundColor: "#f5f5f5"
},
title: {
fontSize: 30,
fontWeight: "bold",
marginBottom: 16,
marginTop: 16,
alignSelf: "center",
color: "blue",
fontStyle: "italic"
},
articleContainer: {
marginBottom: 16,
padding: 16,
backgroundColor: "#fff",
borderRadius: 8,
shadowColor: "#000",
shadowOpacity: 0.1,
shadowRadius: 10,
shadowOffset: { width: 0, height: 0 }
},
articleTitle: {
fontSize: 18,
fontWeight: "bold",
marginBottom: 8,
color: "darkblue"
}
});
export default CourseScreen;