@@ -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 ,
@@ -88,7 +92,7 @@ export default class Toast extends Component {
88
92
89
93
render ( ) {
90
94
let pos ;
91
- switch ( this . props . position ) {
95
+ switch ( 'center' ) {
92
96
case 'top' :
93
97
pos = this . props . positionValue ;
94
98
break ;
@@ -101,16 +105,19 @@ export default class Toast extends Component {
101
105
}
102
106
103
107
const view = this . state . isShow ?
108
+ < TouchableWithoutFeedback onPress = { this . onPress } >
104
109
< View
105
110
style = { [ styles . container , { top : pos } ] }
106
- pointerEvents = "none "
111
+ pointerEvents = "auto "
107
112
>
108
113
< Animated . View
109
114
style = { [ styles . content , { opacity : this . state . opacityValue } , this . props . style ] }
110
115
>
111
116
{ React . isValidElement ( this . state . text ) ? this . state . text : < Text style = { this . props . textStyle } > { this . state . text } </ Text > }
112
117
</ Animated . View >
113
- </ View > : null ;
118
+ </ View >
119
+ </ TouchableWithoutFeedback >
120
+ : null ;
114
121
return view ;
115
122
}
116
123
}
0 commit comments