perf(player): 优化点击响应与互动反馈

This commit is contained in:
Zhou Weidong committed 2026-11-03 18:28:14 +08:00
1 parent 3ad371aa9d
commit 35cbdd2bd3
4 files changed
+30 -15

No files matched your search

+17 -4
View File
@@ -14,11 +14,13 @@ const _popFrame = Duration(milliseconds: 100);
const _buttonSize = 48.0;
const _compactGap = 6.0;
const _epsilon = 0.01;
const _cancelledMaximum = 0.8;
const _popMinimum = 1.22;
const _cancelledMinimum = 0.8;
const _popMinimum = 1.03;
const _popMaximum = 1.18;
const _burstKey = Key('rail-tap-burst');
const _directionFrame = Duration(milliseconds: 60);
const _directionFrames = 4;
const _directionFrames = 2;
const _motionCompletion = Duration(milliseconds: 230);
Future<void> _pumpRail(
WidgetTester tester, {
@@ -115,7 +117,9 @@ void main() {
await tester.pump(_popFrame);
expect(
_scale(tester, key),
selected ? lessThan(_cancelledMaximum) : greaterThan(_popMinimum),
selected
? allOf(greaterThan(_cancelledMinimum), lessThan(1))
: allOf(greaterThan(_popMinimum), lessThan(_popMaximum)),
);
_expectBurst(tester, key, selected);
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', (
tester,
) async {