1
1
import React , { Component } from 'react' ;
2
- import { Dimensions , StyleSheet , Animated , ViewPropTypes } from 'react-native' ;
2
+ import { Dimensions , StyleSheet , Animated } from 'react-native' ;
3
3
import PropTypes from 'prop-types' ;
4
- // galio components
4
+ // Galio components
5
5
import Text from './atomic/ions/Text' ;
6
6
import GalioTheme , { withGalio } from './theme' ;
7
7
@@ -20,10 +20,15 @@ class Toast extends Component {
20
20
PropTypes . string ,
21
21
] ) ,
22
22
round : PropTypes . bool ,
23
- style : ViewPropTypes . style ,
24
- textStyle : ViewPropTypes . style ,
23
+ style : PropTypes . shape ( {
24
+ style : PropTypes . any ,
25
+ } ) ,
26
+ textStyle : PropTypes . shape ( {
27
+ style : PropTypes . any ,
28
+ } ) ,
25
29
styles : PropTypes . any ,
26
30
theme : PropTypes . any ,
31
+ useNativeDriver : PropTypes . bool
27
32
} ;
28
33
29
34
static defaultProps = {
@@ -37,6 +42,7 @@ class Toast extends Component {
37
42
textStyle : null ,
38
43
styles : { } ,
39
44
theme : GalioTheme ,
45
+ useNativeDriver : true
40
46
} ;
41
47
42
48
state = {
@@ -49,7 +55,7 @@ class Toast extends Component {
49
55
visibilityTimeout ;
50
56
51
57
componentDidUpdate ( prevProps ) {
52
- const { isShow, fadeInDuration, fadeOutDuration } = this . props ;
58
+ const { isShow, fadeInDuration, fadeOutDuration, useNativeDriver } = this . props ;
53
59
const { isShow : prevIsShow } = prevProps ;
54
60
const { fadeAnim } = this . state ;
55
61
@@ -59,13 +65,15 @@ class Toast extends Component {
59
65
this . animation = Animated . timing ( fadeAnim , {
60
66
toValue : 1 ,
61
67
duration : fadeInDuration ,
68
+ useNativeDriver,
62
69
} ) . start ( ) ;
63
70
}
64
71
65
72
if ( prevIsShow && ! isShow ) {
66
73
this . animation = Animated . timing ( fadeAnim , {
67
74
toValue : 0 ,
68
75
duration : fadeOutDuration ,
76
+ useNativeDriver,
69
77
} ) . start ( ) ;
70
78
71
79
this . visibilityTimeout = setTimeout ( ( ) => {
@@ -84,7 +92,7 @@ class Toast extends Component {
84
92
}
85
93
}
86
94
87
- setVisibility = isShow => this . setState ( { isShow } ) ;
95
+ setVisibility = ( isShow ) => this . setState ( { isShow } ) ;
88
96
89
97
getTopPosition = ( ) => {
90
98
const { positionIndicator, positionOffset } = this . props ;
@@ -135,7 +143,7 @@ class Toast extends Component {
135
143
}
136
144
}
137
145
138
- const styles = theme =>
146
+ const styles = ( theme ) =>
139
147
StyleSheet . create ( {
140
148
toast : {
141
149
padding : theme . SIZES . BASE ,
0 commit comments