-
Notifications
You must be signed in to change notification settings - Fork 0
/
Related.js
69 lines (66 loc) · 1.68 KB
/
Related.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
import { StyleSheet, Text, View, Image, TouchableOpacity } from "react-native";
import React from "react";
import { useNavigation } from "@react-navigation/native";
export default function Related(props) {
const navigation = useNavigation();
const data = props.data;
let random = Math.floor(Math.random() * data.images.length);
return (
<View style={styles.container}>
<TouchableOpacity
activeOpacity={0.2}
onPress={() =>
navigation.navigate("NewsItem", {
item: data.headlines[random],
image: data.images[random],
id: data.links[random],
index: random,
data: data,
})
}
>
<View style={styles.innerContainer}>
<View style={styles.content}>
<Text style={{ color: "white", fontSize: 20 }}>
{data.headlines[random]}
</Text>
</View>
<View>
<Image
source={{ uri: data.images[random] }}
style={{
width: 65,
height: 65,
borderRadius: 15,
marginLeft: 10,
}}
/>
</View>
</View>
</TouchableOpacity>
</View>
);
}
const styles = StyleSheet.create({
container: {
flexGrow: 1,
paddingVertical: 10,
width: "100%",
},
innerContainer: {
flexDirection: "row",
width: "100%",
justifyContent: "center",
alignItems: "center",
paddingVertical: 10,
paddingHorizontal: 15,
borderWidth: 1,
borderColor: "white",
borderRadius: 15,
},
content: {
flex: 1,
justifyContent: "center",
alignItems: "center",
},
});