1 | import React, {
|
2 | PropTypes,
|
3 | ViewPropTypes,
|
4 | Component,
|
5 | } from 'react';
|
6 | import {
|
7 | View,
|
8 | Text,
|
9 | TouchableOpacity,
|
10 | StyleSheet,
|
11 | } from 'react-native';
|
12 |
|
13 | const styles = StyleSheet.create({
|
14 | rectangularWrap: {
|
15 | flex: 1,
|
16 | },
|
17 | rectangular: {
|
18 | width: 10,
|
19 | backgroundColor: '#82A0FA',
|
20 | borderTopLeftRadius: 5,
|
21 | borderTopRightRadius: 5,
|
22 | borderBottomLeftRadius: 5,
|
23 | borderBottomRightRadius: 5,
|
24 | },
|
25 | });
|
26 |
|
27 | class Rectangular extends Component {
|
28 | static propTypes = {
|
29 | customStyle: PropTypes.object,
|
30 | valueHeight: PropTypes.number,
|
31 | onClick: PropTypes.func,
|
32 | item: PropTypes.object,
|
33 | }
|
34 | static defaultProps = {
|
35 | customStyle: {},
|
36 | valueHeight: 0,
|
37 | onClick: () => {},
|
38 | item: {},
|
39 | }
|
40 | onPress = () => {
|
41 | const item = this.props.item;
|
42 | this.props.onClick(item);
|
43 | }
|
44 | get rectangularWarp() {
|
45 | const customStyle = this.props.customStyle;
|
46 | const raduis = customStyle.raduis;
|
47 | const rectangularWarp = {
|
48 | justifyContent: 'flex-end',
|
49 | height: customStyle.height,
|
50 | width: customStyle.width,
|
51 | backgroundColor: customStyle.backgroundColor,
|
52 | borderTopLeftRadius: raduis,
|
53 | borderTopRightRadius: raduis,
|
54 | borderBottomLeftRadius: raduis,
|
55 | borderBottomRightRadius: raduis,
|
56 | };
|
57 | return rectangularWarp;
|
58 | }
|
59 | get rectangular() {
|
60 | const customStyle = this.props.customStyle;
|
61 | const raduis = customStyle.raduis;
|
62 | return {
|
63 | height: this.props.valueHeight,
|
64 | width: customStyle.width,
|
65 | backgroundColor: customStyle.fillColor,
|
66 | borderTopLeftRadius: raduis,
|
67 | borderTopRightRadius: raduis,
|
68 | borderBottomLeftRadius: raduis,
|
69 | borderBottomRightRadius: raduis,
|
70 | };
|
71 | }
|
72 | render() {
|
73 | return (
|
74 | <TouchableOpacity onPress={this.onPress}>
|
75 | <View style={this.rectangularWarp}>
|
76 | <View style={[styles.rectangular, this.rectangular]} />
|
77 | </View>
|
78 | </TouchableOpacity>
|
79 |
|
80 | );
|
81 | }
|
82 | }
|
83 |
|
84 | export default Rectangular;
|