Reduce quick switch layout churn and flatten planar depth transforms

This commit is contained in:
2026-11-07 19:44:42 +00:00
parent 53a9cc78a3
commit ef0571c562
10 changed files with 284 additions and 17 deletions
@@ -12,10 +12,12 @@ class ChatPanePresentation extends InheritedWidget {
super.key,
required this.peek,
required this.barReveal,
this.fixedChromeLayout = false,
required super.child,
});
final bool peek;
final bool fixedChromeLayout;
final Animation<double> barReveal;
static ChatPanePresentation? maybeOf(BuildContext context) =>
@@ -23,7 +25,9 @@ class ChatPanePresentation extends InheritedWidget {
@override
bool updateShouldNotify(ChatPanePresentation oldWidget) =>
peek != oldWidget.peek || barReveal != oldWidget.barReveal;
peek != oldWidget.peek ||
barReveal != oldWidget.barReveal ||
fixedChromeLayout != oldWidget.fixedChromeLayout;
}
/// The conversation's bar under a [ChatPanePresentation].
@@ -60,7 +64,9 @@ class ChatPaneBarReveal extends StatelessWidget {
ignoring: peek,
child: SizeTransition(
alignment: Alignment.topCenter,
sizeFactor: reveal,
sizeFactor: presentation.fixedChromeLayout
? const AlwaysStoppedAnimation(1.0)
: reveal,
child: FadeTransition(
opacity: reveal,
child: SlideTransition(
@@ -67,6 +67,7 @@ class ChatMobilePaneViewport extends StatelessWidget {
required this.peek,
required this.active,
required this.barReveal,
this.fixedChromeLayout = false,
required this.child,
required this.onActivate,
required this.label,
@@ -75,6 +76,7 @@ class ChatMobilePaneViewport extends StatelessWidget {
final bool peek;
final bool active;
final bool fixedChromeLayout;
/// The bar's reveal for this pane's role (see [ChatPanePresentation]).
final Animation<double> barReveal;
@@ -103,6 +105,7 @@ class ChatMobilePaneViewport extends StatelessWidget {
child: ChatPanePresentation(
peek: peek,
barReveal: barReveal,
fixedChromeLayout: fixedChromeLayout,
child: child,
),
),
@@ -0,0 +1,30 @@
import 'package:flutter/widgets.dart';
/// Keeps the expensive transcript layout at one useful size while its card's
/// painted rectangle moves. Resting peek constraints remain the real viewport.
class ChatMotionViewport extends StatelessWidget {
const ChatMotionViewport({
super.key,
required this.size,
required this.child,
});
final Size? size;
final Widget child;
@override
Widget build(BuildContext context) => LayoutBuilder(
builder: (context, constraints) {
final viewport = size ?? constraints.biggest;
return ClipRect(
child: OverflowBox(
alignment: Alignment.topLeft,
minWidth: viewport.width,
maxWidth: viewport.width,
minHeight: viewport.height,
maxHeight: viewport.height,
child: child,
),
);
},
);
}
@@ -259,6 +259,7 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
peek: peek,
active: active,
barReveal: _motion.revealFor(pane.id),
fixedChromeLayout: _motion.isAnimating && !_motion.isTape,
label: widget.paneTitle?.call(pane) ?? pane.sessionId,
paneId: pane.id,
onActivate: () {
@@ -7,6 +7,7 @@ import 'chat_pane_backdrop.dart';
import 'chat_pane_switch_motion.dart';
import 'chat_tape_exit.dart';
import 'chat_switch_card.dart';
import 'chat_motion_viewport.dart';
import 'chat_workspace_controller.dart';
import 'chat_workspace_divider.dart';
import 'chat_workspace_geometry.dart';
@@ -87,7 +88,12 @@ Widget chatWorkspaceSurface({
child: ChatSwitchCard(
motion: motion,
outgoing: motion.isRetainedOutgoing(pane.id),
child: child!,
child: ChatMotionViewport(
size: mobile != null && motion.isAnimating && !motion.isTape
? motion.viewportRectFor(pane.id)?.size
: null,
child: child!,
),
),
),
),