Skip to content

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Aug 4, 2021

Fixes #87322

Wires up the window specific GestureSettings into a dpr transformed DeviceGestureSettings. This can be configured on the base GestureDetector, and then each gesture detector can choose which (if any) configuration it wants to use.

@flutter-dashboard flutter-dashboard bot added a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. labels Aug 4, 2021
@google-cla google-cla bot added the cla: yes label Aug 4, 2021
@jonahwilliams jonahwilliams marked this pull request as ready for review August 6, 2021 16:55
@jonahwilliams jonahwilliams changed the title [WIP] device gestures Use Device specific gesture configuration for scroll views Aug 6, 2021
@jonahwilliams
Copy link
Contributor Author

I don't really want to hit everything at once, but making this optional for the sake of backwards compat - maybe we can migrate to this over time. @goderbauer for thoughts?

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

In every place where null is passed over the real device value a comment would be good explaining why we want the framework fallback rather than the device-provided value.

case PointerDeviceKind.unknown:
case PointerDeviceKind.touch:
return kPanSlop;
return deviceTouchSlop != null ? (2 * deviceTouchSlop) : kPanSlop;
Copy link
Member

Choose a reason for hiding this comment

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

Why 2x?

return deviceTouchSlop != null ? (2 * deviceTouchSlop) : kPanSlop;
}
}

Copy link
Member

Choose a reason for hiding this comment

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

What about the scaleSlop below?

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'm not quite sure what to do with the scale slop right now.

_state = _ForceState.started;
resolve(GestureDisposition.accepted);
} else if (event.delta.distanceSquared > computeHitSlop(event.kind)) {
} else if (event.delta.distanceSquared > computeHitSlop(event.kind, null)) {
Copy link
Member

Choose a reason for hiding this comment

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

Why null over gestureSettings.touchSlop?

@override
MultiDragPointerState createNewPointerState(PointerDownEvent event) {
return _VerticalPointerState(event.position, event.kind);
return _VerticalPointerState(event.position, event.kind, null);
Copy link
Member

Choose a reason for hiding this comment

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

why null?


/// Determine the appropriate hit slop pixels based on the [kind] of pointer.
double computeHitSlop(PointerDeviceKind kind) {
double computeHitSlop(PointerDeviceKind kind, double? deviceTouchSlop) {
Copy link
Member

Choose a reason for hiding this comment

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

should these just take a DeviceGestureSettings obj and the method can pick the appropriate value from it?

event: event,
entry: GestureBinding.instance!.gestureArena.add(event.pointer, this),
doubleTapMinTime: kDoubleTapMinTime,
touchSlop: null,
Copy link
Member

Choose a reason for hiding this comment

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

Why null?

invokeCallback<void>('onSerialTapDown', () => onSerialTapDown!(details));
}
final _TapTracker tracker = _TapTracker(
touchSlop: null,
Copy link
Member

Choose a reason for hiding this comment

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

Why null?

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

final double? touchSlop;

/// The touch slop value for pan gestures, in logical pixels, or `null` if it
/// was not set.
Copy link
Member

Choose a reason for hiding this comment

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

Looks like there is no way to actually set it independently? Maybe document that it's either null or 2* touchSlop if touchSlop is set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do. In the future we could support setting it separately if need be.

this.disableAnimations = false,
this.boldText = false,
this.navigationMode = NavigationMode.traditional,
this.gestureSettings = const DeviceGestureSettings(touchSlop: 16.0)
Copy link
Member

Choose a reason for hiding this comment

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

Can this use kTouchSlop instead of hard-coding 16?

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flutter should use the platform configured touch slop value for Android

3 participants