22 * react-native-easy-toast
33 * https://github.com/crazycodeboy/react-native-easy-toast
44 * Email:crazycodeboy@gmail.com
5- * Blog:http://www.devio.org/
5+ * Blog:http://jiapenghui.com
66 * @flow
77 */
88
99import React , { Component } from 'react' ;
10+ import PropTypes from 'prop-types' ;
1011import {
1112 StyleSheet ,
1213 View ,
1314 Animated ,
1415 Dimensions ,
1516 Text ,
17+ ViewPropTypes as RNViewPropTypes ,
1618} from 'react-native'
1719
1820import PropTypes from 'prop-types' ;
19-
21+ const ViewPropTypes = RNViewPropTypes || View . propTypes ;
2022export const DURATION = {
21- LENGTH_LONG : 2000 ,
2223 LENGTH_SHORT : 500 ,
2324 FOREVER : 0 ,
2425} ;
@@ -101,15 +102,15 @@ export default class Toast extends Component {
101102 pos = height - this . props . positionValue ;
102103 break ;
103104 }
104-
105+
105106 const view = this . state . isShow ?
106107 < View
107108 style = { [ styles . container , { top : pos } ] }
108109 pointerEvents = "none"
109- >
110+ >
110111 < Animated . View
111112 style = { [ styles . content , { opacity : this . state . opacityValue } , this . props . style ] }
112- >
113+ >
113114 < Text style = { this . props . textStyle } > { this . state . text } </ Text >
114115 </ Animated . View >
115116 </ View > : null ;
@@ -122,7 +123,9 @@ const styles = StyleSheet.create({
122123 position : 'absolute' ,
123124 left : 0 ,
124125 right : 0 ,
126+ elevation : 999 ,
125127 alignItems : 'center' ,
128+ zIndex : 10000 ,
126129 } ,
127130 content : {
128131 backgroundColor : 'black' ,
@@ -135,17 +138,17 @@ const styles = StyleSheet.create({
135138} ) ;
136139
137140Toast . propTypes = {
138- style : PropTypes . any ,
141+ style : ViewPropTypes . style ,
139142 position : PropTypes . oneOf ( [
140143 'top' ,
141144 'center' ,
142145 'bottom' ,
143146 ] ) ,
144- textStyle : PropTypes . any ,
145- positionValue : PropTypes . number ,
146- fadeInDuration : PropTypes . number ,
147- fadeOutDuration : PropTypes . number ,
148- opacity : PropTypes . number
147+ textStyle : Text . propTypes . style ,
148+ positionValue :PropTypes . number ,
149+ fadeInDuration :PropTypes . number ,
150+ fadeOutDuration :PropTypes . number ,
151+ opacity :PropTypes . number
149152}
150153
151154Toast . defaultProps = {
0 commit comments