-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCustomButton.js
80 lines (66 loc) · 1.57 KB
/
CustomButton.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { TouchableOpacity, Text, StyleSheet,Image } from 'react-native';
var defaultButtonText = "Press Me"
class CustomButton extends Component {
constructor (props){
super(props);
this.state = {
clicked: false
}
}
render() {
const { text, onPress} = this.props;
return (
<TouchableOpacity style={styles.buttonStyle}
onPress={() => this.setState({clicked:!this.state.clicked})}>
<Text
accessible= {true}
testID= {"ButtonText"}
accessibilityLabel= {"ButtonTextDesc"}
style={styles.textStyle}>
{!this.state.clicked? defaultButtonText: "Polidea"}
</Text>
<Image
accessible={true}
testID='ButtonImage'
style={!this.state.clicked ? styles.imageStyleDefault : styles.imageStyle}
source={{uri:'https://pbs.twimg.com/profile_images/580677325974536192/oP6A55eF_400x400.png'}}
/>
</TouchableOpacity>
);
}
}
CustomButton.propTypes = {
showLogo: PropTypes.bool,
onPress: PropTypes.func
};
const styles = StyleSheet.create({
textStyle: {
fontSize:20,
color: '#ffffff',
textAlign: 'center'
},
buttonStyle: {
padding:10,
backgroundColor: '#209DD8',
borderRadius:10,
},
imageStyle: {
width: 150,
height: 150,
backgroundColor: "#209DD8",
borderRadius:10,
justifyContent: 'center',
alignItems: 'center'
},
imageStyleDefault: {
width: 0,
height: 0,
backgroundColor: "#209DD8",
borderRadius:10,
justifyContent: 'center',
alignItems: 'center'
}
});
export default CustomButton;