iOS 13 scrollbar vibration (#37724)
Vibrate when starting scrollbar dragging.
This commit is contained in:
parent
f0354b82e6
commit
361730ed72
@ -5,6 +5,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
// All values eyeballed.
|
// All values eyeballed.
|
||||||
@ -207,6 +208,7 @@ class _CupertinoScrollbarState extends State<CupertinoScrollbar> with TickerProv
|
|||||||
_assertVertical();
|
_assertVertical();
|
||||||
_fadeoutTimer?.cancel();
|
_fadeoutTimer?.cancel();
|
||||||
_fadeoutAnimationController.forward();
|
_fadeoutAnimationController.forward();
|
||||||
|
HapticFeedback.mediumImpact();
|
||||||
_dragScrollbar(details.localPosition.dy);
|
_dragScrollbar(details.localPosition.dy);
|
||||||
_dragScrollbarPositionY = details.localPosition.dy;
|
_dragScrollbarPositionY = details.localPosition.dy;
|
||||||
}
|
}
|
||||||
@ -234,6 +236,7 @@ class _CupertinoScrollbarState extends State<CupertinoScrollbar> with TickerProv
|
|||||||
_assertVertical();
|
_assertVertical();
|
||||||
_fadeoutTimer?.cancel();
|
_fadeoutTimer?.cancel();
|
||||||
_thicknessAnimationController.forward();
|
_thicknessAnimationController.forward();
|
||||||
|
HapticFeedback.mediumImpact();
|
||||||
_dragScrollbar(details.localPosition.dy);
|
_dragScrollbar(details.localPosition.dy);
|
||||||
_dragScrollbarPositionY = details.localPosition.dy;
|
_dragScrollbarPositionY = details.localPosition.dy;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
import '../rendering/mock_canvas.dart';
|
import '../rendering/mock_canvas.dart';
|
||||||
@ -86,9 +87,18 @@ void main() {
|
|||||||
await scrollGesture.up();
|
await scrollGesture.up();
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
// Longpress on the scrollbar thumb.
|
int hapticFeedbackCalls = 0;
|
||||||
|
SystemChannels.platform.setMockMethodCallHandler((MethodCall methodCall) async {
|
||||||
|
if (methodCall.method == 'HapticFeedback.vibrate') {
|
||||||
|
hapticFeedbackCalls++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Longpress on the scrollbar thumb and expect a vibration.
|
||||||
|
expect(hapticFeedbackCalls, 0);
|
||||||
final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(796.0, 50.0));
|
final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(796.0, 50.0));
|
||||||
await tester.pump(const Duration(milliseconds: 500));
|
await tester.pump(const Duration(milliseconds: 500));
|
||||||
|
expect(hapticFeedbackCalls, 1);
|
||||||
|
|
||||||
// Drag the thumb down to scroll down.
|
// Drag the thumb down to scroll down.
|
||||||
await dragScrollbarGesture.moveBy(const Offset(0.0, scrollAmount));
|
await dragScrollbarGesture.moveBy(const Offset(0.0, scrollAmount));
|
||||||
@ -145,11 +155,21 @@ void main() {
|
|||||||
await scrollGesture.up();
|
await scrollGesture.up();
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
// Drag in from the right side on top of the scrollbar thumb.
|
int hapticFeedbackCalls = 0;
|
||||||
|
SystemChannels.platform.setMockMethodCallHandler((MethodCall methodCall) async {
|
||||||
|
if (methodCall.method == 'HapticFeedback.vibrate') {
|
||||||
|
hapticFeedbackCalls++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Drag in from the right side on top of the scrollbar thumb and expect a
|
||||||
|
// vibration.
|
||||||
|
expect(hapticFeedbackCalls, 0);
|
||||||
final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(796.0, 50.0));
|
final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(796.0, 50.0));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
await dragScrollbarGesture.moveBy(const Offset(-50.0, 0.0));
|
await dragScrollbarGesture.moveBy(const Offset(-50.0, 0.0));
|
||||||
await tester.pump(_kScrollbarResizeDuration);
|
await tester.pump(_kScrollbarResizeDuration);
|
||||||
|
expect(hapticFeedbackCalls, 1);
|
||||||
|
|
||||||
// Drag the thumb down to scroll down.
|
// Drag the thumb down to scroll down.
|
||||||
await dragScrollbarGesture.moveBy(const Offset(0.0, scrollAmount));
|
await dragScrollbarGesture.moveBy(const Offset(0.0, scrollAmount));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user