-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPetCell.js
More file actions
107 lines (102 loc) · 2.44 KB
/
PetCell.js
File metadata and controls
107 lines (102 loc) · 2.44 KB
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
'use strict';
import React, { Component } from 'react';
import {
Image,
Platform,
StyleSheet,
Text,
TouchableHighlight,
TouchableNativeFeedback,
View
} from 'react-native';
import getImage from './getImage';
import getBreeds from './getBreeds';
export default class PetCell extends Component {
render({ pet } = this.props) {
const image = getImage(pet);
let TouchableElement = TouchableHighlight;
if (Platform.OS === 'android') {
TouchableElement = TouchableNativeFeedback;
}
return (
<View>
<TouchableElement
onPress={this.props.onSelect}
onShowUnderlay={this.props.onHighlight}
onHideUnderlay={this.props.onUnhighlight}>
<View style={styles.row}>
<View style={styles.imageContainer}>
{image
? <Image source={image} style={styles.petImage} />
: <View style={styles.noImage}><Text style={styles.noImageText}>No image</Text></View>
}
</View>
<View style={styles.textContainer}>
<Text style={styles.petName} numberOfLines={1}>
{pet.name}
</Text>
<Text style={styles.petBreed} numberOfLines={1}>
{getBreeds(pet)}
</Text>
<Text style={styles.petDescription} numberOfLines={2}>
{pet.description}
</Text>
<Text style={styles.petLocation}>
{pet.contact.city}, {pet.contact.state}, {pet.contact.zip}
</Text>
</View>
</View>
</TouchableElement>
</View>
);
}
}
const styles = StyleSheet.create({
row: {
alignItems: 'center',
backgroundColor: 'white',
flexDirection: 'row',
borderStyle: 'solid',
borderBottomColor: '#dddddd',
borderBottomWidth: StyleSheet.hairlineWidth,
padding: 5,
},
imageContainer: {
backgroundColor: '#dddddd',
width: 90,
height: 90,
marginRight: 10
},
textContainer: {
flex: 1,
},
noImage: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
noImageText: {
color: '#aaaaaa',
},
petImage: {
width: 90,
height: 90,
},
petName: {
flex: 1,
fontSize: 16,
fontWeight: '500',
},
petBreed: {
fontSize: 13,
},
petDescription: {
fontSize: 12,
marginTop: 5,
marginBottom: 5,
},
petLocation: {
fontSize: 12,
color: 'gray',
},
});