mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
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: Tong Mu <dkwingsmt@users.noreply.github.com> * Update packages/flutter/lib/src/material/ink_well.dart Co-authored-by: Viren Khatri <werainkhatri.work@gmail.com> * Update packages/flutter/lib/src/material/ink_well.dart Co-authored-by: Viren Khatri <werainkhatri.work@gmail.com> Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com> Co-authored-by: Viren Khatri <werainkhatri.work@gmail.com>
This commit is contained in:
parent
3bdea6bb92
commit
ae3f99c98a
@ -295,6 +295,7 @@ class InkResponse extends StatelessWidget {
|
|||||||
this.child,
|
this.child,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
this.onTapDown,
|
this.onTapDown,
|
||||||
|
this.onTapUp,
|
||||||
this.onTapCancel,
|
this.onTapCancel,
|
||||||
this.onDoubleTap,
|
this.onDoubleTap,
|
||||||
this.onLongPress,
|
this.onLongPress,
|
||||||
@ -337,6 +338,10 @@ class InkResponse extends StatelessWidget {
|
|||||||
/// Called when the user taps down this part of the material.
|
/// Called when the user taps down this part of the material.
|
||||||
final GestureTapDownCallback? onTapDown;
|
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
|
/// Called when the user cancels a tap that was started on this part of the
|
||||||
/// material.
|
/// material.
|
||||||
final GestureTapCallback? onTapCancel;
|
final GestureTapCallback? onTapCancel;
|
||||||
@ -583,6 +588,7 @@ class InkResponse extends StatelessWidget {
|
|||||||
return _InkResponseStateWidget(
|
return _InkResponseStateWidget(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
onTapDown: onTapDown,
|
onTapDown: onTapDown,
|
||||||
|
onTapUp: onTapUp,
|
||||||
onTapCancel: onTapCancel,
|
onTapCancel: onTapCancel,
|
||||||
onDoubleTap: onDoubleTap,
|
onDoubleTap: onDoubleTap,
|
||||||
onLongPress: onLongPress,
|
onLongPress: onLongPress,
|
||||||
@ -633,6 +639,7 @@ class _InkResponseStateWidget extends StatefulWidget {
|
|||||||
this.child,
|
this.child,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
this.onTapDown,
|
this.onTapDown,
|
||||||
|
this.onTapUp,
|
||||||
this.onTapCancel,
|
this.onTapCancel,
|
||||||
this.onDoubleTap,
|
this.onDoubleTap,
|
||||||
this.onLongPress,
|
this.onLongPress,
|
||||||
@ -669,6 +676,7 @@ class _InkResponseStateWidget extends StatefulWidget {
|
|||||||
final Widget? child;
|
final Widget? child;
|
||||||
final GestureTapCallback? onTap;
|
final GestureTapCallback? onTap;
|
||||||
final GestureTapDownCallback? onTapDown;
|
final GestureTapDownCallback? onTapDown;
|
||||||
|
final GestureTapUpCallback? onTapUp;
|
||||||
final GestureTapCallback? onTapCancel;
|
final GestureTapCallback? onTapCancel;
|
||||||
final GestureTapCallback? onDoubleTap;
|
final GestureTapCallback? onDoubleTap;
|
||||||
final GestureLongPressCallback? onLongPress;
|
final GestureLongPressCallback? onLongPress;
|
||||||
@ -707,6 +715,7 @@ class _InkResponseStateWidget extends StatefulWidget {
|
|||||||
if (onDoubleTap != null) 'double tap',
|
if (onDoubleTap != null) 'double tap',
|
||||||
if (onLongPress != null) 'long press',
|
if (onLongPress != null) 'long press',
|
||||||
if (onTapDown != null) 'tap down',
|
if (onTapDown != null) 'tap down',
|
||||||
|
if (onTapUp != null) 'tap up',
|
||||||
if (onTapCancel != null) 'tap cancel',
|
if (onTapCancel != null) 'tap cancel',
|
||||||
];
|
];
|
||||||
properties.add(IterableProperty<String>('gestures', gestures, ifEmpty: '<none>'));
|
properties.add(IterableProperty<String>('gestures', gestures, ifEmpty: '<none>'));
|
||||||
@ -963,6 +972,10 @@ class _InkResponseState extends State<_InkResponseStateWidget>
|
|||||||
widget.onTapDown?.call(details);
|
widget.onTapDown?.call(details);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _handleTapUp(TapUpDetails details) {
|
||||||
|
widget.onTapUp?.call(details);
|
||||||
|
}
|
||||||
|
|
||||||
void _startSplash({TapDownDetails? details, BuildContext? context}) {
|
void _startSplash({TapDownDetails? details, BuildContext? context}) {
|
||||||
assert(details != null || context != null);
|
assert(details != null || context != null);
|
||||||
|
|
||||||
@ -1106,6 +1119,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
|
|||||||
onLongPress: widget.excludeFromSemantics || widget.onLongPress == null ? null : _simulateLongPress,
|
onLongPress: widget.excludeFromSemantics || widget.onLongPress == null ? null : _simulateLongPress,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTapDown: enabled ? _handleTapDown : null,
|
onTapDown: enabled ? _handleTapDown : null,
|
||||||
|
onTapUp: enabled ? _handleTapUp : null,
|
||||||
onTap: enabled ? _handleTap : null,
|
onTap: enabled ? _handleTap : null,
|
||||||
onTapCancel: enabled ? _handleTapCancel : null,
|
onTapCancel: enabled ? _handleTapCancel : null,
|
||||||
onDoubleTap: widget.onDoubleTap != null ? _handleDoubleTap : null,
|
onDoubleTap: widget.onDoubleTap != null ? _handleDoubleTap : null,
|
||||||
@ -1214,6 +1228,7 @@ class InkWell extends InkResponse {
|
|||||||
GestureTapCallback? onDoubleTap,
|
GestureTapCallback? onDoubleTap,
|
||||||
GestureLongPressCallback? onLongPress,
|
GestureLongPressCallback? onLongPress,
|
||||||
GestureTapDownCallback? onTapDown,
|
GestureTapDownCallback? onTapDown,
|
||||||
|
GestureTapUpCallback? onTapUp,
|
||||||
GestureTapCancelCallback? onTapCancel,
|
GestureTapCancelCallback? onTapCancel,
|
||||||
ValueChanged<bool>? onHighlightChanged,
|
ValueChanged<bool>? onHighlightChanged,
|
||||||
ValueChanged<bool>? onHover,
|
ValueChanged<bool>? onHover,
|
||||||
@ -1240,6 +1255,7 @@ class InkWell extends InkResponse {
|
|||||||
onDoubleTap: onDoubleTap,
|
onDoubleTap: onDoubleTap,
|
||||||
onLongPress: onLongPress,
|
onLongPress: onLongPress,
|
||||||
onTapDown: onTapDown,
|
onTapDown: onTapDown,
|
||||||
|
onTapUp: onTapUp,
|
||||||
onTapCancel: onTapCancel,
|
onTapCancel: onTapCancel,
|
||||||
onHighlightChanged: onHighlightChanged,
|
onHighlightChanged: onHighlightChanged,
|
||||||
onHover: onHover,
|
onHover: onHover,
|
||||||
|
@ -33,6 +33,9 @@ void main() {
|
|||||||
onTapDown: (TapDownDetails details) {
|
onTapDown: (TapDownDetails details) {
|
||||||
log.add('tap-down');
|
log.add('tap-down');
|
||||||
},
|
},
|
||||||
|
onTapUp: (TapUpDetails details) {
|
||||||
|
log.add('tap-up');
|
||||||
|
},
|
||||||
onTapCancel: () {
|
onTapCancel: () {
|
||||||
log.add('tap-cancel');
|
log.add('tap-cancel');
|
||||||
},
|
},
|
||||||
@ -47,7 +50,7 @@ void main() {
|
|||||||
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
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();
|
log.clear();
|
||||||
|
|
||||||
await tester.tap(find.byType(InkWell), pointer: 2);
|
await tester.tap(find.byType(InkWell), pointer: 2);
|
||||||
@ -67,6 +70,7 @@ void main() {
|
|||||||
expect(log, equals(<String>['tap-down']));
|
expect(log, equals(<String>['tap-down']));
|
||||||
await gesture.up();
|
await gesture.up();
|
||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
expect(log, equals(<String>['tap-down', 'tap-up', 'tap']));
|
||||||
|
|
||||||
log.clear();
|
log.clear();
|
||||||
gesture = await tester.startGesture(tester.getRect(find.byType(InkWell)).center);
|
gesture = await tester.startGesture(tester.getRect(find.byType(InkWell)).center);
|
||||||
|
Loading…
Reference in New Issue
Block a user