-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton.js
79 lines (71 loc) · 2.05 KB
/
Button.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
import React, { Component, PropTypes } from 'react';
import { View, Text,TouchableWithoutFeedback, TouchableHighlight,Navigator, Image, TouchableOpacity } from 'react-native';
var styles = require('./styles');
export default class Button extends Component {
constructor(props) {
super(props);
var ctx = this;
this.state = {pressed: false};
this.pressed = function(){
ctx.props.onclick();
ctx.setState({pressed:true});
}
this.released = function(){
if(!ctx.props.willKillMe){
setTimeout(function(){
ctx.setState({pressed:false});
},500);
}
}
}
render() {
var tint;
var tintBottom;
var sideImage;
var extraBottomStyle = styles.inlineView;
var pressedConfirmStyle = styles.pressedBtn;
var btnTextStyle = [styles.buttonText];
switch(this.props.tint){
default:
break;
case "pale":
tint = styles.paleButton;
tintBottom = styles.paleBottom;
break;
case "bright":
tint = styles.brightButton;
tintBottom = styles.brightBottom;
break;
case "facebook":
tint = styles.fbButton;
tintBottom = styles.fbBottom;
sideImage = <Image style={styles.buttonImage} source={require('./images/fbIcon.png')}/>;
btnTextStyle.push(styles.fbText);
break;
case "chal":
tint = styles.redButton;
tintBottom = styles.redBottom;
extraBottomStyle = styles.smallBtn;
btnTextStyle.push(styles.smallBtnTxt);
pressedConfirmStyle = styles.pressedSmall;
break;
}
var pressedStyle;
if(this.state.pressed){
pressedStyle = pressedConfirmStyle;
}
return (
<View>
<View style={[styles.button, styles.buttonBottom, tintBottom, extraBottomStyle]}>
<Text style={btnTextStyle}>{" "}</Text>
</View>
<TouchableWithoutFeedback onPressIn={this.pressed} onPressOut={this.released}>
<View style={[styles.button, tint, extraBottomStyle,pressedStyle]}>
{sideImage}
<Text style={btnTextStyle}>{this.props.text}</Text>
</View>
</TouchableWithoutFeedback>
</View>
)
}
}