Skip to content

Commit 46fac24

Browse files
authored
customelement style (#1626)
1 parent 8e537bf commit 46fac24

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/components/progressBar/index.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import isUndefined from 'lodash/isUndefined';
12
import React, {PureComponent} from 'react';
23
import {Animated, Easing, StyleSheet, StyleProp, ViewStyle, LayoutChangeEvent} from 'react-native';
34
import {asBaseComponent} from '../../commons/new';
@@ -6,7 +7,6 @@ import {Constants} from '../../helpers';
67
import View from '../view';
78
import {Colors, BorderRadiuses, Spacings} from '../../style';
89

9-
1010
const CONTAINER_HEIGHT = Spacings.s2;
1111
const FULL_WIDTH_CONTAINER_HEIGHT = Spacings.s1;
1212
const TABLET_CONTAINER_HEIGHT = 6;
@@ -33,11 +33,11 @@ interface Props {
3333
/**
3434
* Progress color
3535
*/
36-
progressColor?: string,
36+
progressColor?: string;
3737
/**
3838
* Custom element to render on top of the animated progress
3939
*/
40-
customElement?: JSX.Element
40+
customElement?: JSX.Element;
4141
}
4242
export type ProgressBarProps = Props;
4343

@@ -50,7 +50,7 @@ class ProgressBar extends PureComponent<Props, State> {
5050

5151
static defaultProps: Partial<Props> = {
5252
progress: 0
53-
}
53+
};
5454

5555
progressAnimation: Animated.Value;
5656

@@ -78,7 +78,7 @@ class ProgressBar extends PureComponent<Props, State> {
7878
};
7979

8080
animateProgress(toValue?: number) {
81-
if (toValue) {
81+
if (!isUndefined(toValue)) {
8282
Animated.timing(this.progressAnimation, {
8383
duration: 220,
8484
easing: Easing.ease,
@@ -130,7 +130,7 @@ class ProgressBar extends PureComponent<Props, State> {
130130

131131
if (customElement) {
132132
return React.cloneElement(customElement, {
133-
style: [customElement.props.style, styles.progress]
133+
style: [customElement.props.style, styles.customElement]
134134
});
135135
}
136136
}
@@ -179,6 +179,10 @@ const styles = StyleSheet.create({
179179
justifyContent: 'center',
180180
overflow: 'hidden'
181181
},
182+
customElement: {
183+
height: '100%',
184+
width: '100%'
185+
},
182186
inlineBorderRadius: {
183187
borderRadius: BorderRadiuses.br100
184188
},

0 commit comments

Comments
 (0)