Skip to content

Conversation

@amirh
Copy link
Contributor

@amirh amirh commented Sep 4, 2018

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 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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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() ],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no space before [

Copy link
Contributor Author

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.
Copy link
Contributor

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)

Copy link
Contributor Author

@amirh amirh Sep 5, 2018

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.
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@Hixie
Copy link
Contributor

Hixie commented Sep 5, 2018

LGTM

@amirh amirh merged commit 9506d1e into flutter:master Sep 6, 2018
@amirh amirh deleted the eager_recognizer branch September 6, 2018 18:18
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants