mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Don't reject the gesture after all pointers are up on AndroidView. (#21295)
This was a bug, when e.g a LongPressGestureRecognizer was in the gesture arena, the android view gesture team may not yet win the arena when the last pointer was up. This change allows AndroidView to win the gesture even after all pointers are up.
This commit is contained in:
parent
abb55cb649
commit
4aaa5dfe31
@ -251,9 +251,7 @@ class _AndroidViewGestureRecognizer extends OneSequenceGestureRecognizer {
|
||||
String get debugDescription => 'Android view';
|
||||
|
||||
@override
|
||||
void didStopTrackingLastPointer(int pointer) {
|
||||
resolve(GestureDisposition.rejected);
|
||||
}
|
||||
void didStopTrackingLastPointer(int pointer) {}
|
||||
|
||||
@override
|
||||
void handleEvent(PointerEvent event) {
|
||||
|
||||
@ -585,6 +585,44 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Android view can claim gesture after all pointers are up', (WidgetTester tester) async {
|
||||
final int currentViewId = platformViewsRegistry.getNextPlatformViewId();
|
||||
final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android);
|
||||
viewsController.registerViewType('webview');
|
||||
bool verticalDragAcceptedByParent = false;
|
||||
// The long press recognizer rejects the gesture after the AndroidView gets the pointer up event.
|
||||
// This test makes sure that the Android view can win the gesture after it got the pointer up event.
|
||||
await tester.pumpWidget(
|
||||
new Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: GestureDetector(
|
||||
onVerticalDragStart: (DragStartDetails d) { verticalDragAcceptedByParent = true; },
|
||||
onLongPress: () {},
|
||||
child: SizedBox(
|
||||
width: 200.0,
|
||||
height: 100.0,
|
||||
child: AndroidView(
|
||||
viewType: 'webview',
|
||||
layoutDirection: TextDirection.ltr,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final TestGesture gesture = await tester.startGesture(const Offset(50.0, 50.0));
|
||||
await gesture.up();
|
||||
|
||||
expect(verticalDragAcceptedByParent, false);
|
||||
expect(
|
||||
viewsController.motionEvents[currentViewId + 1],
|
||||
orderedEquals(<FakeMotionEvent> [
|
||||
const FakeMotionEvent(AndroidViewController.kActionDown, <int> [0], <Offset> [Offset(50.0, 50.0)]),
|
||||
const FakeMotionEvent(AndroidViewController.kActionUp, <int> [0], <Offset> [Offset(50.0, 50.0)]),
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Android view rebuilt during gesture', (WidgetTester tester) async {
|
||||
final int currentViewId = platformViewsRegistry.getNextPlatformViewId();
|
||||
final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user