@@ -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