@@ -13,6 +13,7 @@ import {
13
13
Animated ,
14
14
Dimensions ,
15
15
Text ,
16
+ TouchableWithoutFeedback ,
16
17
ViewPropTypes as RNViewPropTypes ,
17
18
} from 'react-native'
18
19
@@ -36,9 +37,12 @@ export default class Toast extends Component {
36
37
}
37
38
}
38
39
39
- show ( text , duration , callback ) {
40
+ show ( text , duration , callback , onPress ) {
40
41
this . duration = typeof duration === 'number' ? duration : DURATION . LENGTH_SHORT ;
41
42
this . callback = callback ;
43
+ console . log ( typeof onPress )
44
+ if ( typeof onPress === 'function' )
45
+ this . onPress = onPress
42
46
this . setState ( {
43
47
isShow : true ,
44
48
text : text ,
@@ -93,7 +97,7 @@ export default class Toast extends Component {
93
97
94
98
render ( ) {
95
99
let pos ;
96
- switch ( this . props . position ) {
100
+ switch ( 'center' ) {
97
101
case 'top' :
98
102
pos = this . props . positionValue ;
99
103
break ;
@@ -106,16 +110,19 @@ export default class Toast extends Component {
106
110
}
107
111
108
112
const view = this . state . isShow ?
113
+ < TouchableWithoutFeedback onPress = { this . onPress } >
109
114
< View
110
115
style = { [ styles . container , { top : pos } ] }
111
- pointerEvents = "none "
116
+ pointerEvents = "auto "
112
117
>
113
118
< Animated . View
114
119
style = { [ styles . content , { opacity : this . state . opacityValue } , this . props . style ] }
115
120
>
116
121
{ React . isValidElement ( this . state . text ) ? this . state . text : < Text style = { this . props . textStyle } > { this . state . text } </ Text > }
117
122
</ Animated . View >
118
- </ View > : null ;
123
+ </ View >
124
+ </ TouchableWithoutFeedback >
125
+ : null ;
119
126
return view ;
120
127
}
121
128
}
0 commit comments