Put the active chat on center stage with Ctrl/Cmd+E

This commit is contained in:
2026-11-10 12:57:39 +00:00
parent 19aa726e7f
commit e033d4e176
10 changed files with 653 additions and 83 deletions
@@ -292,83 +292,98 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
Widget _workspaceView() => SafeArea(
top: false,
child: ChatWorkspace(
key: _workspaceKey,
controller: _workspace,
onVisibleSessionIdsChanged: _workspaceVisibilityChanged,
shortcutsEnabled: _workspaceVisible,
singlePane: !showsListBesideDetail(context),
mobilePeeks: true,
paneTitle: (pane) =>
'${_rowFor(pane.sessionId)?['title'] ?? pane.sessionId}',
onFocusPane: (pane) => _composerFocus.request(pane.sessionId),
paneBuilder: (context, pane, active) {
final scope = ChatWorkspacePaneScope.maybeOf(context);
final topShared = scope?.topEdgeShared ?? false;
final bottomShared = scope?.bottomEdgeShared ?? false;
final leftShared = scope?.leftEdgeShared ?? false;
final rightShared = scope?.rightEdgeShared ?? false;
final activeColor = _workspace.paneCount > 1 && active
? chatColorShade(
context,
chatSessionColor(_rowFor(pane.sessionId)),
) ??
(chatControlsStyleOf(context) == ChatControlsStyle.cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary)
: Colors.transparent;
return Semantics(
selected: active,
child: AnimatedContainer(
duration: showsListBesideDetail(context)
? Motion.of(context, Motion.standard)
: Duration.zero,
curve: Motion.curve,
foregroundDecoration: BoxDecoration(
border: showsListBesideDetail(context)
? Border(
top: bottomShared && !topShared
? BorderSide(color: activeColor)
: BorderSide.none,
bottom: BorderSide(
color: bottomShared ? Colors.transparent : activeColor,
child: ChatCenterStageKeys(
controller: ChatCenterStageController.instance,
enabled: () =>
_workspaceVisible &&
_workspace.paneCount > 0 &&
showsListBesideDetail(context) &&
_chatOwnsKeyboard(),
child: ChatWorkspace(
key: _workspaceKey,
centerStage: ChatCenterStageController.instance,
paneColor: (pane) =>
chatColorShade(context, chatSessionColor(_rowFor(pane.sessionId))),
controller: _workspace,
onVisibleSessionIdsChanged: _workspaceVisibilityChanged,
shortcutsEnabled: _workspaceVisible,
singlePane: !showsListBesideDetail(context),
mobilePeeks: true,
paneTitle: (pane) =>
'${_rowFor(pane.sessionId)?['title'] ?? pane.sessionId}',
onFocusPane: (pane) => _composerFocus.request(pane.sessionId),
paneBuilder: (context, pane, active) {
final scope = ChatWorkspacePaneScope.maybeOf(context);
final topShared = scope?.topEdgeShared ?? false;
final bottomShared = scope?.bottomEdgeShared ?? false;
final leftShared = scope?.leftEdgeShared ?? false;
final rightShared = scope?.rightEdgeShared ?? false;
final activeColor = _workspace.paneCount > 1 && active
? chatColorShade(
context,
chatSessionColor(_rowFor(pane.sessionId)),
) ??
(chatControlsStyleOf(context) == ChatControlsStyle.cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary)
: Colors.transparent;
return Semantics(
selected: active,
child: AnimatedContainer(
duration: showsListBesideDetail(context)
? Motion.of(context, Motion.standard)
: Duration.zero,
curve: Motion.curve,
foregroundDecoration: BoxDecoration(
border: showsListBesideDetail(context)
? Border(
top: bottomShared && !topShared
? BorderSide(color: activeColor)
: BorderSide.none,
bottom: BorderSide(
color: bottomShared
? Colors.transparent
: activeColor,
),
left: bottomShared && topShared && !leftShared
? BorderSide(color: activeColor)
: BorderSide.none,
right:
bottomShared &&
topShared &&
leftShared &&
!rightShared
? BorderSide(color: activeColor)
: BorderSide.none,
)
: Border(
bottom: BorderSide(
color: bottomShared
? Colors.transparent
: activeColor,
),
),
left: bottomShared && topShared && !leftShared
? BorderSide(color: activeColor)
: BorderSide.none,
right:
bottomShared &&
topShared &&
leftShared &&
!rightShared
? BorderSide(color: activeColor)
: BorderSide.none,
)
: Border(
bottom: BorderSide(
color: bottomShared ? Colors.transparent : activeColor,
),
),
),
// Every pane's bar carries its own chat's colour; beside the
// active pane the others fade theirs.
child: ChatPaneActivity(
inactive: _workspace.paneCount > 1 && !active,
child: DetailPane(
key: ValueKey('chat-pane-detail-${pane.id}'),
destination: AppDestination.chat,
implyBack: false,
builder: (context) => _thread(
pane.sessionId,
_back,
pane: pane,
paneContext: context,
),
// Every pane's bar carries its own chat's colour; beside the
// active pane the others fade theirs.
child: ChatPaneActivity(
inactive: _workspace.paneCount > 1 && !active,
child: DetailPane(
key: ValueKey('chat-pane-detail-${pane.id}'),
destination: AppDestination.chat,
implyBack: false,
builder: (context) => _thread(
pane.sessionId,
_back,
pane: pane,
paneContext: context,
),
),
),
),
),
);
},
);
},
),
),
);
}
+5
View File
@@ -31,6 +31,9 @@ import 'conversation/chat_add_pane_picker.dart';
import 'conversation/chat_sidebar_controls.dart';
import 'ui/sessions/chat_compact_sidebar.dart';
import 'workspace/chat_workspace.dart';
import 'workspace/chat_center_stage_action.dart';
import 'workspace/chat_center_stage_controller.dart';
import 'workspace/chat_center_stage_keys.dart';
import 'workspace/chat_workspace_entrance.dart';
import 'ui/sessions/chat_adaptive.dart';
import 'conversation/chat_row_widgets.dart';
@@ -519,6 +522,8 @@ class _ChatScreenState extends State<ChatScreen>
materialIcon: Icons.view_quilt_outlined,
cupertinoIcon: CupertinoIcons.square_split_2x2,
),
if (_workspace.paneCount > 1 && showsListBesideDetail(context))
chatCenterStageAction(ChatCenterStageController.instance),
if (_workspace.paneCount > 1)
ChatBarAction(
label: 'Close pane',
@@ -0,0 +1,23 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../ui/sessions/chat_adaptive.dart';
import 'chat_center_stage_controller.dart';
/// The pane menu's center-stage toggle, naming its keyboard shortcut.
ChatBarAction chatCenterStageAction(ChatCenterStageController controller) {
final shortcut = chatCenterStageShortcutLabel();
return ChatBarAction(
identifier: 'chat-center-stage-toggle',
label: controller.value
? 'Leave center stage ($shortcut)'
: 'Center stage ($shortcut)',
onPressed: controller.toggle,
materialIcon: controller.value
? Icons.view_quilt_outlined
: Icons.center_focus_strong_outlined,
cupertinoIcon: controller.value
? CupertinoIcons.square_split_2x2
: CupertinoIcons.viewfinder,
);
}
@@ -0,0 +1,99 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:shared_preferences/shared_preferences.dart';
const chatCenterStagePreferenceKey = 'pipelines.next.chatCenterStage.v1';
abstract interface class ChatCenterStageStore {
Future<bool?> load();
Future<bool> save(bool on);
}
class SharedChatCenterStageStore implements ChatCenterStageStore {
const SharedChatCenterStageStore();
@override
Future<bool?> load() async {
try {
return (await SharedPreferences.getInstance()).getBool(
chatCenterStagePreferenceKey,
);
} on Object {
return null;
}
}
@override
Future<bool> save(bool on) async {
try {
return await (await SharedPreferences.getInstance()).setBool(
chatCenterStagePreferenceKey,
on,
);
} on Object {
return false;
}
}
}
/// Whether the wide chat workspace puts its active chat on center stage.
/// Device-local, like the quick-switch style: a presentation choice, not
/// part of any server's layout.
class ChatCenterStageController extends ValueNotifier<bool> {
ChatCenterStageController({ChatCenterStageStore? store})
: _store = store ?? const SharedChatCenterStageStore(),
super(false);
static final instance = ChatCenterStageController();
final ChatCenterStageStore _store;
int _revision = 0;
bool _restored = false;
/// Reads the saved choice once, unless it was changed meanwhile.
Future<void> restore() async {
if (_restored) return;
_restored = true;
final revision = _revision;
final saved = await _store.load();
if (saved != null && revision == _revision) super.value = saved;
}
@override
set value(bool on) {
if (on == value) return;
_revision++;
super.value = on;
unawaited(_store.save(on));
}
void toggle() => value = !value;
}
/// Whether [event] toggles center stage: Cmd+E on Apple platforms (where
/// Ctrl+E stays the text fields' and shell's end of line) and Ctrl+E
/// elsewhere, with no other modifier. Repeats of a held chord match too, so
/// they are swallowed; only the first press toggles.
bool chatCenterStageShortcut(
KeyEvent event,
HardwareKeyboard keyboard, {
TargetPlatform? platform,
}) {
if (event is KeyUpEvent || keyboard.isShiftPressed || keyboard.isAltPressed) {
return false;
}
if (event.logicalKey != LogicalKeyboardKey.keyE) return false;
return chatCenterStageUsesCommand(platform)
? keyboard.isMetaPressed && !keyboard.isControlPressed
: keyboard.isControlPressed && !keyboard.isMetaPressed;
}
bool chatCenterStageUsesCommand([TargetPlatform? platform]) {
final target = platform ?? defaultTargetPlatform;
return target == TargetPlatform.macOS || target == TargetPlatform.iOS;
}
/// The shortcut as this platform shows it, for menus and tooltips.
String chatCenterStageShortcutLabel([TargetPlatform? platform]) =>
chatCenterStageUsesCommand(platform) ? 'Cmd+E' : 'Ctrl+E';
@@ -0,0 +1,63 @@
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import '../../../ui/input/keyboard_owner.dart';
import 'chat_center_stage_controller.dart';
/// Answers the center-stage chord before any focused widget sees it, so it
/// works from the composer, the sidebar or a toolbar, and the focused field
/// never types it. Handling the key also stops a browser's own Ctrl+E/Cmd+E
/// (address-bar search, find with selection) in the web build.
///
/// On Apple platforms the chord is Cmd+E and works in the terminal too.
/// Elsewhere it is Ctrl+E, which the terminal keeps while it has the
/// keyboard: there it is the shell's end of line.
class ChatCenterStageKeys extends StatefulWidget {
const ChatCenterStageKeys({
super.key,
required this.controller,
required this.enabled,
required this.child,
});
final ChatCenterStageController controller;
/// Whether the chord belongs to this workspace now: wide, shown and with
/// no popup or other destination over it.
final bool Function() enabled;
final Widget child;
@override
State<ChatCenterStageKeys> createState() => _ChatCenterStageKeysState();
}
class _ChatCenterStageKeysState extends State<ChatCenterStageKeys> {
@override
void initState() {
super.initState();
FocusManager.instance.addEarlyKeyEventHandler(_key);
unawaited(widget.controller.restore());
}
@override
void dispose() {
FocusManager.instance.removeEarlyKeyEventHandler(_key);
super.dispose();
}
KeyEventResult _key(KeyEvent event) {
if (!mounted ||
!chatCenterStageShortcut(event, HardwareKeyboard.instance) ||
!widget.enabled() ||
(!chatCenterStageUsesCommand() && primaryFocusIsTypingSurface())) {
return KeyEventResult.ignored;
}
if (event is KeyDownEvent) widget.controller.toggle();
return KeyEventResult.handled;
}
@override
Widget build(BuildContext context) => widget.child;
}
@@ -0,0 +1,78 @@
import 'dart:math' as math;
import 'dart:ui';
import '../conversation/chat_reading_width.dart';
import 'chat_workspace_geometry.dart';
/// How much wider than the transcript's reading column the stage is: enough
/// for the copy gutter and some air on each side, not much more.
const double chatCenterStageWidthFactor = 1.25;
/// The stage's preferred width: [kChatReadingWidth] plus a modest margin.
const double chatCenterStageWidth =
kChatReadingWidth * chatCenterStageWidthFactor;
/// The narrowest a pane beside the stage gets; wide enough for its colour
/// and a vertical title.
const double chatCenterStageStripMinimumWidth = 56;
/// The gap between the stage and each pane beside it.
const double chatCenterStageGap = chatPaneDividerExtent;
/// Where every pane sits while one chat is on center stage. Panes keep their
/// split-tree order left to right; the stage takes the full height and its
/// preferred width (capped by the workspace), and the others share the rest
/// as columns. A column narrower than a usable pane is shown as a strip.
class ChatCenterStageLayout {
ChatCenterStageLayout._(this.rects, this.strips, this.stageId);
final Map<String, Rect> rects;
/// Panes too narrow to use, shown as a title strip over their retained view.
final Set<String> strips;
final String stageId;
/// Null when there is nothing to stage (one pane) or no room for a stage
/// beside every other pane's strip.
static ChatCenterStageLayout? of(
Size size,
List<String> order,
String? activeId,
) {
if (order.length < 2 || activeId == null || !order.contains(activeId)) {
return null;
}
final others = order.length - 1;
final available = size.width - chatCenterStageGap * others;
final stage = math.min(
chatCenterStageWidth,
available - others * chatCenterStageStripMinimumWidth,
);
if (stage < chatPaneMinimumWidth) return null;
final column = (available - stage) / others;
final rects = <String, Rect>{};
final strips = <String>{};
var left = 0.0;
for (final id in order) {
final width = id == activeId ? stage : column;
rects[id] = Rect.fromLTWH(left, 0, width, size.height);
if (id != activeId && width < chatPaneMinimumWidth) strips.add(id);
left += width + chatCenterStageGap;
}
return ChatCenterStageLayout._(rects, strips, activeId);
}
/// The pane beside [active] in [direction]: columns run left to right, so
/// up and down have none.
String? neighbor(String active, ChatPaneDirection direction) {
final order = rects.keys.toList();
final index = order.indexOf(active);
if (index < 0) return null;
final next = switch (direction) {
ChatPaneDirection.left => index - 1,
ChatPaneDirection.right => index + 1,
_ => -1,
};
return next < 0 || next >= order.length ? null : order[next];
}
}
@@ -0,0 +1,117 @@
import 'dart:math' as math;
import 'dart:ui' show lerpDouble;
import 'package:flutter/widgets.dart';
import 'chat_center_stage_layout.dart';
import 'chat_workspace_geometry.dart';
/// Moves the retained pane views between the split layout and center stage,
/// and the stage between chats. Only a change of role animates (entering,
/// leaving, a new stage chat); a divider drag or window resize follows at once.
class ChatCenterStageMotion {
ChatCenterStageMotion({required TickerProvider vsync})
: _controller = AnimationController(
vsync: vsync,
duration: duration,
value: 1,
);
/// Short enough to follow a quick switch, long enough to read as a move.
static const Duration duration = Duration(milliseconds: 320);
/// Material's emphasized easing: a brisk start and a soft landing.
static const Curve curve = Curves.easeInOutCubicEmphasized;
final AnimationController _controller;
Listenable get animation => _controller;
bool get isAnimating => _controller.isAnimating;
double get _t => curve.transform(_controller.value);
String? _role;
Map<String, Rect> _from = const {}, _to = const {};
Set<String> _stripsFrom = const {}, _stripsTo = const {};
ChatCenterStageLayout? _stage;
/// The stage the panes rest in (or travel to), null in the split layout.
ChatCenterStageLayout? get stage => _stage;
/// Whether the split layout's dividers apply: not on stage, nor on the way.
bool get showsDividers => _stage == null && !isAnimating;
/// Called on each workspace layout. [stage] is null while the split layout
/// applies; [split] is the split layout's geometry. [engaged] false (a phone
/// or collapsed window) releases every pane to the workspace's own layout.
void layout({
required bool engaged,
required Map<String, Rect> split,
required ChatCenterStageLayout? stage,
required bool animate,
}) {
if (!engaged) {
_role = null;
_stage = null;
_from = _to = const {};
_stripsFrom = _stripsTo = const {};
_controller.value = 1;
return;
}
final role = stage == null ? 'split' : 'stage:${stage.stageId}';
final rects = stage?.rects ?? split;
final strips = stage?.strips ?? const <String>{};
_stage = stage;
if (role == _role) {
// Same arrangement: follow sizes at once, or retarget a running move.
if (!isAnimating) _from = rects;
_to = rects;
if (!isAnimating) _stripsFrom = strips;
_stripsTo = strips;
return;
}
final first = _role == null;
_role = role;
if (first || !animate) {
_from = _to = rects;
_stripsFrom = _stripsTo = strips;
_controller.value = 1;
return;
}
_from = {
for (final id in rects.keys) id: rectFor(id) ?? split[id] ?? rects[id]!,
};
_stripsFrom = {
for (final id in rects.keys)
if (stripFor(id) > .5) id,
};
_to = rects;
_stripsTo = strips;
_controller.forward(from: 0);
}
/// Where [id] paints now, or null when this motion does not place it.
Rect? rectFor(String id) {
final to = _to[id];
if (to == null) return null;
if (!isAnimating) return to;
return Rect.lerp(_from[id] ?? to, to, _t);
}
/// How far [id]'s title strip covers it, from 0 (live chat) to 1.
double stripFor(String id) {
final to = _stripsTo.contains(id) ? 1.0 : 0.0;
if (!isAnimating) return to;
final from = _stripsFrom.contains(id) ? 1.0 : 0.0;
return lerpDouble(from, to, _t)!;
}
/// A strip keeps its chat laid out at a usable width beneath the title, so
/// the transcript never reflows into a sliver.
Size? viewportFor(String id) {
if (_role == null || (_stage == null && !isAnimating)) return null;
final rect = rectFor(id);
if (rect == null) return null;
return Size(math.max(rect.width, chatPaneMinimumWidth), rect.height);
}
void dispose() => _controller.dispose();
}
@@ -0,0 +1,107 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/host.dart';
/// Covers a chat beside the stage too narrow to use: its colour and title,
/// running down the column. A press brings that chat to center stage. The
/// retained chat underneath keeps its state.
class ChatCenterStageStrip extends StatelessWidget {
const ChatCenterStageStrip({
super.key,
required this.paneId,
required this.title,
required this.color,
required this.onSelected,
});
final String paneId;
final String title;
final Color? color;
final VoidCallback onSelected;
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final scheme = Theme.of(context).colorScheme;
final accent =
color ??
(cupertino ? CupertinoTheme.of(context).primaryColor : scheme.primary);
final background = Color.alphaBlend(
accent.withValues(alpha: .12),
cupertino
? CupertinoColors.secondarySystemBackground.resolveFrom(context)
: scheme.surfaceContainer,
);
final style = cupertino
? CupertinoTheme.of(context).textTheme.textStyle
: Theme.of(context).textTheme.titleSmall;
final label = Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Column(
children: [
Icon(Icons.circle, color: accent, size: style?.fontSize),
const SizedBox(height: 12),
Expanded(
child: RotatedBox(
quarterTurns: 1,
child: Text(
title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: style,
),
),
),
],
),
);
return Semantics(
identifier: 'chat-center-stage-strip-$paneId',
button: true,
label: 'Show $title on center stage',
excludeSemantics: true,
onTap: onSelected,
child: cupertino
? CupertinoButton(
padding: EdgeInsets.zero,
color: background,
borderRadius: BorderRadius.zero,
onPressed: onSelected,
child: SizedBox.expand(child: label),
)
: Tooltip(
message: title,
excludeFromSemantics: true,
child: Material(
color: background,
child: InkWell(
onTap: onSelected,
child: SizedBox.expand(child: label),
),
),
),
);
}
}
/// One pane's painted layer: its retained [view], with its strip fading in
/// over it while the pane sits (or travels to sit) beside the stage. The
/// structure never changes, so moving in or out of center stage keeps the
/// view's state; a covered view is out of focus traversal.
Widget chatCenterStageLayer({
required double strip,
required bool covered,
required Widget view,
required Widget Function()? buildStrip,
}) => Stack(
fit: StackFit.expand,
children: [
ExcludeFocus(excluding: covered, child: view),
if (strip > 0 && buildStrip != null)
IgnorePointer(
ignoring: !covered,
child: Opacity(opacity: strip.clamp(0, 1), child: buildStrip()),
),
],
);
@@ -4,6 +4,9 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../../ui/motion/quick_switch_animation.dart';
import 'chat_center_stage_layout.dart';
import 'chat_center_stage_motion.dart';
import 'chat_center_stage_strip.dart';
import 'chat_workspace_controller.dart';
import 'chat_workspace_geometry.dart';
import 'chat_mobile_panes.dart';
@@ -59,6 +62,8 @@ class ChatWorkspace extends StatefulWidget {
this.animationStyle,
this.paneTitle,
this.onVisibleSessionIdsChanged,
this.centerStage,
this.paneColor,
});
final ChatWorkspaceController controller;
final ChatWorkspacePaneBuilder paneBuilder;
@@ -71,6 +76,13 @@ class ChatWorkspace extends StatefulWidget {
final String Function(ChatWorkspacePane)? paneTitle;
final ValueChanged<Set<String>>? onVisibleSessionIdsChanged;
/// While true on a wide window, the active chat takes center stage and the
/// others line up beside it (see [ChatCenterStageLayout]).
final ValueListenable<bool>? centerStage;
/// A pane's chat colour, for its strip beside the stage.
final Color? Function(ChatWorkspacePane)? paneColor;
/// Keyboard navigation only: the owner can focus the target composer.
/// Pointer activation leaves text-selection and pointer focus alone.
final ValueChanged<ChatWorkspacePane>? onFocusPane;
@@ -80,10 +92,11 @@ class ChatWorkspace extends StatefulWidget {
}
class _ChatWorkspaceState extends State<ChatWorkspace>
with SingleTickerProviderStateMixin {
with TickerProviderStateMixin {
final _focus = FocusNode(debugLabel: 'Chat workspace');
final Map<String, FocusScopeNode> _panes = {};
late final ChatPaneSwitchMotion _motion;
late final ChatCenterStageMotion _stage = ChatCenterStageMotion(vsync: this);
ChatWorkspaceGeometry? _geometry;
String? _lastActiveId;
Set<String> _visibleSessionIds = const {};
@@ -145,7 +158,12 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
};
if (direction == null) return false;
final id = widget.controller.activePaneId;
final target = id == null ? null : _geometry?.neighbor(id, direction);
final stage = _stage.stage;
final target = id == null
? null
: stage != null
? stage.neighbor(id, direction)
: _geometry?.neighbor(id, direction);
if (target != null) {
widget.controller.activate(target);
final pane = widget.controller.activePane!;
@@ -169,6 +187,7 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
_backdrop.dispose();
_motion.animation.removeStatusListener(_motionSettled);
_motion.dispose();
_stage.dispose();
_focus.dispose();
for (final node in _panes.values) {
node.dispose();
@@ -183,6 +202,7 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
listenable: Listenable.merge([
widget.controller,
QuickSwitchAnimationController.instance,
?widget.centerStage,
]),
builder: (context, _) => LayoutBuilder(
builder: (context, constraints) {
@@ -239,6 +259,17 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
QuickSwitchAnimationController.instance.value,
);
}
final engaged = !collapsed && mobile == null;
_stage.layout(
engaged: engaged,
split: geometry.panes,
stage: engaged && widget.centerStage?.value == true
? ChatCenterStageLayout.of(constraints.biggest, [
for (final pane in panes) pane.id,
], activeId)
: null,
animate: !MediaQuery.disableAnimationsOf(context),
);
_reportVisible({
for (final pane in panes)
if (mobile != null
@@ -281,6 +312,7 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
for (final edge in const ['top', 'bottom', 'left', 'right'])
if (!collapsed &&
mobile == null &&
_stage.stage == null &&
sharesEdge(entry.value, edge))
edge,
},
@@ -289,6 +321,8 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
context: context,
backdrop: _backdrop,
motion: _motion,
stage: _stage,
stageStrip: _strip,
controller: widget.controller,
geometry: geometry,
mobile: mobile,
@@ -303,6 +337,22 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
),
);
Widget _strip(ChatWorkspacePane pane) => ChatCenterStageStrip(
paneId: pane.id,
title: widget.paneTitle?.call(pane) ?? pane.sessionId,
color: widget.paneColor?.call(pane),
onSelected: () {
FocusManager.instance.primaryFocus?.unfocus();
widget.controller.activate(pane.id);
// Choosing a strip is choosing that chat: its composer takes the
// keyboard once it is on stage.
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted || widget.controller.activePaneId != pane.id) return;
widget.onFocusPane?.call(pane);
});
},
);
Widget _paneView(
ChatWorkspacePane pane,
ChatMobilePanes? mobile,
@@ -1,6 +1,8 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/host.dart';
import 'chat_center_stage_motion.dart';
import 'chat_center_stage_strip.dart';
import 'chat_mobile_panes.dart';
import 'chat_mobile_peek_divider.dart';
import 'chat_pane_backdrop.dart';
@@ -18,6 +20,7 @@ Widget chatWorkspaceSurface({
required BuildContext context,
required ChatPaneBackdrop backdrop,
required ChatPaneSwitchMotion motion,
required ChatCenterStageMotion stage,
required ChatWorkspaceController controller,
required ChatWorkspaceGeometry geometry,
required ChatMobilePanes? mobile,
@@ -25,7 +28,9 @@ Widget chatWorkspaceSurface({
required Size size,
required List<ChatWorkspacePane> panes,
required Widget Function(ChatWorkspacePane) paneView,
Widget Function(ChatWorkspacePane)? stageStrip,
}) {
final moving = Listenable.merge([motion.animation, stage.animation]);
final ordered = mobile?.paintOrder(panes) ?? panes;
final picture = backdrop.image != null && mobile != null && motion.isTape
? AnimatedBuilder(
@@ -65,11 +70,12 @@ Widget chatWorkspaceSurface({
// built once per layout; ticks resize its real scroll viewport.
AnimatedBuilder(
key: ValueKey('chat-workspace-${pane.id}'),
animation: motion.animation,
animation: moving,
child: paneView(pane),
builder: (context, child) => Positioned.fromRect(
rect:
motion.rectFor(pane.id) ??
stage.rectFor(pane.id) ??
(collapsed ? Offset.zero & size : geometry.panes[pane.id]!),
child: IgnorePointer(
ignoring:
@@ -88,11 +94,18 @@ Widget chatWorkspaceSurface({
child: ChatSwitchCard(
motion: motion,
outgoing: motion.isRetainedOutgoing(pane.id),
child: ChatMotionViewport(
size: mobile != null && motion.isAnimating && !motion.isTape
? motion.viewportRectFor(pane.id)?.size
: null,
child: child!,
child: chatCenterStageLayer(
strip: stage.stripFor(pane.id),
covered: stage.stage?.strips.contains(pane.id) ?? false,
buildStrip: stageStrip == null
? null
: () => stageStrip(pane),
view: ChatMotionViewport(
size: mobile != null && motion.isAnimating && !motion.isTape
? motion.viewportRectFor(pane.id)?.size
: stage.viewportFor(pane.id),
child: child!,
),
),
),
),
@@ -103,7 +116,7 @@ Widget chatWorkspaceSurface({
return ChatPanePicture(
key: backdrop.pictureKey,
child: AnimatedBuilder(
animation: motion.animation,
animation: moving,
builder: (context, _) => Stack(
fit: StackFit.expand,
clipBehavior: Clip.hardEdge,
@@ -135,7 +148,7 @@ Widget chatWorkspaceSurface({
onChanged: controller.resizeMobilePeek,
),
),
if (!collapsed && mobile == null)
if (!collapsed && mobile == null && stage.showsDividers)
for (final divider in geometry.dividers)
Positioned.fromRect(
key: ValueKey('chat-workspace-${divider.split.id}'),