-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMImageTitle.js
108 lines (101 loc) · 3.23 KB
/
MImageTitle.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
import React, { PureComponent } from 'react'
import Icon from 'react-native-vector-icons/AntDesign'
import {
Text,
StyleSheet,
View,
Dimensions,
ImageBackground,
TouchableHighlight,
} from 'react-native'
const { width } = Dimensions.get('window')
class MImageTitle extends PureComponent {
render() {
const { item, index, selected, selectImage, selectedItemCount, singleSelect, paddingTop } = this.props
const pad = index < 4 ? paddingTop : 0;
if (!item) return null
return (
<TouchableHighlight
style={{ opacity: selected ? 0.8 : 1, paddingTop: pad, margin: 1, backgroundColor: "#ccc" }}
underlayColor='transparent'
onPress={() => { if (selected && singleSelect) return; selectImage(index) }} >
<View style={{ position: 'relative' }}>
<View style={styles.container}>
<ImageBackground
style={styles.item}
source={{
uri: item.node.image.uri,
cache: 'force-cache'
}} >
{
!singleSelect && <>
<View style={selectedItemCount > 0 ? styles.countBadgeSelected : styles.countBadge}>
<Text style={styles.countBadgeText}>{selectedItemCount > 0 ? selectedItemCount : null}</Text>
</View>
{item.node.image.playableDuration > 0 && <View style={styles.duration}>
<Icon name="play" size={24} color="white" />
</View>}
</>
}
</ImageBackground>
</View>
</View>
</TouchableHighlight>
)
}
}
export default MImageTitle;
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
width: '100%',
},
item: {
width: (width / 4 - 2),
height: (width / 4 - 2),
},
countBadge: {
width: 24,
height: 24,
borderRadius: 12,
position: 'absolute',
left: 3,
top: 3,
justifyContent: 'center',
backgroundColor: 'rgba(255,255,255,0.6)',
borderWidth: 1,
borderColor: 'white',
alignItems: 'center'
},
duration: {
color: 'white',
position: 'absolute',
justifyContent: 'center',
alignItems: 'center',
bottom: 0,
right: 3
},
countBadgeSelected: {
width: 24,
height: 24,
borderRadius: 12,
left: 3,
top: 3,
justifyContent: 'center',
backgroundColor: 'rgba(0,134,4,0.9)',
borderWidth: 1,
borderColor: 'white',
alignItems: 'center'
},
countBadgeText: {
color: 'white',
fontWeight: 'bold',
alignSelf: 'center',
padding: 'auto',
textAlign: 'center',
fontSize: 10,
width: '100%'
}
})