Snap CupertinoSliverNavigationBar large title and bottom widget#156381
Snap CupertinoSliverNavigationBar large title and bottom widget#156381auto-submit[bot] merged 22 commits intoflutter:masterfrom
Conversation
MitchellGoodwin
left a comment
There was a problem hiding this comment.
Was ScrollEndNotification unable to be used for this? Just following up on this comment: #126028 (comment)
| : 0.0, | ||
| // Eyeballed on an iPhone 16 simulator running iOS 18. | ||
| duration: const Duration(milliseconds: 100), | ||
| curve: Curves.easeOut, |
There was a problem hiding this comment.
To my eye, the animation isn't snappy enough. I wonder if the curve should have a faster start. On iOS it might be a spring animation.
There was a problem hiding this comment.
Yeah, tbh I don't know what animation curve or values are used. The native one seems more snappy, but not too fast at the same time. If only there was a way to get these values...
There was a problem hiding this comment.
Maybe Curves.easeOutExpo? That one seems to start off faster. There is a helpful video with graphs and sample animation for every curve at https://api.flutter.dev/flutter/animation/Curves-class.html
There was a problem hiding this comment.
I have a strong suspicion that it's a spring animation. That's what iOS uses for releasing a partially dragged page transition. There is a way to check with Xcode debugging, but I do not remember off the top of my head. @dkwingsmt was working with using the spring simulation for an animation: #155575
But my opinion for this PR is it's fine to use a curve we already have for now, but one that's closer. fastEaseInToSlowEaseOut is what the Cupertino routes use.
There was a problem hiding this comment.
easeOutExpo started a little bit too fast, but fastEaseInToSlowEaseOut was closer-ish. It's not perfect but definitely better.
I was having difficulty making scroll notifications and scroll position play well together. I added a listener to be called on I agree that responding to |
| : 0.0, | ||
| // Eyeballed on an iPhone 16 simulator running iOS 18. | ||
| duration: const Duration(milliseconds: 100), | ||
| curve: Curves.easeOut, |
There was a problem hiding this comment.
Maybe Curves.easeOutExpo? That one seems to start off faster. There is a helpful video with graphs and sample animation for every curve at https://api.flutter.dev/flutter/animation/Curves-class.html
| @override | ||
| void didChangeDependencies() { | ||
| super.didChangeDependencies(); | ||
| _scrollableState?.position.isScrollingNotifier.removeListener(_handleScrollChange); |
There was a problem hiding this comment.
Using the isScrollingNotifier makes sense to me. It will only notify when scrolling starts and stops, which is exactly what is needed here. 👍 Using scroll notifications would mean a lot of notifications we would not need.
|
Converting to draft... Since the bottom to nav bar PR has been merged, I'm working to make it snap for both the search bar and the large title. |
|
Snapping only the large title causes problems in |
MitchellGoodwin
left a comment
There was a problem hiding this comment.
Renewing my LGTM with some nits.
| } | ||
|
|
||
| if (target != null) { | ||
| position.animateTo( |
There was a problem hiding this comment.
Using 'animateTo' can be very risky as it breaks the entire scrollable widget if one attempts to scroll within the 300ms timeframe (refer to issue #14452). This issue is easily reproducible by increasing the animation duration and trying to scroll the CustomScrollView during that period. Subsequently, assertions fail, such as '_hold == null || _drag == null'.
Fixes CupertinoSliverNavigationBar should snap between large and middle title
Fixes CupertinoSliverNavigationBar needs to implement snapping
Flutter (with this PR):
Screen.Recording.2024-10-16.at.4.26.18.PM.mov
Native:
Screen.Recording.2024-10-16.at.4.28.17.PM.mov
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.