Skip to content

Commit fd914b1

Browse files
authored
Merge pull request #58 from imMayankRaj/master
Added onPress feature
2 parents 1b7d5e9 + 600647e commit fd914b1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

index.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
Animated,
1414
Dimensions,
1515
Text,
16+
TouchableWithoutFeedback,
1617
ViewPropTypes as RNViewPropTypes,
1718
} from 'react-native'
1819

@@ -36,9 +37,12 @@ export default class Toast extends Component {
3637
}
3738
}
3839

39-
show(text, duration, callback) {
40+
show(text, duration, callback, onPress) {
4041
this.duration = typeof duration === 'number' ? duration : DURATION.LENGTH_SHORT;
4142
this.callback = callback;
43+
console.log(typeof onPress)
44+
if(typeof onPress === 'function')
45+
this.onPress = onPress
4246
this.setState({
4347
isShow: true,
4448
text: text,
@@ -93,7 +97,7 @@ export default class Toast extends Component {
9397

9498
render() {
9599
let pos;
96-
switch (this.props.position) {
100+
switch ('center') {
97101
case 'top':
98102
pos = this.props.positionValue;
99103
break;
@@ -106,16 +110,19 @@ export default class Toast extends Component {
106110
}
107111

108112
const view = this.state.isShow ?
113+
<TouchableWithoutFeedback onPress={this.onPress} >
109114
<View
110115
style={[styles.container, { top: pos }]}
111-
pointerEvents="none"
116+
pointerEvents="auto"
112117
>
113118
<Animated.View
114119
style={[styles.content, { opacity: this.state.opacityValue }, this.props.style]}
115120
>
116121
{React.isValidElement(this.state.text) ? this.state.text : <Text style={this.props.textStyle}>{this.state.text}</Text>}
117122
</Animated.View>
118-
</View> : null;
123+
</View>
124+
</TouchableWithoutFeedback>
125+
: null;
119126
return view;
120127
}
121128
}

0 commit comments

Comments
 (0)