diff --git a/example/src/Examples/ProgressBarExample.tsx b/example/src/Examples/ProgressBarExample.tsx
index a51c2f8301..e1b2b61a9a 100644
--- a/example/src/Examples/ProgressBarExample.tsx
+++ b/example/src/Examples/ProgressBarExample.tsx
@@ -94,11 +94,23 @@ const ProgressBarExample = () => {
ProgressBar with animated value
+
+
+
+ ProgressBar with custom percentage height
+
+
+
);
};
@@ -112,9 +124,16 @@ const styles = StyleSheet.create({
row: {
marginVertical: 10,
},
+ fullRow: {
+ height: '100%',
+ width: '100%',
+ },
customHeight: {
height: 20,
},
+ customPercentageHeight: {
+ height: '50%',
+ },
progressBar: {
height: 15,
},
diff --git a/src/components/ProgressBar.tsx b/src/components/ProgressBar.tsx
index 89b9fe67c9..3c7443e9bc 100644
--- a/src/components/ProgressBar.tsx
+++ b/src/components/ProgressBar.tsx
@@ -74,6 +74,7 @@ const ProgressBar = ({
animatedValue,
...rest
}: Props) => {
+ const isWeb = Platform.OS === 'web';
const theme = useInternalTheme(themeOverrides);
const { current: timer } = React.useRef(
new Animated.Value(0)
@@ -123,7 +124,7 @@ const ProgressBar = ({
duration: INDETERMINATE_DURATION,
toValue: 1,
// Animated.loop does not work if useNativeDriver is true on web
- useNativeDriver: Platform.OS !== 'web',
+ useNativeDriver: !isWeb,
isInteraction: false,
});
}
@@ -140,7 +141,7 @@ const ProgressBar = ({
isInteraction: false,
}).start();
}
- }, [fade, scale, indeterminate, timer, progress]);
+ }, [fade, scale, indeterminate, timer, progress, isWeb]);
const stopAnimation = React.useCallback(() => {
// Stop indeterminate animation
@@ -194,6 +195,7 @@ const ProgressBar = ({
accessibilityValue={
indeterminate ? {} : { min: 0, max: 100, now: progress * 100 }
}
+ style={isWeb && styles.webContainer}
>
{
const AnimatedProgressBar = Animated.createAnimatedComponent(ClassProgressBar);
+afterEach(() => {
+ Platform.OS = 'ios';
+});
+
it('renders progress bar with animated value', async () => {
const tree = render();
await waitFor(() => tree.getByRole(a11yRole).props.onLayout(layoutEvent));
@@ -59,3 +63,13 @@ it('renders indeterminate progress bar', async () => {
expect(tree.toJSON()).toMatchSnapshot();
});
+
+it('renders progress bar with full height on web', () => {
+ Platform.OS = 'web';
+ const tree = render();
+
+ expect(tree.getByRole(a11yRole)).toHaveStyle({
+ width: '100%',
+ height: '100%',
+ });
+});
diff --git a/src/components/__tests__/__snapshots__/ProgressBar.test.tsx.snap b/src/components/__tests__/__snapshots__/ProgressBar.test.tsx.snap
index ead876fb2b..291bd6739f 100644
--- a/src/components/__tests__/__snapshots__/ProgressBar.test.tsx.snap
+++ b/src/components/__tests__/__snapshots__/ProgressBar.test.tsx.snap
@@ -17,6 +17,7 @@ exports[`renders colored progress bar 1`] = `
}
accessible={true}
onLayout={[Function]}
+ style={false}
>