-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBox.js
66 lines (47 loc) · 1.71 KB
/
Box.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
import React, { Component } from 'react';
import { Text, View, Image } from 'react-native';
export default class Box extends Component{
constructor(props){
super(props);
this.state = {
maxHeight: 0
};
}
getHeight(event){
this.setState({
maxHeight : event.nativeEvent.layout.height/2
});
}
render(){
if(this.props.start)
barStart =
<View style={{marginLeft: 14, width: 2, height: this.state.maxHeight + 5, backgroundColor: 'transparent'}} /> ;
else {
barStart =
<View style={{marginLeft: 14, width: 2, height: this.state.maxHeight + 5, backgroundColor: 'black'}} /> ;
}
if(this.props.end)
barEnd =
<View style={{marginLeft: 14,width: 2, height: this.state.maxHeight + 5, backgroundColor: 'transparent'}} /> ;
else {
barEnd =
<View style={{marginLeft: 14,width: 2, height: this.state.maxHeight + 5, backgroundColor: 'black'}} /> ;
}
return(
<View style={{flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center'}}>
<View style={{alignSelf:'flex-start'}}>
{ barStart }
<View style={{marginLeft: 10, width: 10, height: 10, borderRadius: 20, borderWidth: 1, backgroundColor: 'transparent', alignSelf: 'center', justifyContent:'center', alignItems: 'center' }} >
<View style={{width: 5, height: 5, borderRadius: 10, backgroundColor: 'black'}} />
</View>
{ barEnd }
</View>
<View
style={{ marginLeft: 15, padding: 10, backgroundColor: '#F2F1EF', borderWidth: 0.5, flex: 0.9 }}
onLayout={this.getHeight.bind(this)}>
{this.props.children}
</View>
</View>
);
}
}