@@ -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 ,
@@ -88,7 +92,7 @@ export default class Toast extends Component {
8892
8993 render ( ) {
9094 let pos ;
91- switch ( this . props . position ) {
95+ switch ( 'center' ) {
9296 case 'top' :
9397 pos = this . props . positionValue ;
9498 break ;
@@ -101,16 +105,19 @@ export default class Toast extends Component {
101105 }
102106
103107 const view = this . state . isShow ?
108+ < TouchableWithoutFeedback onPress = { this . onPress } >
104109 < View
105110 style = { [ styles . container , { top : pos } ] }
106- pointerEvents = "none "
111+ pointerEvents = "auto "
107112 >
108113 < Animated . View
109114 style = { [ styles . content , { opacity : this . state . opacityValue } , this . props . style ] }
110115 >
111116 { React . isValidElement ( this . state . text ) ? this . state . text : < Text style = { this . props . textStyle } > { this . state . text } </ Text > }
112117 </ Animated . View >
113- </ View > : null ;
118+ </ View >
119+ </ TouchableWithoutFeedback >
120+ : null ;
114121 return view ;
115122 }
116123}
0 commit comments