-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Add an EagerGestureRecognizer. #21407
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
This recognizer can be passed in AndroidView's gesureRecognizers when we want all touch events in the view bounds to be immediately dispatched to the Android view.
| /// | ||
| /// This is typically passed in [AndroidView.gestureRecognizers] in order to immediately dispatch | ||
| /// all touch events inside the view bounds to the embedded Android view. | ||
| class EagerGestureRecognizer extends OneSequenceGestureRecognizer { |
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.
why do you want this to be a OneSequenceGestureRecognizer? it seems like that drags in a bunch of logic you don't need, given how trivial this recognizer is.
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.
Right now AndroidView takes only OneSequenceGestureRecognizers as these are the only ones who currently support gesture teams.
I have a TODO for this (see #20953)
| height: 100.0, | ||
| child: AndroidView( | ||
| viewType: 'webview', | ||
| gestureRecognizers: <OneSequenceGestureRecognizer> [ new EagerGestureRecognizer() ], |
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.
nit: no space 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.
done
| // Normally (without the eager gesture recognizer) after just the pointer down event | ||
| // no gesture arena member will claim the arena (so no motion events will be dispatched to | ||
| // the Android view). Here we assert that with the eager recognizer in the gesture team the | ||
| // pointer down event is immediately dispatched. |
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.
might be worth adding the control test (that we don't dispatch the event if there's no eager thingy)
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 is covered by a test above ('Android view can lose gesture arenas')
| /// A gesture recognizers that eagerly claims victory in all gesture arenas. | ||
| /// | ||
| /// This is typically passed in [AndroidView.gestureRecognizers] in order to immediately dispatch | ||
| /// all touch events inside the view bounds to the embedded Android view. |
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 we should add more documentation here to explain the implications one way or the other, maybe show how it could be used.
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 added some more documentation with examples in AndroidView's getureRecognizers dartdoc, and referred to it from here.
This recognizer can be passed in AndroidView's gesureRecognizers when we
want all touch events in the view bounds to be immediately dispatched
to the Android view.