Repository navigation
Expand file tree
/
Copy pathTextBtn.js
More file actions
executable file
·78 lines (71 loc) · 1.98 KB
/
Copy pathTextBtn.js
File metadata and controls
executable file
·78 lines (71 loc) · 1.98 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
import * as React from 'react'
import { StyleSheet, Text, TouchableOpacity } from 'react-native'
import * as Util from '../utils/constUtil'
import { scaleSize } from '../utils'
const WIDTH = scaleSize(120)
export default class TextBtn extends React.Component {
props: {
width?: number,
height?: number,
btnText: string,
btnClick: () => {},
textStyle?: any,
containerStyle?: any,
}
constructor(props) {
super(props)
this.state = {
clicked: false,
}
}
_btnClick = () => {
// if (!this.state.clicked) {
// this.setState({ clicked: true });
// }
if (this.props.btnClick) {
this.props.btnClick()
}
}
render() {
const containerWidth = this.props.width ? this.props.width : WIDTH
const containerHeight = this.props.height ? this.props.height : null
return (
<TouchableOpacity
accessible={true}
accessibilityLabel={this.props.btnText}
activeOpacity={0.8}
style={[
styles.container,
this.props.containerStyle,
this.props.width && { width: containerWidth },
this.props.height && { height: containerHeight },
]}
onPress={this._btnClick}
>
<Text style={[styles.btnText, this.props.textStyle]}>
{this.props.btnText ? this.props.btnText : '按钮'}
</Text>
{/*<Text style={[styles.btnText, { color: this.state.clicked ? Util.USUAL_PURPLE : textBlue }]}>{this.props.btnText ? this.props.btnText : '按钮'}</Text>*/}
</TouchableOpacity>
)
}
}
const styles = StyleSheet.create({
container: {
width: WIDTH,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
titleBtn: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
btnText: {
// textDecorationLine: 'underline',
fontSize: 17,
color: Util.USUAL_BLUE,
alignSelf: 'center',
},
})