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.
This commit is contained in:
@@ -7,6 +7,7 @@ import 'chat_workspace_controller.dart';
|
||||
import 'chat_workspace_divider.dart';
|
||||
import 'chat_workspace_geometry.dart';
|
||||
import 'chat_mobile_panes.dart';
|
||||
import 'chat_pane_switch_motion.dart';
|
||||
|
||||
export 'chat_workspace_controller.dart';
|
||||
export 'chat_workspace_geometry.dart' show ChatPaneDirection;
|
||||
@@ -44,9 +45,11 @@ class ChatWorkspace extends StatefulWidget {
|
||||
State<ChatWorkspace> createState() => _ChatWorkspaceState();
|
||||
}
|
||||
|
||||
class _ChatWorkspaceState extends State<ChatWorkspace> {
|
||||
class _ChatWorkspaceState extends State<ChatWorkspace>
|
||||
with SingleTickerProviderStateMixin {
|
||||
final _focus = FocusNode(debugLabel: 'Chat workspace');
|
||||
final Map<String, FocusScopeNode> _panes = {};
|
||||
late final ChatPaneSwitchMotion _motion;
|
||||
ChatWorkspaceGeometry? _geometry;
|
||||
String? _lastActiveId;
|
||||
String? _peekId;
|
||||
@@ -54,6 +57,7 @@ class _ChatWorkspaceState extends State<ChatWorkspace> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_motion = ChatPaneSwitchMotion(vsync: this);
|
||||
HardwareKeyboard.instance.addHandler(_key);
|
||||
}
|
||||
|
||||
@@ -103,6 +107,7 @@ class _ChatWorkspaceState extends State<ChatWorkspace> {
|
||||
@override
|
||||
void dispose() {
|
||||
HardwareKeyboard.instance.removeHandler(_key);
|
||||
_motion.dispose();
|
||||
_focus.dispose();
|
||||
for (final node in _panes.values) {
|
||||
node.dispose();
|
||||
@@ -124,7 +129,8 @@ class _ChatWorkspaceState extends State<ChatWorkspace> {
|
||||
final collapsed = widget.singlePane || geometry.collapsed;
|
||||
final panes = widget.controller.panes;
|
||||
final activeId = widget.controller.activePaneId;
|
||||
if (_lastActiveId != activeId) {
|
||||
final switching = _lastActiveId != activeId;
|
||||
if (switching) {
|
||||
_peekId = _lastActiveId;
|
||||
_lastActiveId = activeId;
|
||||
}
|
||||
@@ -136,76 +142,42 @@ class _ChatWorkspaceState extends State<ChatWorkspace> {
|
||||
size: constraints.biggest,
|
||||
)
|
||||
: null;
|
||||
if (mobile == null) {
|
||||
_motion.rest();
|
||||
} else {
|
||||
_motion.layout(
|
||||
rects: mobile.rects,
|
||||
size: constraints.biggest,
|
||||
activeId: activeId!,
|
||||
switching: switching,
|
||||
animate: !MediaQuery.disableAnimationsOf(context),
|
||||
);
|
||||
}
|
||||
final existing = panes.map((p) => p.id).toSet();
|
||||
for (final id
|
||||
in _panes.keys.where((id) => !existing.contains(id)).toList()) {
|
||||
final node = _panes.remove(id)!;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) => node.dispose());
|
||||
}
|
||||
final ordered = mobile?.paintOrder(panes) ?? panes;
|
||||
return Stack(
|
||||
fit: StackFit.expand,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
children: [
|
||||
for (final pane in panes)
|
||||
Positioned.fromRect(
|
||||
for (final pane in ordered)
|
||||
// A switch moves the retained pane view; the view itself is
|
||||
// built once per layout and only repositioned per tick.
|
||||
AnimatedBuilder(
|
||||
key: ValueKey('chat-workspace-${pane.id}'),
|
||||
rect:
|
||||
mobile?.rects[pane.id] ??
|
||||
(collapsed
|
||||
? Offset.zero & constraints.biggest
|
||||
: geometry.panes[pane.id]!),
|
||||
child: Offstage(
|
||||
offstage: mobile != null
|
||||
? !mobile.rects.containsKey(pane.id)
|
||||
: collapsed &&
|
||||
pane.id != widget.controller.activePaneId,
|
||||
child: ExcludeFocus(
|
||||
excluding:
|
||||
collapsed &&
|
||||
pane.id != widget.controller.activePaneId,
|
||||
child: ChatMobilePaneViewport(
|
||||
peek: mobile?.peekId == pane.id,
|
||||
active: pane.id == activeId,
|
||||
animate:
|
||||
mobile != null &&
|
||||
!MediaQuery.disableAnimationsOf(context),
|
||||
contentHeight: mobile?.contentHeight,
|
||||
label: widget.paneTitle?.call(pane) ?? pane.sessionId,
|
||||
paneId: pane.id,
|
||||
onActivate: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
widget.controller.activate(pane.id);
|
||||
},
|
||||
child: FocusScope(
|
||||
node: _panes.putIfAbsent(
|
||||
pane.id,
|
||||
() => FocusScopeNode(debugLabel: pane.id),
|
||||
),
|
||||
onFocusChange: (focused) {
|
||||
if (focused && !widget.mobilePeeks) {
|
||||
widget.controller.activate(pane.id);
|
||||
}
|
||||
},
|
||||
child: Listener(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onPointerDown: (_) =>
|
||||
widget.controller.activate(pane.id),
|
||||
child: Semantics(
|
||||
identifier: 'chat-pane-${pane.id}',
|
||||
container: true,
|
||||
sortKey: mobile == null
|
||||
? null
|
||||
: const OrdinalSortKey(0),
|
||||
child: widget.paneBuilder(
|
||||
context,
|
||||
pane,
|
||||
pane.id == widget.controller.activePaneId,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
animation: _motion.animation,
|
||||
child: _paneView(pane, mobile, collapsed, activeId),
|
||||
builder: (context, child) => Positioned.fromRect(
|
||||
rect:
|
||||
_motion.rectFor(pane.id) ??
|
||||
(collapsed
|
||||
? Offset.zero & constraints.biggest
|
||||
: geometry.panes[pane.id]!),
|
||||
child: child!,
|
||||
),
|
||||
),
|
||||
if (!collapsed && mobile == null)
|
||||
@@ -225,4 +197,58 @@ class _ChatWorkspaceState extends State<ChatWorkspace> {
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Widget _paneView(
|
||||
ChatWorkspacePane pane,
|
||||
ChatMobilePanes? mobile,
|
||||
bool collapsed,
|
||||
String? activeId,
|
||||
) {
|
||||
final peek = mobile?.peekId == pane.id;
|
||||
final active = pane.id == activeId;
|
||||
return Offstage(
|
||||
offstage: mobile != null
|
||||
? !mobile.rects.containsKey(pane.id)
|
||||
: collapsed && !active,
|
||||
child: ExcludeFocus(
|
||||
excluding: collapsed && !active,
|
||||
child: ChatMobilePaneViewport(
|
||||
peek: peek,
|
||||
active: active,
|
||||
barReveal: peek ? _motion.recede : _motion.rise,
|
||||
contentHeight: mobile?.contentHeight,
|
||||
label: widget.paneTitle?.call(pane) ?? pane.sessionId,
|
||||
paneId: pane.id,
|
||||
onActivate: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
widget.controller.activate(pane.id);
|
||||
},
|
||||
child: FocusScope(
|
||||
node: _panes.putIfAbsent(
|
||||
pane.id,
|
||||
() => FocusScopeNode(debugLabel: pane.id),
|
||||
),
|
||||
onFocusChange: (focused) {
|
||||
if (focused && !widget.mobilePeeks) {
|
||||
widget.controller.activate(pane.id);
|
||||
}
|
||||
},
|
||||
child: Listener(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
// A press in the peek scrolls or taps; the tap alone activates.
|
||||
onPointerDown: peek
|
||||
? null
|
||||
: (_) => widget.controller.activate(pane.id),
|
||||
child: Semantics(
|
||||
identifier: 'chat-pane-${pane.id}',
|
||||
container: true,
|
||||
sortKey: mobile == null ? null : const OrdinalSortKey(0),
|
||||
child: widget.paneBuilder(context, pane, active),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user