fix(lyrics): pulse instrumental dots in unison

This commit is contained in:
zarzet
2026-09-26 04:10:00 +07:00
parent 0aaef057cd
commit 5aad892882
2 changed files with 17 additions and 9 deletions
+3 -7
View File
@@ -71,13 +71,9 @@ class _LyricGapIndicatorState extends ConsumerState<LyricGapIndicator>
AnimatedBuilder(
animation: _pulse,
builder: (context, child) {
// Stagger the breath without changing the row's layout or
// letting the pulse advance the playback-driven fill.
final phase = ((_pulse.value - index * 0.12) / 0.76).clamp(
0.0,
1.0,
);
final breath = math.sin(math.pi * phase);
// All three dots breathe together; only their fill advances
// independently with the playback position.
final breath = math.sin(math.pi * _pulse.value);
return Transform.scale(
scale: reduceMotion || widget.position != null
? 1
+14 -2
View File
@@ -1274,8 +1274,17 @@ void main() {
}
final firstDot = find.byKey(const ValueKey('lyric-gap-dot-0'));
double dotWidth() =>
(tester.getBottomRight(firstDot) - tester.getTopLeft(firstDot)).dx;
double dotWidth([int index = 0]) {
final dot = find.byKey(ValueKey('lyric-gap-dot-$index'));
return (tester.getBottomRight(dot) - tester.getTopLeft(dot)).dx;
}
void expectSynchronizedDots() {
for (var index = 1; index < 3; index++) {
expect(dotWidth(index), closeTo(dotWidth(), 0.001));
}
}
final restingWidth = dotWidth();
final restingCenter = tester.getCenter(firstDot);
final rowSize = tester.getSize(find.byType(LyricGapIndicator));
@@ -1284,11 +1293,14 @@ void main() {
final filling = dotAlphas();
final growingWidth = dotWidth();
expect(growingWidth, greaterThan(restingWidth));
expectSynchronizedDots();
await tester.pump(const Duration(milliseconds: 350));
final peakWidth = dotWidth();
expect(peakWidth, greaterThan(growingWidth));
expectSynchronizedDots();
await tester.pump(const Duration(milliseconds: 750));
expect(dotWidth(), lessThan(peakWidth));
expectSynchronizedDots();
expect(tester.getCenter(firstDot), restingCenter);
expect(tester.getSize(find.byType(LyricGapIndicator)), rowSize);
expect(dotAlphas(), filling);