NumberButton.js
1.28 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
'use strict';
import React from 'react';
import ReactNative from 'react-native';
const {
View,
Text,
Image,
TouchableOpacity,
StyleSheet,
Dimensions,
} = ReactNative;
export default class NumberButton extends React.Component {
static propTypes = {
source: Image.propTypes.source.isRequired,
number: React.PropTypes.number.isRequired,
onPressButton: React.PropTypes.func,
};
constructor(props) {
super (props);
}
render() {
return (
<TouchableOpacity style={[styles.container, this.props.style]} onPress={() => {
this.props.onPressButton && this.props.onPressButton();
}}>
<Image style={styles.image} source={this.props.source} resizeMode={'contain'}/>
<Text style={styles.number}>{this.props.number}</Text>
</TouchableOpacity>
);
}
}
let styles = StyleSheet.create({
container: {
flexDirection: 'row',
alignItems: 'center',
// alignSelf: 'center',
justifyContent: 'center',
// backgroundColor: '#f2f2f2',
// paddingHorizontal: 10,
},
image: {
width: 18,
height: 18,
},
number: {
fontSize: 14,
marginLeft: 5,
},
});