-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Material Bottom Sheet Reveal/Dismiss animation uses a curved animation #51122
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
Conversation
perclasson
left a comment
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.
Some style nits and comments
rami-a
left a comment
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.
LGTM with a couple comments
|
@guidezpl the analyzer is unhappy about this: |
| final bool enableDrag; | ||
|
|
||
| /// Called when the user begins dragging the bottom sheet vertically. | ||
| final BottomSheetDragStartHandler onDragStart; |
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.
The new callbacks should explain how they'd typically be used and how they relate to the existing onClosing and enableDrag parameters.
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.
Done
| /// straight line, and the top-right quarter will contain the entire contents of | ||
| /// [Curves.easeOut]. | ||
| /// | ||
| /// This is useful in situations where a widget must track the user's finger |
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.
This curve appears to fit a common idiom - linear drag then cuved animated fling - that's not specific to BottomSheet. Rather than defining it as specific to BottomSheet now, and then later as a generic utility with a different name, can we keep the API private for now and then make it public later? We'd have to include a copy of _BottomSheetSuspendedCurve in scaffold.dart for now. Making this public would require adding some usage examples to the docs and maybe retrofitting some existing code to use it (and to prove that it's generally useful).
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 don't mind adding examples and putting it in material/curves.dart. I think this would be cleaner and a future PR could use it in more places that exhibit this kind of behaviour. What do you think?
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 think that expanding on this part of the PR, by adding a track-fling curve and some examples to curves.dart in a future PR, is a good idea. So long as the curve is (the two copies of the curve are) private now.
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.
Sounds good
HansMuller
left a comment
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.
LGTM
Description
Ensures all bottom sheets use non-linear animations for entrance and exits, while still allowing dragging (linearly) bottom sheets. Fixes the animation durations to match the spec.
Before (in slow motion):

After (in slow motion):1

Related Issues
Closes #19469
Future work #51627
Tests
I added the following tests:
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.