-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Add handler for SemanticsAction.scrollToOffset
#159811
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
Add handler for SemanticsAction.scrollToOffset
#159811
Conversation
chunhtai
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
| /// | ||
| /// The callback, if not `null`, should typically set the scroll offset of | ||
| /// the associated scrollable container to the given `targetOffset` without | ||
| /// animation as it is already animated by the caller: the iOS focus engine |
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.
isn't the animation controlled by flutter? how does the caller (I assume iOS) animate the scrollable?
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.
UIKit would create a display link that calls setContentOffset every frame with different scroll offsets. So the animation / curve is determined by UIKIt.
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.
(should I rephrase somehow to make this clear?)
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.
yes, some rephrasing can help
Do we translate all the setContentOffset to scrollToOffset call?
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.
Yeah. Made some minor adjustments to the last sentence.
| _physics = _configuration.getScrollPhysics(context); | ||
| _physics = physicsFromWidget?.applyTo(_physics) ?? _physics; |
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.
nvm
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.
hmm if I apply the suggested change, is _physics going to be up to date for the expression before ??
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.
oh I didn't realize the applyTo uses _physics, in that case no, the suggestion is wrong, the original code is fine
|
|
||
| void _onScrollToOffset(Offset targetOffset) { | ||
| final double offset = switch (axis) { | ||
| Axis.horizontal => targetOffset.dx, |
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.
will there be cases where dx and dy both none zero?
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.
Not currently. In the iOS implementation, every semantics node is only scrollable in one axis I think, so iOS won't issue commands that would scroll both axes. If it does then I think we can't do anything other than just ignoring the unscrollable axis?
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.
oh ok, just want to double check there isn't any surprise.
Also closes #159515
Looking at the google testing failurescl/703169955Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.