forked from Darren80/fog-o-war
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisplayImages.js
110 lines (102 loc) · 2.86 KB
/
DisplayImages.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
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
import { useState } from "react";
import { Image, StyleSheet, View, Pressable, Text, ScrollView, ActivityIndicator } from "react-native";
export default function DisplayImages({ markers, setViewImage }) {
const [loading, setLoading] = useState(false);
const [enlargeImage, setEnlargeImage] = useState(false);
const [imageSelected, setImageSelected] = useState(null);
return (
<View style={styles.container}>
<ScrollView
style={styles.ImageContainer}
contentContainerStyle={{
flexDirection: "row",
flexWrap: "wrap",
justifyContent: "center",
}}
horizontal={false}
>
{
markers.map((marker, i) => {
const source = { uri: marker.image };
return (
<View
style={{
padding: 5,
}}
key={i}
>
<Pressable onPress={() => {
setEnlargeImage(true)
setImageSelected(source)
}}>
<Image source={source}
// style={{ height: 500, width: 500, resizeMode: 'center' }}
style={[
styles.Image,
{
width: i % 2 === 1 ? 150 : 95,
height: i % 2 === 1 ? 150 : 95,
},
]}
resizeMode="center"
onLoadStart={() => setLoading(true)}
onLoadEnd={() => setLoading(false)}
/>
</Pressable>
{loading && <ActivityIndicator color="green" size="large" />}
{
enlargeImage ?
<Image source={imageSelected} style={{ height: 500, width: 500, resizeMode: 'contain' }}>
</Image> : null
}
</View>
)
})
}
</ScrollView>
<Pressable style={styles.button} onPress={() => setViewImage(false)}>
<Text style={styles.text}>Back</Text>
</Pressable>
</View>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
button: {
alignItems: 'center',
justifyContent: 'center',
// paddingVertical: 10,
// paddingHorizontal: 32,
borderRadius: 30,
backgroundColor: 'black',
},
text: {
fontSize: 16,
// lineHeight: 21,
// fontWeight: 'bold',
// letterSpacing: 0.25,
color: 'white',
width: "60%",
padding: "3%"
},
ImageContainer: {
marginHorizontal: 16,
marginTop: 30,
width: "100%",
},
Image: {
shadowColor: "black",
shadowOffset: {
width: -10,
height: 9,
},
shadowOpacity: 0.5,
shadowRadius: 2,
elevation: 5
},
});