-
Notifications
You must be signed in to change notification settings - Fork 11
/
ActivityItemStateless.js
99 lines (91 loc) · 2.49 KB
/
ActivityItemStateless.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
import React from 'react'
import {
Icon,
Image,
PropTypes,
StyleSheet,
Text,
TouchableWithoutFeedback,
View
} from 'react-native-mdcore'
import { Activity } from '@models'
const onPress = (props) => () => {
props.onPress(props)
}
const ActivityItem = (props, { theme }) => {
if (props.width === 0 || !props.data) {
return null
}
const styles = Styles.get(theme, props)
return (
<TouchableWithoutFeedback onPress={onPress(props)}>
<View style={[styles.container, props.style]}>
<Image style={{ backgroundColor: theme.palette.backgroundDark }}
height={props.width / props.ratio}
source={props.data.image}
width={props.width} />
<View style={styles.header}>
<Text numberOfLines={2} type="subhead1">
{props.data.highlightTitle && <Text style={styles.headerHighLightTitle} type="subhead1">{props.data.highlightTitle}</Text>}
{props.data.highlightTitle && <Text type="subhead1" value=" - " />}
{props.data.title && <Text type="subhead1">{props.data.title}</Text>}
</Text>
</View>
<View style={styles.footer}>
<Icon
name="star"
size={theme.icon.sizeSm} />
<Icon
name="star"
size={theme.icon.sizeSm} />
<Icon
name="star"
size={theme.icon.sizeSm} />
<Icon
name="star"
size={theme.icon.sizeSm} />
<Icon
name="star"
size={theme.icon.sizeSm} />
<Text style={{ flex: 1, marginLeft: theme.layout.spacingXs }}
type="caption"
value="99 Reviews" />
</View>
</View>
</TouchableWithoutFeedback>
)
}
ActivityItem.contextTypes = {
theme: PropTypes.any
}
ActivityItem.propTypes = {
data: PropTypes.instanceOf(Activity),
ratio: PropTypes.number,
width: PropTypes.number,
onPress: PropTypes.func
}
ActivityItem.defaultProps = {
ratio: 1,
onPress: () => { }
}
export default ActivityItem
const Styles = StyleSheet.create((theme, { width }) => {
const container = {
width,
paddingBottom: theme.layout.spacing
}
const footer = {
flexDirection: 'row',
alignItems: 'center'
}
const header = {
flexDirection: 'row',
alignItems: 'center',
paddingTop: theme.layout.spacingSm,
paddingBottom: theme.layout.spacingSm
}
const headerHighLightTitle = {
fontWeight: 'bold'
}
return { container, footer, header, headerHighLightTitle }
})