-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Loading state perception improvement #57610
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
Merged
mountiny
merged 36 commits into
Expensify:main
from
callstack-internal:loading-state-perception-improvement
Mar 10, 2025
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
d913d8a
Loading state perception improvement
martasudol 48c0a57
Merge branch 'fix-infinite-loader' into loading-state-perception-impr…
martasudol 677c620
Loading state perception improvement - loading bar and loading older …
martasudol fcaead7
Loading state perception improvement: less blinking skeletons
martasudol 6a81a03
remove redundant reportActions props
martasudol 8870944
remove redundant imports
martasudol 769362b
loading bar animation performance improvement
martasudol c86d880
Merge branch 'main' into loading-state-perception-improvement
martasudol 44ef831
manage scrolling position only for web and desktop
martasudol a423100
fix linter errors
martasudol 8f075e3
fix linter errors
martasudol f300945
Merge branch 'main' into loading-state-perception-improvement
martasudol 2dcbe0c
Merge branch 'main' into loading-state-perception-improvement
martasudol 3cc105b
Addressed PR comments
martasudol a0de6d5
Fix prettier error & default isLoadingOlderReportActions flag
martasudol 4315668
fix linter errors
martasudol 821bd06
show loading bar when fetching newer actions
martasudol 9a61799
Merge branch 'main' into loading-state-perception-improvement
martasudol ce88678
Loading state perception improvement
martasudol c2b48f6
Loading state perception improvement - loading bar and loading older …
martasudol 4ee4077
Loading state perception improvement: less blinking skeletons
martasudol 433cea2
remove redundant reportActions props
martasudol fad5bdb
remove redundant imports
martasudol 99bce83
loading bar animation performance improvement
martasudol 21d7f28
manage scrolling position only for web and desktop
martasudol 8f58783
fix linter errors
martasudol 502cf8c
fix linter errors
martasudol ec54ce5
Addressed PR comments
martasudol 17e18ac
Fix prettier error & default isLoadingOlderReportActions flag
martasudol d4a73a6
fix linter errors
martasudol d7c6e08
show loading bar when fetching newer actions
martasudol 4bdfa9c
Merge branch 'main' into loading-state-perception-improvement
martasudol 119f91c
Merge branch 'loading-state-perception-improvement' of github.com:cal…
martasudol 2590b10
load newer actions fix
martasudol 322dcd1
load newer actions fix
martasudol 863a88d
Addressed comments
martasudol 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,83 +1,68 @@ | ||
| import React, {useEffect} from 'react'; | ||
| import Animated, {cancelAnimation, Easing, useAnimatedStyle, useSharedValue, withDelay, withRepeat, withSequence, withTiming} from 'react-native-reanimated'; | ||
| import {View} from 'react-native'; | ||
| import Animated, {useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import colors from '@styles/theme/colors'; | ||
| import CONST from '@src/CONST'; | ||
|
|
||
| type LoadingBarProps = { | ||
| // Whether or not to show the loading bar | ||
| // Whether to show the loading bar | ||
| shouldShow: boolean; | ||
| }; | ||
|
|
||
| function LoadingBar({shouldShow}: LoadingBarProps) { | ||
| const left = useSharedValue(0); | ||
| const width = useSharedValue(0); | ||
| const left = useSharedValue(-30); | ||
| const opacity = useSharedValue(0); | ||
| const isAnimating = useSharedValue(false); | ||
| const styles = useThemeStyles(); | ||
|
|
||
| useEffect(() => { | ||
| if (shouldShow) { | ||
| // eslint-disable-next-line react-compiler/react-compiler | ||
| left.set(0); | ||
| width.set(0); | ||
| opacity.set(withTiming(1, {duration: CONST.ANIMATED_PROGRESS_BAR_OPACITY_DURATION})); | ||
| if (shouldShow && !isAnimating.get()) { | ||
| isAnimating.set(true); | ||
| opacity.set(withTiming(1, {duration: CONST.TIMING.SKELETON_FADE_DURATION})); | ||
|
|
||
| left.set( | ||
| 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.set( | ||
| 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, | ||
| ), | ||
| ), | ||
| withTiming(100, {duration: CONST.TIMING.SKELETON_SLIDE_DURATION}, () => { | ||
| requestAnimationFrame(() => { | ||
| if (shouldShow) { | ||
| left.set(-30); | ||
| left.set(withTiming(100, {duration: CONST.TIMING.SKELETON_SLIDE_DURATION})); | ||
| } else { | ||
| opacity.set( | ||
| withTiming(0, {duration: CONST.TIMING.SKELETON_FADE_DURATION}, () => { | ||
| isAnimating.set(false); | ||
| }), | ||
| ); | ||
| } | ||
| }); | ||
| }), | ||
| ); | ||
| } else { | ||
| } else if (!shouldShow) { | ||
| opacity.set( | ||
| withTiming(0, {duration: CONST.ANIMATED_PROGRESS_BAR_OPACITY_DURATION}, () => { | ||
| cancelAnimation(left); | ||
| cancelAnimation(width); | ||
| withTiming(0, {duration: CONST.TIMING.SKELETON_FADE_DURATION}, () => { | ||
| isAnimating.set(false); | ||
| }), | ||
| ); | ||
| } | ||
| // we want to update only when shouldShow changes | ||
| // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps | ||
| }, [shouldShow]); | ||
|
|
||
| const animatedIndicatorStyle = useAnimatedStyle(() => ({ | ||
| const barStyle = useAnimatedStyle(() => ({ | ||
| left: `${left.get()}%`, | ||
| width: `${width.get()}%`, | ||
| })); | ||
|
|
||
| const animatedContainerStyle = useAnimatedStyle(() => ({ | ||
| width: '30%', | ||
| height: '100%', | ||
| backgroundColor: colors.green, | ||
| opacity: opacity.get(), | ||
| borderRadius: 2, | ||
| })); | ||
|
|
||
| return ( | ||
| <Animated.View style={[styles.progressBarWrapper, animatedContainerStyle]}> | ||
| <Animated.View style={[styles.progressBar, animatedIndicatorStyle]} /> | ||
| </Animated.View> | ||
| <View style={[styles.progressBarWrapper]}> | ||
| <Animated.View style={barStyle} /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| LoadingBar.displayName = 'ProgressBar'; | ||
|
martasudol marked this conversation as resolved.
|
||
| LoadingBar.displayName = 'LoadingBar'; | ||
|
|
||
| export default LoadingBar; | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.