-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPetScreen.js
More file actions
73 lines (68 loc) · 1.69 KB
/
PetScreen.js
File metadata and controls
73 lines (68 loc) · 1.69 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
'use strict';
import React, { Component } from 'react';
import {
Image,
Linking,
ScrollView,
StyleSheet,
Text,
View
} from 'react-native';
import getImage from './getImage';
import getBreeds from './getBreeds';
export default class PetScreen extends Component {
render({ pet } = this.props) {
const image = getImage(pet);
const url = `https://www.petfinder.com/petdetail/${pet.id}`;
return (
<ScrollView contentContainerStyle={styles.contentContainer}>
<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.mainSection}>
<Text style={styles.petDecsription}>{pet.description}</Text>
<Text>{' '}</Text>
<Text>Age: {pet.age}</Text>
<Text>Breeds: {getBreeds(pet)}</Text>
<Text>Location: {pet.contact.city}, {pet.contact.state}, {pet.contact.zip}</Text>
<Text>Email: {pet.contact.email}</Text>
<Text>{' '}</Text>
<Text style={{color: 'blue'}} onPress={() => Linking.openURL(url)}>
{url}
</Text>
</View>
</ScrollView>
);
}
}
const styles = StyleSheet.create({
contentContainer: {
flex: 1,
},
imageContainer: {
backgroundColor: '#dddddd',
flex: 1,
},
petImage: {
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
right: 0,
},
noImage: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
noImageText: {
color: '#aaaaaa',
},
mainSection: {
flex: 1,
padding: 10,
},
});