Add opposing arc swap animation for chat quick switch

This commit is contained in:
2026-11-08 01:00:08 +00:00
parent 2fe08226f2
commit d6006bb1f8
6 changed files with 147 additions and 47 deletions
@@ -39,6 +39,50 @@ void main() {
}
});
test(
'arc swap bows to opposite sides while both cards travel vertically',
() {
const style = QuickSwitchAnimation.arcSwap;
for (final t in [.25, .5, .75]) {
final outgoing = quickSwitchPose(style, t, outgoing: true);
final incoming = quickSwitchPose(style, t, outgoing: false);
expect(outgoing.translation.dx, lessThan(0));
expect(incoming.translation.dx, greaterThan(0));
expect(
outgoing.translation.dx,
closeTo(-incoming.translation.dx, 1e-9),
);
expect(outgoing.rotationX, 0);
expect(outgoing.rotationY, 0);
expect(outgoing.transform(full.size).entry(3, 2), 0);
expect(outgoing.opacity, 1);
expect(incoming.opacity, 1);
expect(
quickSwitchRect(style, t, full, peek, outgoing: true),
Rect.lerp(full, peek, t),
);
expect(
quickSwitchRect(style, t, peek, full, outgoing: false),
Rect.lerp(peek, full, t),
);
}
final quarter = quickSwitchPose(
style,
.25,
outgoing: false,
).translation.dx;
final middle = quickSwitchPose(style, .5, outgoing: false).translation.dx;
final threeQuarter = quickSwitchPose(
style,
.75,
outgoing: false,
).translation.dx;
expect(quarter, closeTo(threeQuarter, 1e-9));
expect(middle, greaterThan(quarter));
expect(middle, closeTo(.38, 1e-9));
},
);
test('every style settles without residual transforms or missing cards', () {
for (final style in QuickSwitchAnimation.values) {
for (final outgoing in [true, false]) {