Unverified Commit ae3f99c9 authored by Grant Slender's avatar Grant Slender Committed by GitHub

implemented TapUp within InkResponse and InkWell (#93833)

* implemented TapUp within InkResponse and InkWell

* Update packages/flutter/lib/src/material/ink_well.dart
Co-authored-by: 's avatarTong Mu <dkwingsmt@users.noreply.github.com>

* Update packages/flutter/lib/src/material/ink_well.dart
Co-authored-by: 's avatarViren Khatri <werainkhatri.work@gmail.com>

* Update packages/flutter/lib/src/material/ink_well.dart
Co-authored-by: 's avatarViren Khatri <werainkhatri.work@gmail.com>
Co-authored-by: 's avatarTong Mu <dkwingsmt@users.noreply.github.com>
Co-authored-by: 's avatarViren Khatri <werainkhatri.work@gmail.com>
parent 3bdea6bb
......@@ -295,6 +295,7 @@ class InkResponse extends StatelessWidget {
this.child,
this.onTap,
this.onTapDown,
this.onTapUp,
this.onTapCancel,
this.onDoubleTap,
this.onLongPress,
......@@ -337,6 +338,10 @@ class InkResponse extends StatelessWidget {
/// Called when the user taps down this part of the material.
final GestureTapDownCallback? onTapDown;
/// Called when the user releases a tap that was started on this part of the
/// material. [onTap] is called immediately after.
final GestureTapUpCallback? onTapUp;
/// Called when the user cancels a tap that was started on this part of the
/// material.
final GestureTapCallback? onTapCancel;
......@@ -583,6 +588,7 @@ class InkResponse extends StatelessWidget {
return _InkResponseStateWidget(
onTap: onTap,
onTapDown: onTapDown,
onTapUp: onTapUp,
onTapCancel: onTapCancel,
onDoubleTap: onDoubleTap,
onLongPress: onLongPress,
......@@ -633,6 +639,7 @@ class _InkResponseStateWidget extends StatefulWidget {
this.child,
this.onTap,
this.onTapDown,
this.onTapUp,
this.onTapCancel,
this.onDoubleTap,
this.onLongPress,
......@@ -669,6 +676,7 @@ class _InkResponseStateWidget extends StatefulWidget {
final Widget? child;
final GestureTapCallback? onTap;
final GestureTapDownCallback? onTapDown;
final GestureTapUpCallback? onTapUp;
final GestureTapCallback? onTapCancel;
final GestureTapCallback? onDoubleTap;
final GestureLongPressCallback? onLongPress;
......@@ -707,6 +715,7 @@ class _InkResponseStateWidget extends StatefulWidget {
if (onDoubleTap != null) 'double tap',
if (onLongPress != null) 'long press',
if (onTapDown != null) 'tap down',
if (onTapUp != null) 'tap up',
if (onTapCancel != null) 'tap cancel',
];
properties.add(IterableProperty<String>('gestures', gestures, ifEmpty: '<none>'));
......@@ -963,6 +972,10 @@ class _InkResponseState extends State<_InkResponseStateWidget>
widget.onTapDown?.call(details);
}
void _handleTapUp(TapUpDetails details) {
widget.onTapUp?.call(details);
}
void _startSplash({TapDownDetails? details, BuildContext? context}) {
assert(details != null || context != null);
......@@ -1106,6 +1119,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
onLongPress: widget.excludeFromSemantics || widget.onLongPress == null ? null : _simulateLongPress,
child: GestureDetector(
onTapDown: enabled ? _handleTapDown : null,
onTapUp: enabled ? _handleTapUp : null,
onTap: enabled ? _handleTap : null,
onTapCancel: enabled ? _handleTapCancel : null,
onDoubleTap: widget.onDoubleTap != null ? _handleDoubleTap : null,
......@@ -1214,6 +1228,7 @@ class InkWell extends InkResponse {
GestureTapCallback? onDoubleTap,
GestureLongPressCallback? onLongPress,
GestureTapDownCallback? onTapDown,
GestureTapUpCallback? onTapUp,
GestureTapCancelCallback? onTapCancel,
ValueChanged<bool>? onHighlightChanged,
ValueChanged<bool>? onHover,
......@@ -1240,6 +1255,7 @@ class InkWell extends InkResponse {
onDoubleTap: onDoubleTap,
onLongPress: onLongPress,
onTapDown: onTapDown,
onTapUp: onTapUp,
onTapCancel: onTapCancel,
onHighlightChanged: onHighlightChanged,
onHover: onHover,
......
......@@ -33,6 +33,9 @@ void main() {
onTapDown: (TapDownDetails details) {
log.add('tap-down');
},
onTapUp: (TapUpDetails details) {
log.add('tap-up');
},
onTapCancel: () {
log.add('tap-cancel');
},
......@@ -47,7 +50,7 @@ void main() {
await tester.pump(const Duration(seconds: 1));
expect(log, equals(<String>['tap-down', 'tap']));
expect(log, equals(<String>['tap-down', 'tap-up', 'tap']));
log.clear();
await tester.tap(find.byType(InkWell), pointer: 2);
......@@ -67,6 +70,7 @@ void main() {
expect(log, equals(<String>['tap-down']));
await gesture.up();
await tester.pump(const Duration(seconds: 1));
expect(log, equals(<String>['tap-down', 'tap-up', 'tap']));
log.clear();
gesture = await tester.startGesture(tester.getRect(find.byType(InkWell)).center);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment