Animate the user account drawer header arrow#14315
Animate the user account drawer header arrow#14315dudeofawesome wants to merge 77 commits intoflutter:masterfrom
Conversation
| curve: Curves.easeInOut, | ||
| ) | ||
| ..addListener(() { | ||
| setState(() {}); |
There was a problem hiding this comment.
always put a comment inside the block of a setState() if it's otherwise empty, explaining what it is that the build method depends on that has changed
|
|
||
| _controller = new AnimationController( | ||
| value: widget.isOpen ? 1.0 : 0.0, | ||
| duration: const Duration(milliseconds: 200), |
There was a problem hiding this comment.
I picked 200 ms because that's the duration of the account switcher animations in the gallery's drawer example.
| ); | ||
| _animation = new CurvedAnimation( | ||
| parent: _controller, | ||
| curve: Curves.easeInOut, |
There was a problem hiding this comment.
I picked easeInOut because that's what I think the Material guidelines recommend. Should this be a different curve?
There was a problem hiding this comment.
Ah, I see. That's actually Curves.fastOutSlowIn (the name matches Android's name for the same).
|
|
||
| void _onTap() { | ||
| if (widget.isOpen) { | ||
| _controller.reverse(); |
There was a problem hiding this comment.
this doesn't seem right. Consider the case where the user taps the widget, onTap is invoked, and does not change isOpen. Now the arrow will be animating the wrong direction.
I think it would make more sense to trigger the animation during didUpdateWidget based on the new value of isOpen.
See data_table.dart in the material directory, there's a _SortArrow widget there that you may wish to crib from. (It also does other cool things, like always going clockwise unless you change it mid-turn, IIRC.)
|
this will need tests |
|
@Hixie What would you recommend I test? I'm not very familiar with UI testing in Flutter. |
|
@dudeofawesome Anything you don't want us to regress should be tested. Imagine that we have a bot which randomly changes a line of code, then runs the tests, and if the tests pass, it checks the change in. |
| super.didUpdateWidget(oldWidget); | ||
|
|
||
| if (widget.isOpen) { | ||
| _controller.forward(); |
There was a problem hiding this comment.
This will cause the animation to repeatedly restart each time the widget is rebuilt, if the direction didn't change. You probably want to check if the animation is already running, and only start it if it's not running in the right direction. So e.g. in this case you'd want to call forward() if the animation status was dismissed or reverse, and where you call reverse you only want to call it if the status is completed or forward.
|
@dudeofawesome I'm going to close this PR since you're not waiting for review right now, but please don't hesitate to reopen it, or submit a new one, once you are ready for further review. Thanks! If you don't want to work further on this PR that's fine too, I've tagged it so that when we have some free time we can fix whatever remains to be fixed and land it for you. |
|
@Hixie I've been trying to get this updated with the latest version of Flutter, but have been stuck on a an odd pub issue. It won't I've upgraded my system Dart install to the latest ( I've merged in the latest changes from
|
|
Hm, I wonder if what's going on is that your local changes are confusing our version code, and so pub is refusing to give you packages that relate to more recent changes. Can you try |
* Create TabBarTheme of(...) constructor * First round comments * fix imports
|
I'd love to be able to finish this PR up, but I've been unable to get my dev environment set up properly. I'm trying to use the Flutter executable in this repository, which I've forked and then cloned on to my machine at which is clearly a problem given Flutter is at I'm not really sure how to get the bundled version of Flutter updated. I've tried merging in the most recent changes from |
|
@dudeofawesome Awesome! And I've had that exact problem. I've found the best way to resolve it is to get the diff file for the current PR and then use git apply to merge it into the current version of flutter. To get the diff file (if you don't already know), you have to click the "files changed" link at the top of the pr, delete the "/files" and replace it with ".diff". Press enter and you'll get the diff file! (Also, you'll probably need to add a new line to the end of the file you make.) If you then copy that text into a text file, you can use If git apply fails, you'll have to manually copy your changes into a new version of flutter. Let me know if that helps! |
…eofawesome/flutter into feat/user-account-arrow-anim
|
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
|
@jslavitz I ended up trying a rebase (which I've tried before) and it worked this time! I've now got flutter Edit: And apparently that added 83 files to the diff. Not sure exactly what happened there. |
|
@dudeofawesome Great! Though, adding those files isn't good and we won't be able to merge this commit unless it only has the changes from the files you were working on. It would probably make the most sense to strip out your changed file and then merge that into a fresh master. (You also might have to make a new PR because you unfortunately can't un-commit files from a PR :( ). |
|
@dudeofawesome If you're busy right now, I can take this one over! Just wondering if you modified any other files than |
|
@jslavitz I'm a little bit stuck as far as trying to figure out exactly how I should go about writing tests for this. The only user-facing change here is that the arrow now animates. Is there any prior art that you know of as far as testing animations? I've only modified the |
|
@dudeofawesome So the purpose of tests are just to verify that the code you've written works the way you expect it to. So in this case, you probably want to test that:
You'll want to add the tests to the If you want help, feel free to comment or if you want me to take over let me know! Good luck! |
|
@dudeofawesome I'm in charge of getting this PR landed, so I'm going to take this over from here. If you still want to write a test though, we can totally add it to the testing framework, more tests are always better! Thanks so much for your contribution! 😊 |
When the user account drawer header is tapped, the arrow in the bottom right will now rotate instead of just switching to the upward facing arrow.