This repository has been archived by the owner on Jul 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
PokemonCell.js
76 lines (72 loc) · 1.78 KB
/
PokemonCell.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
'use strict';
var React = require('react-native');
var {
Image,
PixelRatio,
StyleSheet,
Text,
TouchableHighlight,
View
} = React;
var getImageSource = require('./getImageSource');
var PokemonType = require('./PokemonType');
var PokemonCell = React.createClass({
render: function() {
return (
<View>
<TouchableHighlight onPress={this.props.onSelect}>
<View style={styles.row}>
<Image
source={getImageSource(this.props.pokemon, true)}
style={styles.cellImage}
/>
<View style={styles.textContainer}>
<Text style={styles.pokemonName} numberOfLines={1}>
#{this.props.pokemon.pkdx_id} - {this.props.pokemon.name}
</Text>
<Text style={styles.pokemonHp} numberOfLines={1}>
{this.props.pokemon.height/10}m / {this.props.pokemon.weight/10}kg - HP: {this.props.pokemon.hp}
</Text>
<PokemonType types={this.props.pokemon.types} />
</View>
</View>
</TouchableHighlight>
<View style={styles.cellBorder} />
</View>
);
}
});
var styles = StyleSheet.create({
textContainer: {
flex: 1,
},
pokemonName: {
flex: 1,
fontSize: 16,
fontWeight: '500',
marginBottom: 2,
},
pokemonHp: {
color: '#999999',
fontSize: 12,
},
row: {
alignItems: 'center',
backgroundColor: 'white',
flexDirection: 'row',
padding: 5,
},
cellImage: {
backgroundColor: 'white',
height: 90,
marginRight: 10,
width: 90,
},
cellBorder: {
backgroundColor: 'rgba(0, 0, 0, 0.1)',
// Trick to get the thinest line the device can display
height: 1 / PixelRatio.get(),
marginLeft: 4,
}
});
module.exports = PokemonCell;