commit
f3cfd0d0ec
4 files changed
+30
-15
No files matched your search
@@ -12,9 +12,9 @@ const double _defaultIconSize = 32;
|
|||||||
const double _defaultCountFont = 12;
|
const double _defaultCountFont = 12;
|
||||||
const double _defaultIconCountGap = 2;
|
const double _defaultIconCountGap = 2;
|
||||||
const double _defaultItemGap = 24;
|
const double _defaultItemGap = 24;
|
||||||
const _tapDuration = Duration(milliseconds: 360);
|
const _tapDuration = Duration(milliseconds: 220);
|
||||||
const double _popScale = 1.34;
|
const double _popScale = 1.14;
|
||||||
const double _cancelScale = 0.68;
|
const double _cancelScale = 0.86;
|
||||||
const double _popWeight = 40;
|
const double _popWeight = 40;
|
||||||
const double _settleWeight = 60;
|
const double _settleWeight = 60;
|
||||||
final _growTween = _tapTween(_popScale);
|
final _growTween = _tapTween(_popScale);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class PlayerTapGestureRegion extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PlayerTapGestureRegionState extends State<PlayerTapGestureRegion> {
|
class _PlayerTapGestureRegionState extends State<PlayerTapGestureRegion> {
|
||||||
static const Duration _singleTapDelay = Duration(milliseconds: 320);
|
static const Duration _singleTapDelay = Duration(milliseconds: 240);
|
||||||
|
|
||||||
Timer? _singleTapTimer;
|
Timer? _singleTapTimer;
|
||||||
DateTime? _lastDownAt;
|
DateTime? _lastDownAt;
|
||||||
|
|||||||
@@ -16,8 +16,10 @@ import '../support/fake_haptics.dart';
|
|||||||
import '../support/fake_interaction_repositories.dart';
|
import '../support/fake_interaction_repositories.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('double tap within 320ms never pauses', (tester) async {
|
testWidgets('should_like_without_pausing_when_double_tap_within_240ms', (
|
||||||
for (final delay in [120, 250, 300]) {
|
tester,
|
||||||
|
) async {
|
||||||
|
for (final delay in [80, 160, 220]) {
|
||||||
final repository = FakeInteractionRepository();
|
final repository = FakeInteractionRepository();
|
||||||
final haptics = FakeHaptics();
|
final haptics = FakeHaptics();
|
||||||
final key = GlobalKey<_HarnessState>();
|
final key = GlobalKey<_HarnessState>();
|
||||||
@@ -53,7 +55,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('taps 500ms apart toggle playback twice', (tester) async {
|
testWidgets('should_toggle_twice_when_taps_are_260ms_apart', (tester) async {
|
||||||
final key = GlobalKey<_HarnessState>();
|
final key = GlobalKey<_HarnessState>();
|
||||||
final clock = _TestClock();
|
final clock = _TestClock();
|
||||||
await _pumpHarness(
|
await _pumpHarness(
|
||||||
@@ -67,15 +69,15 @@ void main() {
|
|||||||
await tester.tapAt(
|
await tester.tapAt(
|
||||||
tester.getCenter(find.byKey(const Key('home-feed-gesture'))),
|
tester.getCenter(find.byKey(const Key('home-feed-gesture'))),
|
||||||
);
|
);
|
||||||
clock.advance(const Duration(milliseconds: 500));
|
clock.advance(const Duration(milliseconds: 260));
|
||||||
await tester.pump(const Duration(milliseconds: 500));
|
await tester.pump(const Duration(milliseconds: 260));
|
||||||
expect(key.currentState!.pauseToggles, 1);
|
expect(key.currentState!.pauseToggles, 1);
|
||||||
|
|
||||||
await tester.tapAt(
|
await tester.tapAt(
|
||||||
tester.getCenter(find.byKey(const Key('home-feed-gesture'))),
|
tester.getCenter(find.byKey(const Key('home-feed-gesture'))),
|
||||||
);
|
);
|
||||||
clock.advance(const Duration(milliseconds: 500));
|
clock.advance(const Duration(milliseconds: 260));
|
||||||
await tester.pump(const Duration(milliseconds: 500));
|
await tester.pump(const Duration(milliseconds: 260));
|
||||||
expect(key.currentState!.pauseToggles, 2);
|
expect(key.currentState!.pauseToggles, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -14,11 +14,13 @@ const _popFrame = Duration(milliseconds: 100);
|
|||||||
const _buttonSize = 48.0;
|
const _buttonSize = 48.0;
|
||||||
const _compactGap = 6.0;
|
const _compactGap = 6.0;
|
||||||
const _epsilon = 0.01;
|
const _epsilon = 0.01;
|
||||||
const _cancelledMaximum = 0.8;
|
const _cancelledMinimum = 0.8;
|
||||||
const _popMinimum = 1.22;
|
const _popMinimum = 1.03;
|
||||||
|
const _popMaximum = 1.18;
|
||||||
const _burstKey = Key('rail-tap-burst');
|
const _burstKey = Key('rail-tap-burst');
|
||||||
const _directionFrame = Duration(milliseconds: 60);
|
const _directionFrame = Duration(milliseconds: 60);
|
||||||
const _directionFrames = 4;
|
const _directionFrames = 2;
|
||||||
|
const _motionCompletion = Duration(milliseconds: 230);
|
||||||
|
|
||||||
Future<void> _pumpRail(
|
Future<void> _pumpRail(
|
||||||
WidgetTester tester, {
|
WidgetTester tester, {
|
||||||
@@ -115,7 +117,9 @@ void main() {
|
|||||||
await tester.pump(_popFrame);
|
await tester.pump(_popFrame);
|
||||||
expect(
|
expect(
|
||||||
_scale(tester, key),
|
_scale(tester, key),
|
||||||
selected ? lessThan(_cancelledMaximum) : greaterThan(_popMinimum),
|
selected
|
||||||
|
? allOf(greaterThan(_cancelledMinimum), lessThan(1))
|
||||||
|
: allOf(greaterThan(_popMinimum), lessThan(_popMaximum)),
|
||||||
);
|
);
|
||||||
_expectBurst(tester, key, selected);
|
_expectBurst(tester, key, selected);
|
||||||
expect(tester.getRect(_button(key)), rect);
|
expect(tester.getRect(_button(key)), rect);
|
||||||
@@ -155,6 +159,15 @@ void main() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
testWidgets('should_finish_feedback_within_230ms', (tester) async {
|
||||||
|
await _pumpRail(tester, onTap: () {});
|
||||||
|
await tester.tap(_button(_likeKey));
|
||||||
|
await tester.pump();
|
||||||
|
await tester.pump(_motionCompletion);
|
||||||
|
expect(find.byKey(_burstKey), findsNothing);
|
||||||
|
expect(_scale(tester, _likeKey), closeTo(1, _epsilon));
|
||||||
|
});
|
||||||
|
|
||||||
testWidgets('should_keep_callbacks_without_motion_when_reduced', (
|
testWidgets('should_keep_callbacks_without_motion_when_reduced', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
|
|||||||
Reference in new issue
Block a user