Files
pipelines/app/lib/features/chat/workspace/chat_mobile_panes.dart
T
alan 357affe207 Phone chat peek: transcript-only peek, tap-or-scroll, animated switch
The inactive (peek) pane no longer shows the chat's bar: ChatPanePresentation
tells the conversation its role and ChatPaneBarReveal keeps a resting peek's
bar offstage (zero height, not painted), so the peek reads its transcript from
the top. A drag on the peek scrolls that transcript; a tap anywhere on it,
even over a button or link, activates the chat (ChatPeekTapRecognizer accepts
on release ahead of the arena sweep and yields to drags past the slop). The
'chat-peek-<id>' semantics stay a labelled button.

Switching animates (260 ms, Cubic(.2,.8,.2,1)): the tapped chat rises over the
active one with its bottom edge pinned, then the covered chat slides up into
the slot from the bottom edge; each bar fades and slides in or out over the
rise. Content boxes keep their fixed size, so ticks move and clip retained
pictures without laying a transcript out again. Reduced motion jumps. The
old focus stripe is gone.
2026-11-07 01:17:38 +00:00

128 lines
3.9 KiB
Dart

import 'dart:math' as math;
import 'package:flutter/semantics.dart';
import 'package:flutter/widgets.dart';
import '../conversation/chat_pane_presentation.dart';
import 'chat_peek_gesture.dart';
import 'chat_workspace_controller.dart';
/// A phone presentation only: saved split axes and ratios are left untouched.
class ChatMobilePanes {
ChatMobilePanes({
required List<ChatWorkspacePane> panes,
required String activeId,
required String? peekId,
required Size size,
}) {
final active = panes.firstWhere((pane) => pane.id == activeId);
this.activeId = active.id;
final peek =
panes
.where((pane) => pane.id == peekId && pane.id != activeId)
.firstOrNull ??
panes.where((pane) => pane.id != activeId).firstOrNull;
if (peek == null) {
contentHeight = size.height;
rects[active.id] = Offset.zero & size;
return;
}
this.peekId = peek.id;
this.activeId = active.id;
const gap = 6.0;
final available = math.max(0.0, size.height - gap);
final peekHeight = available * .2;
contentHeight = available - peekHeight;
// Selection always promotes the active conversation to the top.
rects[active.id] = Rect.fromLTWH(0, 0, size.width, contentHeight);
rects[peek.id] = Rect.fromLTWH(
0,
contentHeight + gap,
size.width,
peekHeight,
);
}
late final double contentHeight;
final rects = <String, Rect>{};
String? peekId;
String? activeId;
/// [panes] with the active one last: it is drawn over the other during a
/// switch and takes pointers first.
List<ChatWorkspacePane> paintOrder(List<ChatWorkspacePane> panes) => [
for (final pane in panes)
if (pane.id != activeId) pane,
for (final pane in panes)
if (pane.id == activeId) pane,
];
}
/// One retained chat in the phone presentation.
///
/// Both chats keep the same full content box ([contentHeight]), aligned to
/// the pane's top and clipped to it, so a switch moves and clips retained
/// pictures without laying a transcript out again. The peek shows its
/// transcript from the top (its bar steps aside through
/// [ChatPanePresentation]); a drag on it scrolls that transcript and a tap
/// activates the chat. The tree keeps one shape in both roles, so a chat
/// changing role keeps its state.
class ChatMobilePaneViewport extends StatelessWidget {
const ChatMobilePaneViewport({
super.key,
required this.peek,
required this.active,
required this.barReveal,
required this.child,
required this.onActivate,
required this.label,
required this.paneId,
this.contentHeight,
});
final bool peek;
final bool active;
/// The bar's reveal for this pane's role (see [ChatPanePresentation]).
final Animation<double> barReveal;
final Widget child;
final VoidCallback onActivate;
final String label;
final String paneId;
final double? contentHeight;
@override
Widget build(BuildContext context) => ClipRect(
child: Semantics(
key: ValueKey('chat-peek-$paneId'),
identifier: peek ? 'chat-peek-$paneId' : null,
container: peek,
sortKey: peek ? const OrdinalSortKey(1) : null,
label: peek ? 'Expand $label' : null,
button: peek ? true : null,
onTap: peek ? onActivate : null,
child: ChatPeekGesture(
onTap: peek ? onActivate : null,
child: OverflowBox(
alignment: Alignment.topCenter,
minHeight: contentHeight,
maxHeight: contentHeight,
child: SizedBox(
height: contentHeight,
child: ExcludeFocus(
excluding: peek,
child: ExcludeSemantics(
excluding: peek,
child: RepaintBoundary(
child: ChatPanePresentation(
peek: peek,
barReveal: barReveal,
child: child,
),
),
),
),
),
),
),
),
);
}