-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Animate the paid checkmark when paying expense #49438
Changes from all commits
b9799bf
13ee2d7
a524085
a4beb09
aaeef2e
b382e0e
5bdbedf
8fc1158
5afcac4
009e2ea
a46ffb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ function AnimatedSettlementButton({isPaidAnimationRunning, onAnimationFinish, is | |
const paymentCompleteTextScale = useSharedValue(0); | ||
const paymentCompleteTextOpacity = useSharedValue(1); | ||
const height = useSharedValue<number>(variables.componentSizeNormal); | ||
const buttonMarginTop = useSharedValue<number>(styles.expenseAndReportPreviewTextButtonContainer.gap); | ||
const buttonStyles = useAnimatedStyle(() => ({ | ||
transform: [{scale: buttonScale.value}], | ||
opacity: buttonOpacity.value, | ||
|
@@ -33,6 +34,7 @@ function AnimatedSettlementButton({isPaidAnimationRunning, onAnimationFinish, is | |
height: height.value, | ||
justifyContent: 'center', | ||
overflow: 'hidden', | ||
marginTop: buttonMarginTop.value, | ||
})); | ||
const buttonDisabledStyle = isPaidAnimationRunning | ||
? { | ||
|
@@ -48,26 +50,28 @@ function AnimatedSettlementButton({isPaidAnimationRunning, onAnimationFinish, is | |
paymentCompleteTextScale.value = 0; | ||
paymentCompleteTextOpacity.value = 1; | ||
height.value = variables.componentSizeNormal; | ||
}, [buttonScale, buttonOpacity, paymentCompleteTextScale, paymentCompleteTextOpacity, height]); | ||
buttonMarginTop.value = styles.expenseAndReportPreviewTextButtonContainer.gap; | ||
}, [buttonScale, buttonOpacity, paymentCompleteTextScale, paymentCompleteTextOpacity, height, buttonMarginTop, styles.expenseAndReportPreviewTextButtonContainer.gap]); | ||
|
||
useEffect(() => { | ||
if (!isPaidAnimationRunning) { | ||
resetAnimation(); | ||
return; | ||
} | ||
// eslint-disable-next-line react-compiler/react-compiler | ||
buttonScale.value = withTiming(0, {duration: CONST.ANIMATION_PAY_BUTTON_DURATION}); | ||
buttonOpacity.value = withTiming(0, {duration: CONST.ANIMATION_PAY_BUTTON_DURATION}); | ||
paymentCompleteTextScale.value = withTiming(1, {duration: CONST.ANIMATION_PAY_BUTTON_DURATION}); | ||
buttonScale.value = withTiming(0, {duration: CONST.ANIMATION_PAID_DURATION}); | ||
buttonOpacity.value = withTiming(0, {duration: CONST.ANIMATION_PAID_DURATION}); | ||
paymentCompleteTextScale.value = withTiming(1, {duration: CONST.ANIMATION_PAID_DURATION}); | ||
|
||
// Wait for the above animation + 1s delay before hiding the component | ||
const totalDelay = CONST.ANIMATION_PAY_BUTTON_DURATION + CONST.ANIMATION_PAY_BUTTON_HIDE_DELAY; | ||
const totalDelay = CONST.ANIMATION_PAID_DURATION + CONST.ANIMATION_PAID_BUTTON_HIDE_DELAY; | ||
height.value = withDelay( | ||
totalDelay, | ||
withTiming(0, {duration: CONST.ANIMATION_PAY_BUTTON_DURATION}, () => runOnJS(onAnimationFinish)()), | ||
withTiming(0, {duration: CONST.ANIMATION_PAID_DURATION}, () => runOnJS(onAnimationFinish)()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small thing I'm noticing is that we're just using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we talked in slack about using bounce for showing the checkmark |
||
); | ||
paymentCompleteTextOpacity.value = withDelay(totalDelay, withTiming(0, {duration: CONST.ANIMATION_PAY_BUTTON_DURATION})); | ||
}, [isPaidAnimationRunning, onAnimationFinish, buttonOpacity, buttonScale, height, paymentCompleteTextOpacity, paymentCompleteTextScale, resetAnimation]); | ||
buttonMarginTop.value = withDelay(totalDelay, withTiming(0, {duration: CONST.ANIMATION_PAID_DURATION})); | ||
paymentCompleteTextOpacity.value = withDelay(totalDelay, withTiming(0, {duration: CONST.ANIMATION_PAID_DURATION})); | ||
}, [isPaidAnimationRunning, onAnimationFinish, buttonOpacity, buttonScale, height, paymentCompleteTextOpacity, paymentCompleteTextScale, buttonMarginTop, resetAnimation]); | ||
|
||
return ( | ||
<Animated.View style={containerStyles}> | ||
|
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.
bug: preview does not display checkmark - #50219
for details, see - #50554 (comment).