-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: Add loading indicator when ReconnectApp is running #52272
Open
nkdengineer
wants to merge
11
commits into
Expensify:main
Choose a base branch
from
nkdengineer:fix/46611-re-create
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+106
−2
Open
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1c3c035
feature: Add loading indicator when ReconnectApp is running
nkdengineer c8f048a
fix lint
nkdengineer c69bf57
Merge branch 'main' into fix/46611-re-create
nkdengineer a3dcad3
remove isVisible shared value
nkdengineer 7bc1067
Merge branch 'main' into fix/46611-re-create
nkdengineer b88bc5d
Merge branch 'main' into fix/46611-re-create
nkdengineer 0309518
resolve conflict
nkdengineer cd37b51
fix lint
nkdengineer 7e16699
fix border radius
nkdengineer 2d79dbc
merge main
nkdengineer 4015f65
fix loading bar animation doesn't work
nkdengineer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React, {useEffect} from 'react'; | ||
import Animated, {cancelAnimation, Easing, useAnimatedStyle, useSharedValue, withDelay, withRepeat, withSequence, withTiming} from 'react-native-reanimated'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import CONST from '@src/CONST'; | ||
|
||
type LoadingBarProps = { | ||
// Whether or not to show the loading bar | ||
shouldShow: boolean; | ||
}; | ||
|
||
function LoadingBar({shouldShow}: LoadingBarProps) { | ||
const left = useSharedValue(0); | ||
const width = useSharedValue(0); | ||
const opacity = useSharedValue(0); | ||
const styles = useThemeStyles(); | ||
|
||
useEffect(() => { | ||
if (shouldShow) { | ||
// eslint-disable-next-line react-compiler/react-compiler | ||
left.value = 0; | ||
width.value = 0; | ||
opacity.value = withTiming(1, {duration: CONST.ANIMATED_PROGRESS_BAR_OPACITY_DURATION}); | ||
|
||
left.value = withDelay( | ||
CONST.ANIMATED_PROGRESS_BAR_DELAY, | ||
withRepeat( | ||
withSequence( | ||
withTiming(0, {duration: 0}), | ||
withTiming(0, {duration: CONST.ANIMATED_PROGRESS_BAR_DURATION, easing: Easing.bezier(0.65, 0, 0.35, 1)}), | ||
withTiming(100, {duration: CONST.ANIMATED_PROGRESS_BAR_DURATION, easing: Easing.bezier(0.65, 0, 0.35, 1)}), | ||
), | ||
-1, | ||
false, | ||
), | ||
); | ||
|
||
width.value = withDelay( | ||
CONST.ANIMATED_PROGRESS_BAR_DELAY, | ||
withRepeat( | ||
withSequence( | ||
withTiming(0, {duration: 0}), | ||
withTiming(100, {duration: CONST.ANIMATED_PROGRESS_BAR_DURATION, easing: Easing.bezier(0.65, 0, 0.35, 1)}), | ||
withTiming(0, {duration: CONST.ANIMATED_PROGRESS_BAR_DURATION, easing: Easing.bezier(0.65, 0, 0.35, 1)}), | ||
), | ||
-1, | ||
false, | ||
), | ||
); | ||
} else { | ||
opacity.value = withTiming(0, {duration: CONST.ANIMATED_PROGRESS_BAR_OPACITY_DURATION}, () => { | ||
cancelAnimation(left); | ||
cancelAnimation(width); | ||
}); | ||
} | ||
// we want to update only when shouldShow changes | ||
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps | ||
}, [shouldShow]); | ||
|
||
const animatedIndicatorStyle = useAnimatedStyle(() => ({ | ||
left: `${left.value}%`, | ||
width: `${width.value}%`, | ||
})); | ||
|
||
const animatedContainerStyle = useAnimatedStyle(() => ({ | ||
opacity: opacity.value, | ||
})); | ||
|
||
return ( | ||
<Animated.View style={[styles.progressBarWrapper, animatedContainerStyle]}> | ||
{opacity.value > 0 ? <Animated.View style={[styles.progressBar, animatedIndicatorStyle]} /> : null} | ||
</Animated.View> | ||
); | ||
} | ||
|
||
LoadingBar.displayName = 'ProgressBar'; | ||
|
||
export default LoadingBar; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB but why 5? If the height is only 2 total, couldn't the border radius just be 2 as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nkdengineer outstanding q here :)