GuideItem.js
2.1 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import Button from 'apsl-react-native-button';
const {
Component,
} = React;
const {
StyleSheet,
View,
Image,
Text,
Dimensions,
} = ReactNative;
export default class GuideItem extends Component {
constructor(props) {
super(props);
}
static propTypes = {
text: React.PropTypes.string,
textStyle: View.propTypes.style,
buttonText: React.PropTypes.string,
buttonTextStyle: View.propTypes.style,
onPress: React.PropTypes.func,
};
renderText() {
if (this.props.text) {
return (
<Text style={[styles.text, this.props.textStyle]}>{this.props.text}</Text>
);
} else {
return null;
}
}
renderButton() {
if (this.props.buttonText) {
return (
<Button style={[styles.button, this.buttonStyle]}
textStyle={[styles.buttonText, this.props.buttonTextStyle]}
onPress={this.props.onPress} >
{this.props.buttonText}
</Button>
);
} else {
return null;
}
}
render() {
return (
<Image style={styles.image} source={this.props.uri} resizeMode={'contain'} >
{this.renderText()}
{this.renderButton()}
</Image>
);
}
}
let {width, height} = Dimensions.get('window');
let textPaddingTop = height * 7 / 10;
let buttonMargin = (width - 165) / 2;
let styles = StyleSheet.create({
image: {
flex: 1,
flexDirection: 'column',
alignItems: 'center',
width: width,
height: height
},
text: {
color: '#000000',
fontSize: 17,
textAlign: 'center',
marginTop: textPaddingTop,
},
button: {
marginTop: 40,
marginLeft: buttonMargin,
marginRight: buttonMargin,
backgroundColor: '#000000',
borderRadius:5,
},
buttonText: {
color: '#ffffff',
}
});