This repository has been archived by the owner on Jun 15, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show progress on file upload and download (#608)
- Loading branch information
1 parent
f1e707c
commit 51d9707
Showing
9 changed files
with
206 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useCallback, useRef } from 'react' | ||
import { Animated } from 'react-native' | ||
|
||
export const useProgressBar = () => { | ||
const counterRef = useRef(new Animated.Value(0)).current | ||
|
||
const updateProgressBar = useCallback( | ||
(percentComplete: number) => { | ||
Animated.timing(counterRef, { | ||
toValue: percentComplete, | ||
duration: 500, | ||
useNativeDriver: false, | ||
}).start() | ||
}, | ||
[counterRef] | ||
) | ||
|
||
const progressBarWidth = counterRef.interpolate({ | ||
inputRange: [0, 100], | ||
outputRange: ['0%', '100%'], | ||
extrapolate: 'identity', | ||
}) | ||
|
||
return { | ||
updateProgressBar, | ||
progressBarWidth, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export enum ErrorMessage { | ||
GeneralText = 'An error occurred. Please try again later.', | ||
} |
Oops, something went wrong.