fix(player): 优化双击飘心轨迹
This commit is contained in:
1 parent
bea50ab32f
commit
94b37ef00f
7 files changed
+89
-16
No files matched your search
@@ -6,6 +6,8 @@ import 'package:fruitshorts/core/data/services/interaction_controller.dart';
|
||||
import 'package:fruitshorts/core/theme/app_theme.dart';
|
||||
import 'package:fruitshorts/l10n/app_localizations.dart';
|
||||
import 'package:fruitshorts/pages/player/widgets/home_feed_overlay.dart';
|
||||
import 'package:fruitshorts/pages/player/widgets/player_double_tap_hearts.dart';
|
||||
import 'package:fruitshorts/pages/player/widgets/player_tap_gesture_region.dart';
|
||||
|
||||
import '../support/fake_catalog.dart';
|
||||
import '../support/fake_haptics.dart';
|
||||
@@ -91,7 +93,7 @@ void main() {
|
||||
await tester.tapAt(center);
|
||||
await tester.pump();
|
||||
expect(repository.likeTargets, hasLength(1));
|
||||
await tester.pump(const Duration(milliseconds: 1600));
|
||||
await tester.pump(const Duration(milliseconds: 2300));
|
||||
|
||||
clock.advance(const Duration(milliseconds: 500));
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
@@ -107,6 +109,40 @@ void main() {
|
||||
expect(key.currentState!.pauseToggles, 0);
|
||||
expect(find.byKey(const Key('double-tap-heart-0')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('parent rebuild keeps the heart burst state alive', (
|
||||
tester,
|
||||
) async {
|
||||
final key = GlobalKey<_HarnessState>();
|
||||
final clock = _TestClock();
|
||||
await _pumpHarness(
|
||||
tester,
|
||||
FakeInteractionRepository(),
|
||||
FakeHaptics(),
|
||||
key,
|
||||
clock,
|
||||
);
|
||||
final center = tester.getCenter(find.byKey(const Key('home-feed-gesture')));
|
||||
|
||||
await tester.tapAt(center);
|
||||
clock.advance(const Duration(milliseconds: 100));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.tapAt(center);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
final gestureFinder = find.byType(PlayerTapGestureRegion);
|
||||
final burstFinder = find.byType(PlayerDoubleTapHeartBurst);
|
||||
final gestureState = tester.state(gestureFinder);
|
||||
final burstState = tester.state(burstFinder);
|
||||
|
||||
key.currentState!.rebuild();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
expect(tester.state(gestureFinder), same(gestureState));
|
||||
expect(tester.state(burstFinder), same(burstState));
|
||||
expect(find.byKey(const Key('double-tap-heart-0')), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _pumpHarness(
|
||||
@@ -155,6 +191,8 @@ class _HarnessState extends State<_Harness> {
|
||||
);
|
||||
int pauseToggles = 0;
|
||||
|
||||
void rebuild() => setState(() {});
|
||||
|
||||
Future<void> _like({bool likeOnly = false}) async {
|
||||
await widget.haptics.lightImpact();
|
||||
final episodeId = demoDramas.first.episodes.first.id;
|
||||
|
||||
@@ -10,7 +10,9 @@ void main() {
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(body: PlayerDoubleTapHeartBurst(onCompleted: _noop)),
|
||||
home: Scaffold(
|
||||
body: PlayerDoubleTapHeartBurst(burstId: 1, onCompleted: _noop),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
@@ -33,10 +35,10 @@ void main() {
|
||||
});
|
||||
|
||||
test('heart burst stays long and sparse', () {
|
||||
expect(PlayerDoubleTapHeartBurst.singleHeartDurationMs, 1300);
|
||||
expect(PlayerDoubleTapHeartBurst.singleHeartDurationMs, 1900);
|
||||
expect(
|
||||
PlayerDoubleTapHeartBurst.animationDuration,
|
||||
greaterThanOrEqualTo(const Duration(milliseconds: 1200)),
|
||||
greaterThanOrEqualTo(const Duration(milliseconds: 1800)),
|
||||
);
|
||||
expect(PlayerDoubleTapHeartBurst.particleCount, lessThanOrEqualTo(4));
|
||||
expect(PlayerDoubleTapHeartBurst.particleCount, 3);
|
||||
|
||||
@@ -699,7 +699,7 @@ void main() {
|
||||
AppColors.doubleTapHeartRed,
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 1600));
|
||||
await tester.pump(const Duration(milliseconds: 2300));
|
||||
expect(find.byKey(const Key('double-tap-heart-0')), findsNothing);
|
||||
expect(logic.session.userWantsPlay, isTrue);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user