fix(player): 使用根Overlay承载飘心
This commit is contained in:
1 parent
810ca5bf9d
commit
db3e153409
3 files changed
+17
-7
No files matched your search
@@ -38,10 +38,12 @@ const List<_HeartParticle> _hearts = [
|
|||||||
class PlayerDoubleTapHeartBurst extends StatefulWidget {
|
class PlayerDoubleTapHeartBurst extends StatefulWidget {
|
||||||
const PlayerDoubleTapHeartBurst({
|
const PlayerDoubleTapHeartBurst({
|
||||||
super.key,
|
super.key,
|
||||||
|
required this.burstId,
|
||||||
required this.onCompleted,
|
required this.onCompleted,
|
||||||
this.origin = Offset.zero,
|
this.origin = Offset.zero,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final int burstId;
|
||||||
final VoidCallback onCompleted;
|
final VoidCallback onCompleted;
|
||||||
final Offset origin;
|
final Offset origin;
|
||||||
|
|
||||||
@@ -66,7 +68,7 @@ class _PlayerDoubleTapHeartBurstState extends State<PlayerDoubleTapHeartBurst>
|
|||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
debugPrint(
|
debugPrint(
|
||||||
'[player] phase=heart-burst-start '
|
'[player] phase=heart-burst-start '
|
||||||
'id=${identityHashCode(this)} count=${_hearts.length} '
|
'id=${widget.burstId} count=${_hearts.length} '
|
||||||
'configuredMs=$total at=${widget.origin.dx.toStringAsFixed(1)},'
|
'configuredMs=$total at=${widget.origin.dx.toStringAsFixed(1)},'
|
||||||
'${widget.origin.dy.toStringAsFixed(1)}',
|
'${widget.origin.dy.toStringAsFixed(1)}',
|
||||||
);
|
);
|
||||||
@@ -84,7 +86,7 @@ class _PlayerDoubleTapHeartBurstState extends State<PlayerDoubleTapHeartBurst>
|
|||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
debugPrint(
|
debugPrint(
|
||||||
'[player] phase=heart-burst-complete '
|
'[player] phase=heart-burst-complete '
|
||||||
'id=${identityHashCode(this)} '
|
'id=${widget.burstId} '
|
||||||
'configuredMs=${_controller.duration?.inMilliseconds ?? 0}',
|
'configuredMs=${_controller.duration?.inMilliseconds ?? 0}',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -99,7 +101,7 @@ class _PlayerDoubleTapHeartBurstState extends State<PlayerDoubleTapHeartBurst>
|
|||||||
: _lifetime.elapsedMilliseconds;
|
: _lifetime.elapsedMilliseconds;
|
||||||
debugPrint(
|
debugPrint(
|
||||||
'[player] phase=heart-burst-dispose '
|
'[player] phase=heart-burst-dispose '
|
||||||
'id=${identityHashCode(this)} elapsedMs=$elapsedMs '
|
'id=${widget.burstId} elapsedMs=$elapsedMs '
|
||||||
'completed=${_completed ? 1 : 0}',
|
'completed=${_completed ? 1 : 0}',
|
||||||
);
|
);
|
||||||
if (!_completed) {
|
if (!_completed) {
|
||||||
@@ -107,7 +109,7 @@ class _PlayerDoubleTapHeartBurstState extends State<PlayerDoubleTapHeartBurst>
|
|||||||
maxFrames: 30,
|
maxFrames: 30,
|
||||||
label:
|
label:
|
||||||
'[player] heart-burst-premature-dispose '
|
'[player] heart-burst-premature-dispose '
|
||||||
'id=${identityHashCode(this)} mount=tap-gesture-region',
|
'id=${widget.burstId} mount=root-overlay',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,6 +167,7 @@ class _PlayerTapGestureRegionState extends State<PlayerTapGestureRegion> {
|
|||||||
child: IgnorePointer(
|
child: IgnorePointer(
|
||||||
child: PlayerDoubleTapHeartBurst(
|
child: PlayerDoubleTapHeartBurst(
|
||||||
key: ValueKey('heart-overlay-$id'),
|
key: ValueKey('heart-overlay-$id'),
|
||||||
|
burstId: id,
|
||||||
origin: origin,
|
origin: origin,
|
||||||
onCompleted: () => _removeHeartOverlay(id),
|
onCompleted: () => _removeHeartOverlay(id),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ void main() {
|
|||||||
) async {
|
) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const MaterialApp(
|
const MaterialApp(
|
||||||
home: Scaffold(body: PlayerDoubleTapHeartBurst(onCompleted: _noop)),
|
home: Scaffold(
|
||||||
|
body: PlayerDoubleTapHeartBurst(burstId: 1, onCompleted: _noop),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await tester.pump(const Duration(milliseconds: 200));
|
await tester.pump(const Duration(milliseconds: 200));
|
||||||
@@ -42,7 +44,9 @@ void main() {
|
|||||||
) async {
|
) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const MaterialApp(
|
const MaterialApp(
|
||||||
home: Scaffold(body: PlayerDoubleTapHeartBurst(onCompleted: _noop)),
|
home: Scaffold(
|
||||||
|
body: PlayerDoubleTapHeartBurst(burstId: 2, onCompleted: _noop),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -61,7 +65,10 @@ void main() {
|
|||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
body: PlayerDoubleTapHeartBurst(onCompleted: () => completed = true),
|
body: PlayerDoubleTapHeartBurst(
|
||||||
|
burstId: 3,
|
||||||
|
onCompleted: () => completed = true,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user