From 0f2711e8faccc0816e9e835a1ddb2e275994bfce Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Sat, 7 Nov 2026 19:51:10 +0000 Subject: [PATCH] Reveal full next card behind opaque deck front --- .../chat/workspace/chat_switch_card.dart | 4 ++++ app/lib/ui/motion/quick_switch_effect.dart | 10 +++++----- .../chat/workspace/chat_switch_styles_test.dart | 16 ++++++++++++++++ app/test/ui/motion/quick_switch_effect_test.dart | 11 +++++++++++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/app/lib/features/chat/workspace/chat_switch_card.dart b/app/lib/features/chat/workspace/chat_switch_card.dart index c2549875..25fb3023 100644 --- a/app/lib/features/chat/workspace/chat_switch_card.dart +++ b/app/lib/features/chat/workspace/chat_switch_card.dart @@ -27,6 +27,9 @@ class ChatSwitchCard extends StatelessWidget { final shadow = usesCupertinoHost(context) ? CupertinoColors.black : Theme.of(context).shadowColor; + final surface = usesCupertinoHost(context) + ? CupertinoTheme.of(context).scaffoldBackgroundColor + : Theme.of(context).colorScheme.surface; return LayoutBuilder( builder: (context, constraints) => Opacity( opacity: pose.opacity, @@ -35,6 +38,7 @@ class ChatSwitchCard extends StatelessWidget { transform: pose.transform(constraints.biggest), child: DecoratedBox( decoration: BoxDecoration( + color: motion.isAnimating && !motion.isTape ? surface : null, boxShadow: [ BoxShadow( color: shadow.withValues(alpha: .24 * pose.shadow), diff --git a/app/lib/ui/motion/quick_switch_effect.dart b/app/lib/ui/motion/quick_switch_effect.dart index 288cef5b..c37801f2 100644 --- a/app/lib/ui/motion/quick_switch_effect.dart +++ b/app/lib/ui/motion/quick_switch_effect.dart @@ -65,11 +65,11 @@ Rect quickSwitchRect( final deck = style == QuickSwitchAnimation.cardStack || style == QuickSwitchAnimation.deckSlide; - final travel = deck - ? outgoing - ? ((t - .45) / .55).clamp(0.0, 1.0) - : (t / .8).clamp(0.0, 1.0) - : t; + // The next card is already full-sized behind the opaque front card. + // Sliding the front card aside reveals it instead of exposing empty space + // above a view still travelling up from the small preview. + if (deck && !outgoing) return to; + final travel = deck ? ((t - .45) / .55).clamp(0.0, 1.0) : t; return Rect.lerp(from, to, travel)!; } diff --git a/app/test/features/chat/workspace/chat_switch_styles_test.dart b/app/test/features/chat/workspace/chat_switch_styles_test.dart index 477608ce..f1231499 100644 --- a/app/test/features/chat/workspace/chat_switch_styles_test.dart +++ b/app/test/features/chat/workspace/chat_switch_styles_test.dart @@ -101,6 +101,22 @@ void main() { ) .first, ); + final surfaceColor = + tester + .widget( + find + .descendant( + of: find.byWidgetPredicate( + (w) => w is ChatSwitchCard && w.outgoing, + ), + matching: find.byType(DecoratedBox), + ) + .first, + ) + .decoration + as BoxDecoration; + expect(surfaceColor.color, isNotNull); + expect(surfaceColor.color!.a, 1); expect( card.transform.entry(3, 2) != 0, { diff --git a/app/test/ui/motion/quick_switch_effect_test.dart b/app/test/ui/motion/quick_switch_effect_test.dart index 246574d7..ad118028 100644 --- a/app/test/ui/motion/quick_switch_effect_test.dart +++ b/app/test/ui/motion/quick_switch_effect_test.dart @@ -28,6 +28,17 @@ void main() { } }); + test('deck reveals a full-size next card behind the front card', () { + for (final style in [ + QuickSwitchAnimation.cardStack, + QuickSwitchAnimation.deckSlide, + ]) { + for (final t in [0.0, .3, .5, 1.0]) { + expect(quickSwitchRect(style, t, peek, full, outgoing: false), full); + } + } + }); + test('every style settles without residual transforms or missing cards', () { for (final style in QuickSwitchAnimation.values) { for (final outgoing in [true, false]) {