File tree 2 files changed +16
-17
lines changed
2 files changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -14,12 +14,7 @@ class Toast extends Component {
14
14
static durations = durations ;
15
15
16
16
static show = ( message , options = { position : positions . BOTTOM , duration : durations . SHORT } ) => {
17
- return new RootSiblings ( < ToastContainer
18
- { ...options }
19
- visible = { true }
20
- >
21
- { message }
22
- </ ToastContainer > ) ;
17
+ return new RootSiblings ( < ToastContainer message = { message } { ...options } visible = { true } /> ) ;
23
18
} ;
24
19
25
20
static hide = toast => {
Original file line number Diff line number Diff line change @@ -64,6 +64,8 @@ class ToastContainer extends Component {
64
64
static propTypes = {
65
65
...ViewPropTypes ,
66
66
containerStyle : ViewPropTypes . style ,
67
+ message : PropTypes . string ,
68
+ component : PropTypes . element ,
67
69
duration : PropTypes . number ,
68
70
visible : PropTypes . bool ,
69
71
position : PropTypes . number ,
@@ -236,24 +238,26 @@ class ToastContainer extends Component {
236
238
style = { [
237
239
styles . containerStyle ,
238
240
{ marginHorizontal : windowWidth * ( ( 1 - TOAST_MAX_WIDTH ) / 2 ) } ,
239
- props . containerStyle ,
240
241
props . backgroundColor && { backgroundColor : props . backgroundColor } ,
241
- {
242
- opacity : this . state . opacity
243
- } ,
242
+ props . containerStyle ,
243
+ { opacity : this . state . opacity } ,
244
244
props . shadow && styles . shadowStyle ,
245
245
props . shadowColor && { shadowColor : props . shadowColor }
246
246
] }
247
247
pointerEvents = "none"
248
248
ref = { ele => this . _root = ele }
249
249
>
250
- < Text style = { [
251
- styles . textStyle ,
252
- props . textStyle ,
253
- props . textColor && { color : props . textColor }
254
- ] } >
255
- { this . props . children }
256
- </ Text >
250
+ { this . props . component ? (
251
+ this . props . component
252
+ ) : (
253
+ < Text style = { [
254
+ styles . textStyle ,
255
+ props . textStyle ,
256
+ props . textColor && { color : props . textColor }
257
+ ] } >
258
+ { this . props . message }
259
+ </ Text >
260
+ ) }
257
261
</ Animated . View >
258
262
</ TouchableWithoutFeedback >
259
263
</ View > : null ;
You can’t perform that action at this time.
0 commit comments