1
+ import isUndefined from 'lodash/isUndefined' ;
1
2
import React , { PureComponent } from 'react' ;
2
3
import { Animated , Easing , StyleSheet , StyleProp , ViewStyle , LayoutChangeEvent } from 'react-native' ;
3
4
import { asBaseComponent } from '../../commons/new' ;
@@ -6,7 +7,6 @@ import {Constants} from '../../helpers';
6
7
import View from '../view' ;
7
8
import { Colors , BorderRadiuses , Spacings } from '../../style' ;
8
9
9
-
10
10
const CONTAINER_HEIGHT = Spacings . s2 ;
11
11
const FULL_WIDTH_CONTAINER_HEIGHT = Spacings . s1 ;
12
12
const TABLET_CONTAINER_HEIGHT = 6 ;
@@ -33,11 +33,11 @@ interface Props {
33
33
/**
34
34
* Progress color
35
35
*/
36
- progressColor ?: string ,
36
+ progressColor ?: string ;
37
37
/**
38
38
* Custom element to render on top of the animated progress
39
39
*/
40
- customElement ?: JSX . Element
40
+ customElement ?: JSX . Element ;
41
41
}
42
42
export type ProgressBarProps = Props ;
43
43
@@ -50,7 +50,7 @@ class ProgressBar extends PureComponent<Props, State> {
50
50
51
51
static defaultProps : Partial < Props > = {
52
52
progress : 0
53
- }
53
+ } ;
54
54
55
55
progressAnimation : Animated . Value ;
56
56
@@ -78,7 +78,7 @@ class ProgressBar extends PureComponent<Props, State> {
78
78
} ;
79
79
80
80
animateProgress ( toValue ?: number ) {
81
- if ( toValue ) {
81
+ if ( ! isUndefined ( toValue ) ) {
82
82
Animated . timing ( this . progressAnimation , {
83
83
duration : 220 ,
84
84
easing : Easing . ease ,
@@ -130,7 +130,7 @@ class ProgressBar extends PureComponent<Props, State> {
130
130
131
131
if ( customElement ) {
132
132
return React . cloneElement ( customElement , {
133
- style : [ customElement . props . style , styles . progress ]
133
+ style : [ customElement . props . style , styles . customElement ]
134
134
} ) ;
135
135
}
136
136
}
@@ -179,6 +179,10 @@ const styles = StyleSheet.create({
179
179
justifyContent : 'center' ,
180
180
overflow : 'hidden'
181
181
} ,
182
+ customElement : {
183
+ height : '100%' ,
184
+ width : '100%'
185
+ } ,
182
186
inlineBorderRadius : {
183
187
borderRadius : BorderRadiuses . br100
184
188
} ,
0 commit comments