-
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
Animations for the IOU flow #4070
Changes from 9 commits
b392aee
2401b69
31c74e6
0a2672f
2ec237e
726421a
05ed316
5a4326a
e3e24c2
6945514
d7d6a3f
d548279
5255541
bf68d2f
d5734d5
54b9c25
fd9f63f
74e27ef
e06bc60
b3fc7c4
7ab444b
a712c94
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 |
---|---|---|
|
@@ -115,6 +115,7 @@ class IOUModal extends Component { | |
})); | ||
|
||
this.state = { | ||
previousStepIndex: 0, | ||
currentStepIndex: 0, | ||
participants: participantsWithDetails, | ||
|
||
|
@@ -155,6 +156,20 @@ class IOUModal extends Component { | |
PersonalDetails.fetchCurrencyPreferences(); | ||
} | ||
|
||
/** | ||
* Decides our animation type based on whether we're increasing or decreasing | ||
* our step index. | ||
* @returns {String} | ||
*/ | ||
getAnimation() { | ||
if (this.state.previousStepIndex < this.state.currentStepIndex) { | ||
return 'slideInRight'; | ||
} | ||
if (this.state.previousStepIndex > this.state.currentStepIndex) { | ||
return 'slideInLeft'; | ||
} | ||
} | ||
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. For example, IOUModal should not be responsible for determining the animation. 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. Makes sense! Just to make sure I'm understanding: you think it would be better for the 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. Yep, exactly. Then we won't need to define the |
||
|
||
/** | ||
* Retrieve title for current step, based upon current step and type of IOU | ||
* | ||
|
@@ -214,6 +229,7 @@ class IOUModal extends Component { | |
return; | ||
} | ||
this.setState(prevState => ({ | ||
previousStepIndex: prevState.currentStepIndex, | ||
currentStepIndex: prevState.currentStepIndex - 1, | ||
})); | ||
} | ||
|
@@ -226,6 +242,7 @@ class IOUModal extends Component { | |
return; | ||
} | ||
this.setState(prevState => ({ | ||
previousStepIndex: prevState.currentStepIndex, | ||
currentStepIndex: prevState.currentStepIndex + 1, | ||
})); | ||
} | ||
|
@@ -323,6 +340,7 @@ class IOUModal extends Component { | |
<> | ||
{currentStep === Steps.IOUAmount && ( | ||
<IOUAmountPage | ||
animation={this.getAnimation()} | ||
onStepComplete={(amount) => { | ||
this.setState({amount}); | ||
this.navigateToNextStep(); | ||
|
@@ -337,6 +355,7 @@ class IOUModal extends Component { | |
)} | ||
{currentStep === Steps.IOUParticipants && ( | ||
<IOUParticipantsPage | ||
animation={this.getAnimation()} | ||
participants={this.state.participants} | ||
hasMultipleParticipants={this.props.hasMultipleParticipants} | ||
onAddParticipants={this.addParticipants} | ||
|
@@ -345,6 +364,7 @@ class IOUModal extends Component { | |
)} | ||
{currentStep === Steps.IOUConfirm && ( | ||
<IOUConfirmPage | ||
animation={this.getAnimation()} | ||
onConfirm={this.createTransaction} | ||
hasMultipleParticipants={this.props.hasMultipleParticipants} | ||
participants={this.state.participants} | ||
|
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.
We've manually implemented animations to these 4 files, but this is not easy to maintain or extend. Can you try to simplify this with the use of a new Component/HOC which can be reused by any page without needing to repeat the animation logic?
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.
I'm having a little trouble imagining this, can you help me here?
We're only wrapping the component to be animated in a
Animatable.View
and passing the animation and duration props, if we were to create a new Component/HOC, we would wrap the component in it and, if we wanted the animation and duration to be customizable, pass the same props as we did before.I think I might be missing something
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.
In this case, the props would not be passed. The animation duration and name would be defined once, within this component. It would mean that any other Modal can add the exact same page animations without needing to manually define props each time. But please let me know if I'm missing something that makes this tricky.
Something like this:
The benefits being A) We don't repeat ourselves by declaring the animation duration and type in multiple places B) that we have no dependency on animation logic in either the IOU pages or IOUModal. IOUModal simply declares: I want you to animate in -- keeping components nicely separated and reusable
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.
Ahh, I got it now. Thanks for the explanation!
I'll apply the changes and re-request the review once it's ready.