Merge commit '35e4aec0a753e7ff46b345e0bc83e391cf905ed4' into pipelines/run-20261112-0055-ctrl-k-and-alt-k-open-chat-24be
This commit is contained in:
@@ -147,11 +147,14 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
|
||||
/// focus. Over a single pane it swaps in the chat shown before this one
|
||||
/// instead, and back again (see [_toggleRecentChat]). Command+Tab stays
|
||||
/// with the operating system's application switcher. While the app's
|
||||
/// terminal is shown, Ctrl+Tab moves between its tabs instead.
|
||||
/// terminal is shown, Ctrl+Tab moves between its tabs instead. While a
|
||||
/// floating chat window holds the keyboard, Ctrl+Tab cycles those windows
|
||||
/// (see [ChatWindows]).
|
||||
bool _cycleChatKey(KeyEvent event) {
|
||||
final keyboard = HardwareKeyboard.instance;
|
||||
if (event is! KeyDownEvent ||
|
||||
TerminalScope.peek(context)?.claimsTabKeys == true ||
|
||||
keyboardWindow()?.entry.kind == chatWindowKind ||
|
||||
event.logicalKey != LogicalKeyboardKey.tab ||
|
||||
!keyboard.isControlPressed ||
|
||||
keyboard.isMetaPressed ||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'chat_pane_content.dart';
|
||||
import 'chat_runtime.dart';
|
||||
import 'windows/chat_window_tabs.dart';
|
||||
import 'windows/chat_windows.dart';
|
||||
import 'workspace/federated_workspace_store.dart';
|
||||
import '../../core/servers/chat/federated_chat_gateway.dart';
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../shell/windows/window_entry.dart';
|
||||
import '../../../shell/windows/window_scope.dart';
|
||||
|
||||
/// The step Ctrl+Tab (1) or Ctrl+Shift+Tab (-1) moves between floating chat
|
||||
/// windows, or null for any other key. Command+Tab stays with the system.
|
||||
int? chatWindowTabStep(KeyEvent event, HardwareKeyboard keyboard) {
|
||||
if (event is! KeyDownEvent ||
|
||||
event.logicalKey != LogicalKeyboardKey.tab ||
|
||||
!keyboard.isControlPressed ||
|
||||
keyboard.isMetaPressed ||
|
||||
keyboard.isAltPressed) {
|
||||
return null;
|
||||
}
|
||||
return keyboard.isShiftPressed ? -1 : 1;
|
||||
}
|
||||
|
||||
/// The window [step] away from the window [currentId] in [visible] (bottom
|
||||
/// to top), wrapping around. Null when [currentId] is not listed or there is
|
||||
/// no other window to move to.
|
||||
WindowEntry? chatWindowAfter(
|
||||
List<WindowEntry> visible,
|
||||
String currentId,
|
||||
int step,
|
||||
) {
|
||||
final at = visible.indexWhere((w) => w.id == currentId);
|
||||
if (at < 0 || visible.length < 2) return null;
|
||||
return visible[(at + step) % visible.length];
|
||||
}
|
||||
|
||||
/// The floating window whose content holds the keyboard, if one does. Read
|
||||
/// from the focused node's ancestors, so it needs no reference to the host.
|
||||
WindowScope? keyboardWindow() {
|
||||
final context = FocusManager.instance.primaryFocus?.context;
|
||||
if (context == null) return null;
|
||||
return context.findAncestorWidgetOfExactType<WindowScope>();
|
||||
}
|
||||
@@ -8,11 +8,13 @@ import '../../../shell/list_detail_policy.dart';
|
||||
import '../../../shell/windows/window_entry.dart';
|
||||
import '../../../shell/windows/window_kind.dart';
|
||||
import '../../../shell/windows/window_manager.dart';
|
||||
import '../../terminal/terminal_scope.dart';
|
||||
import '../chat_runtime.dart';
|
||||
import '../domain/chat_commands.dart';
|
||||
import '../workspace/chat_float_shortcut.dart';
|
||||
import '../workspace/chat_float_store.dart';
|
||||
import 'chat_window_content.dart';
|
||||
import 'chat_window_tabs.dart';
|
||||
|
||||
const chatWindowKind = 'chat';
|
||||
|
||||
@@ -79,7 +81,9 @@ class ChatWindows {
|
||||
if (_started) return;
|
||||
_started = true;
|
||||
manager.kinds.register(kind);
|
||||
FocusManager.instance.addEarlyKeyEventHandler(_key);
|
||||
FocusManager.instance
|
||||
..addEarlyKeyEventHandler(_key)
|
||||
..addEarlyKeyEventHandler(_tabKey);
|
||||
runtime.addSessionReplacedListener(_replacedElsewhere);
|
||||
runtime.sessions.addListener(_rowsChanged);
|
||||
manager.addListener(_rowsChanged);
|
||||
@@ -89,7 +93,9 @@ class ChatWindows {
|
||||
void dispose() {
|
||||
if (!_started) return;
|
||||
_started = false;
|
||||
FocusManager.instance.removeEarlyKeyEventHandler(_key);
|
||||
FocusManager.instance
|
||||
..removeEarlyKeyEventHandler(_key)
|
||||
..removeEarlyKeyEventHandler(_tabKey);
|
||||
runtime.removeSessionReplacedListener(_replacedElsewhere);
|
||||
runtime.sessions.removeListener(_rowsChanged);
|
||||
manager.removeListener(_rowsChanged);
|
||||
@@ -224,6 +230,36 @@ class ChatWindows {
|
||||
if (event is KeyDownEvent) manager.toggleOrRaiseGroup(chatWindowKind);
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
/// Ctrl+Tab and Ctrl+Shift+Tab while a floating chat window holds the
|
||||
/// keyboard: the next (previous) visible chat window, in stacking order and
|
||||
/// wrapping, comes to the top. The window host then gives it the keyboard,
|
||||
/// its composer. Left alone when another window or the tiling has the
|
||||
/// keyboard, when the terminal claims tab keys, or with one window.
|
||||
KeyEventResult _tabKey(KeyEvent event) {
|
||||
final step = chatWindowTabStep(event, HardwareKeyboard.instance);
|
||||
if (step == null || !_wide) return KeyEventResult.ignored;
|
||||
final scope = keyboardWindow();
|
||||
if (scope == null ||
|
||||
scope.entry.kind != chatWindowKind ||
|
||||
_terminalClaimsTabs()) {
|
||||
return KeyEventResult.ignored;
|
||||
}
|
||||
final target = chatWindowAfter(
|
||||
windows.where(manager.isVisible).toList(),
|
||||
scope.entry.id,
|
||||
step,
|
||||
);
|
||||
if (target == null) return KeyEventResult.ignored;
|
||||
manager.raise(target.id);
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
bool _terminalClaimsTabs() {
|
||||
final context = FocusManager.instance.primaryFocus?.context;
|
||||
return context != null &&
|
||||
TerminalScope.peek(context)?.claimsTabKeys == true;
|
||||
}
|
||||
}
|
||||
|
||||
class _Never implements Listenable {
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'chat_center_stage_layout.dart';
|
||||
|
||||
/// Hairline thickness of a center-stage edge.
|
||||
const double chatCenterStageEdgeThickness = 1;
|
||||
|
||||
/// Where the stage's two hairlines sit: each in the gap beside the stage, or on
|
||||
/// the workspace edge when the stage reaches it. Returns (left, right).
|
||||
(Rect, Rect) chatCenterStageEdgeRects(Rect stage, Size size) {
|
||||
final half = chatCenterStageGap / 2;
|
||||
const t = chatCenterStageEdgeThickness;
|
||||
final maxX = size.width - t;
|
||||
final leftX = stage.left <= 0
|
||||
? 0.0
|
||||
: (stage.left - half - t / 2).clamp(0.0, maxX).toDouble();
|
||||
final rightX = stage.right >= size.width
|
||||
? maxX
|
||||
: (stage.right + half - t / 2).clamp(0.0, maxX).toDouble();
|
||||
return (
|
||||
Rect.fromLTWH(leftX, 0, t, size.height),
|
||||
Rect.fromLTWH(rightX, 0, t, size.height),
|
||||
);
|
||||
}
|
||||
|
||||
/// The stage's left and right hairlines in the workspace's stack, drawn in the
|
||||
/// theme's outlineVariant so the centred chat column has a visible boundary.
|
||||
/// Only center stage calls this; the split layout keeps its own dividers.
|
||||
List<Widget> chatCenterStageEdges({
|
||||
required BuildContext context,
|
||||
required Rect rect,
|
||||
required Size size,
|
||||
}) {
|
||||
final color = Theme.of(context).colorScheme.outlineVariant;
|
||||
final (left, right) = chatCenterStageEdgeRects(rect, size);
|
||||
return [
|
||||
Positioned.fromRect(
|
||||
key: const ValueKey('chat-center-stage-edge-left'),
|
||||
rect: left,
|
||||
child: ColoredBox(color: color),
|
||||
),
|
||||
Positioned.fromRect(
|
||||
key: const ValueKey('chat-center-stage-edge-right'),
|
||||
rect: right,
|
||||
child: ColoredBox(color: color),
|
||||
),
|
||||
];
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'chat_center_stage_edges.dart';
|
||||
import 'chat_center_stage_motion.dart';
|
||||
import 'chat_center_stage_strip.dart';
|
||||
import 'chat_mobile_panes.dart';
|
||||
@@ -138,6 +139,12 @@ Widget chatWorkspaceSurface({
|
||||
for (final pane in livePanes)
|
||||
if (pane.key == ValueKey('chat-workspace-${motion.topPaneId}'))
|
||||
pane,
|
||||
if (stage.stage case final layout?)
|
||||
...chatCenterStageEdges(
|
||||
context: context,
|
||||
rect: stage.rectFor(layout.stageId)!,
|
||||
size: size,
|
||||
),
|
||||
if (mobile?.peekId != null && !motion.isAnimating)
|
||||
Positioned(
|
||||
top: mobile!.contentHeight - 12,
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
# Center stage column edges
|
||||
|
||||
## Change
|
||||
- In center stage (Alt+E / Option+E), the centred chat column had no visible
|
||||
boundary: its neighbours are strips or the workspace background, so the
|
||||
column's end read as unfinished.
|
||||
- Added two 1px `outlineVariant` hairlines (`ChatCenterStageEdges` in
|
||||
`app/lib/features/chat/workspace/chat_center_stage_edges.dart`). Each sits
|
||||
centred in the 12px gap beside the stage, or on the workspace edge when the
|
||||
stage reaches it.
|
||||
- Painted from `chat_workspace_surface.dart`, only while a stage layout exists.
|
||||
The split layout, phone/collapsed layouts and single-chat workspaces draw
|
||||
nothing new.
|
||||
- Reading width is unchanged (stage stays `chatCenterStageWidth`, 950 at the
|
||||
test size). The lines travel with the stage's animated rectangle.
|
||||
|
||||
## Focused results
|
||||
- `tool/memwatch/full.sh 'test/features/chat/workspace/chat_center_stage_test.dart'`
|
||||
→ PASS: 21 passed, 0 failed, 0 skipped; peak 893 MB; 8s; exit 0.
|
||||
New tests among them:
|
||||
- `the stage edges sit in the gaps beside the stage, or on the workspace edge`
|
||||
- `center stage draws the column edges in the light theme, only on stage`
|
||||
- `center stage draws the column edges in the dark theme, only on stage`
|
||||
- `tool/analyze.sh` → clean, exit 0.
|
||||
- Not run: other `test/features/chat/workspace/*` files use `ChatWorkspace`
|
||||
without `centerStage` on stage, so the new branch is not reached there. The
|
||||
land gate runs the suites.
|
||||
|
||||
## Affected states (code-level only)
|
||||
- Center stage on, 3 panes, light and dark: both hairlines present, colour is
|
||||
the theme's `outlineVariant`.
|
||||
- Center stage off: no hairlines (asserted in both themes).
|
||||
- Stage with a neighbour on each side (gaps) and stage at a workspace edge
|
||||
(line on the edge) are both covered by the geometry test.
|
||||
|
||||
## Limitations
|
||||
- No browser or device capture was made; `ui-review` owns visual evidence.
|
||||
Visual weight of a 1px `outlineVariant` line in light and dark is unverified.
|
||||
- Hairlines hide at once when leaving center stage (same as the split
|
||||
dividers); they do not fade.
|
||||
@@ -29,6 +29,14 @@ every destination and come back at app start without Chat being opened.
|
||||
terminal). On macOS Ctrl+Y in a terminal always goes to the shell.
|
||||
- **Focus**: a window that shows or comes to the top puts the keyboard in its
|
||||
composer; hiding the last window gives it back to what had it.
|
||||
- **Cycle**: while a floating chat window's content holds the keyboard (a
|
||||
composer, a Files page inside it), Ctrl+Tab brings the next visible chat
|
||||
window to the top and Ctrl+Shift+Tab the previous one, wrapping round. The
|
||||
order is the stacking order, bottom to top, and the window's composer takes
|
||||
the keyboard. Command+Tab stays with the system. With the tiling focused,
|
||||
Ctrl+Tab still cycles its panes; while the terminal claims tab keys (shown)
|
||||
it switches terminal tabs. Alt+` (`windowCycleShortcut`) still cycles every
|
||||
kind of window, not only chats.
|
||||
- **Popups**: sheets, dialogs, menus and tooltips opened from a floating chat
|
||||
are above every window. Files opens as a page inside the window, and a file
|
||||
opened from it stays in the window. Because the window's own title bar names
|
||||
@@ -60,6 +68,23 @@ every destination and come back at app start without Chat being opened.
|
||||
|
||||
## Checks
|
||||
|
||||
- Focused, 2026-11-12, `tool/memwatch/full.sh` with
|
||||
`test/features/chat/chat_floating_pane_test.dart` and
|
||||
`test/features/terminal/terminal_chat_tab_test.dart`: 16 passed, 0 failed.
|
||||
New in the first: Ctrl+Tab and Ctrl+Shift+Tab over three floating chats
|
||||
(order, wrap, composer focus, Command+Tab ignored); with the tiling focused
|
||||
Ctrl+Tab moves the active pane and leaves the windows alone, and with one
|
||||
window focused it does nothing; a terminal that claims tab keys keeps
|
||||
Ctrl+Tab over a focused chat window.
|
||||
- `tool/analyze.sh` on the changed paths: clean.
|
||||
- Affected states: two or more floating chats; one floating chat; tiling
|
||||
focused; a window focused with the terminal shown (claimed); Command+Tab.
|
||||
- Not covered: the terminal's own tab switching (the test app has no terminal
|
||||
surface), real browser or device keys, and captures (ui-review's).
|
||||
- Observed, not changed: in the widget harness, floating from a pane's More
|
||||
menu does not leave the keyboard in the new window's composer (the window
|
||||
takes it); the chord and Ctrl+Tab do.
|
||||
|
||||
- `test/features/chat/chat_floating_pane_test.dart` (the Chat screen with the
|
||||
window host), `test/features/chat/windows/chat_windows_test.dart`,
|
||||
`test/features/chat/workspace/chat_workspace_float_test.dart`,
|
||||
|
||||
@@ -11,6 +11,7 @@ import 'package:pipelines_app/features/chat/windows/chat_windows.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_float_store.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace_store.dart';
|
||||
import 'package:pipelines_app/features/terminal/terminal_scope.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_frame.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_host.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_kind.dart';
|
||||
@@ -48,6 +49,16 @@ class _Store implements WindowStore {
|
||||
}
|
||||
}
|
||||
|
||||
class _ClaimingTerminal implements TerminalActions {
|
||||
const _ClaimingTerminal();
|
||||
@override
|
||||
void toggle() {}
|
||||
@override
|
||||
bool get claimsTabKeys => true;
|
||||
@override
|
||||
Future<String?> openAt(ApiGateway gateway, String cwd) async => null;
|
||||
}
|
||||
|
||||
class _TerminalKind extends WindowKind {
|
||||
@override
|
||||
String get key => 'terminal';
|
||||
@@ -105,6 +116,7 @@ class _App {
|
||||
WidgetTester tester, {
|
||||
Size size = const Size(1800, 1000),
|
||||
bool terminalSurface = false,
|
||||
bool terminalClaimsTabs = false,
|
||||
}) async {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
@@ -124,6 +136,13 @@ class _App {
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
// A terminal that shows its tabs: it claims Ctrl+Tab.
|
||||
builder: terminalClaimsTabs
|
||||
? (context, child) => TerminalScope(
|
||||
actions: const _ClaimingTerminal(),
|
||||
child: child!,
|
||||
)
|
||||
: null,
|
||||
home: Scaffold(
|
||||
body: Stack(
|
||||
fit: StackFit.expand,
|
||||
@@ -218,6 +237,19 @@ Future<void> _chord(WidgetTester tester) async {
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
/// Ctrl+Tab, or Ctrl+Shift+Tab with [shift].
|
||||
Future<void> _tab(WidgetTester tester, {bool shift = false}) async {
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
|
||||
if (shift) await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
|
||||
if (shift) await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
bool _composerFocused(WidgetTester tester, String id) =>
|
||||
tester.widget<EditableText>(_input(id)).focusNode.hasPrimaryFocus;
|
||||
|
||||
Future<void> _controlChord(WidgetTester tester) async {
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.keyY);
|
||||
@@ -452,6 +484,91 @@ void main() {
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
testWidgets('Ctrl+Tab and Ctrl+Shift+Tab cycle the floating chat windows, '
|
||||
'each composer taking the keyboard', (tester) async {
|
||||
await _saved('a', 'b', 'c');
|
||||
final app = _App(_Store());
|
||||
await app.start(tester);
|
||||
await _menu(tester, 'b', 'Float (Alt+Y)');
|
||||
await _menu(tester, 'c', 'Float (Alt+Y)');
|
||||
await _menu(tester, 'a', 'Float (Alt+Y)');
|
||||
expect(app.floating, ['b', 'c', 'a']);
|
||||
|
||||
// Command+Tab belongs to the system.
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.metaLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.metaLeft);
|
||||
await tester.pumpAndSettle();
|
||||
expect(app.floating, ['b', 'c', 'a']);
|
||||
|
||||
await _tab(tester);
|
||||
expect(app.floating, ['c', 'a', 'b']);
|
||||
expect(_composerFocused(tester, 'b'), isTrue);
|
||||
// Past the top, the bottom window comes up again.
|
||||
await _tab(tester);
|
||||
expect(app.floating, ['a', 'b', 'c']);
|
||||
expect(_composerFocused(tester, 'c'), isTrue);
|
||||
await _tab(tester, shift: true);
|
||||
expect(app.floating, ['a', 'c', 'b']);
|
||||
expect(_composerFocused(tester, 'b'), isTrue);
|
||||
await _tab(tester, shift: true);
|
||||
expect(app.floating, ['a', 'b', 'c']);
|
||||
expect(_composerFocused(tester, 'c'), isTrue);
|
||||
expect(tester.takeException(), isNull);
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
testWidgets('with the tiling focused Ctrl+Tab cycles its panes and leaves '
|
||||
'the windows alone', (tester) async {
|
||||
await _saved('a', 'b', 'c');
|
||||
final app = _App(_Store());
|
||||
await app.start(tester);
|
||||
await _menu(tester, 'c', 'Float (Alt+Y)');
|
||||
expect(app.floating, ['c']);
|
||||
final controller = _workspace(tester);
|
||||
|
||||
await tester.tapAt(tester.getCenter(_input('a')));
|
||||
await tester.pump();
|
||||
expect(controller.activePane?.sessionId, 'a');
|
||||
await _tab(tester);
|
||||
expect(controller.activePane?.sessionId, 'b');
|
||||
expect(_composerFocused(tester, 'b'), isTrue);
|
||||
expect(app.floating, ['c']);
|
||||
|
||||
// With a window focused, the panes stay where they are; a single window
|
||||
// has nothing to cycle to.
|
||||
await tester.tapAt(tester.getCenter(_input('c')));
|
||||
await tester.pump();
|
||||
expect(_composerFocused(tester, 'c'), isTrue);
|
||||
await _tab(tester);
|
||||
expect(controller.activePane?.sessionId, 'b');
|
||||
expect(app.floating, ['c']);
|
||||
expect(tester.takeException(), isNull);
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
testWidgets('a terminal that claims tab keys keeps Ctrl+Tab over a focused '
|
||||
'floating chat', (tester) async {
|
||||
await _saved('a', 'b', 'c');
|
||||
final app = _App(_Store());
|
||||
await app.start(tester, terminalClaimsTabs: true);
|
||||
await _menu(tester, 'b', 'Float (Alt+Y)');
|
||||
await _menu(tester, 'c', 'Float (Alt+Y)');
|
||||
expect(app.floating, ['b', 'c']);
|
||||
await tester.tapAt(tester.getCenter(_input('c')));
|
||||
await tester.pump();
|
||||
expect(_composerFocused(tester, 'c'), isTrue);
|
||||
|
||||
// The terminal's tabs get the key (its own handler is not in this app);
|
||||
// neither the windows nor the panes move.
|
||||
await _tab(tester);
|
||||
expect(app.floating, ['b', 'c']);
|
||||
expect(_composerFocused(tester, 'c'), isTrue);
|
||||
expect(_workspace(tester).activePane?.sessionId, 'a');
|
||||
expect(tester.takeException(), isNull);
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
testWidgets('a floating chat types, runs its tickers, hides and shows over '
|
||||
'another destination', (tester) async {
|
||||
await _saved('a', 'b');
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_center_stage_controller.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_center_stage_edges.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_center_stage_keys.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_center_stage_layout.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_center_stage_strip.dart';
|
||||
@@ -82,7 +83,10 @@ Widget host(
|
||||
List<KeyEvent>? fieldKeys,
|
||||
bool actionBars = false,
|
||||
bool filesProbe = false,
|
||||
ThemeMode themeMode = ThemeMode.light,
|
||||
}) => MaterialApp(
|
||||
themeMode: themeMode,
|
||||
darkTheme: ThemeData.dark(),
|
||||
home: MediaQuery(
|
||||
data: MediaQueryData(disableAnimations: reduceMotion),
|
||||
child: Scaffold(
|
||||
@@ -410,6 +414,71 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'the stage edges sit in the gaps beside the stage, or on the workspace edge',
|
||||
() {
|
||||
final (left, right) = chatCenterStageEdgeRects(
|
||||
const Rect.fromLTWH(418, 0, 950, 800),
|
||||
const Size(1368, 800),
|
||||
);
|
||||
expect(left, const Rect.fromLTWH(411.5, 0, 1, 800));
|
||||
expect(right, const Rect.fromLTWH(1367, 0, 1, 800));
|
||||
|
||||
// A stage that reaches the workspace's right edge keeps its hairline inside.
|
||||
final (edgeLeft, edgeRight) = chatCenterStageEdgeRects(
|
||||
const Rect.fromLTWH(650, 0, 950, 800),
|
||||
const Size(1600, 800),
|
||||
);
|
||||
expect(edgeLeft, const Rect.fromLTWH(643.5, 0, 1, 800));
|
||||
expect(edgeRight, const Rect.fromLTWH(1599, 0, 1, 800));
|
||||
},
|
||||
);
|
||||
|
||||
for (final mode in [ThemeMode.light, ThemeMode.dark]) {
|
||||
testWidgets(
|
||||
'center stage draws the column edges in the ${mode.name} theme, only on stage',
|
||||
(tester) async {
|
||||
wide(tester);
|
||||
final workspace = threePanes();
|
||||
final stage = ChatCenterStageController(store: _MemoryStore());
|
||||
addTearDown(workspace.dispose);
|
||||
addTearDown(stage.dispose);
|
||||
await tester.pumpWidget(host(workspace, stage, themeMode: mode));
|
||||
await tester.pumpAndSettle();
|
||||
const leftKey = ValueKey('chat-center-stage-edge-left');
|
||||
const rightKey = ValueKey('chat-center-stage-edge-right');
|
||||
expect(find.byKey(leftKey), findsNothing);
|
||||
expect(find.byKey(rightKey), findsNothing);
|
||||
|
||||
stage.value = true;
|
||||
await tester.pumpAndSettle();
|
||||
final outline = Theme.of(
|
||||
tester.element(find.byType(ChatWorkspace)),
|
||||
).colorScheme.outlineVariant;
|
||||
for (final key in [leftKey, rightKey]) {
|
||||
expect(
|
||||
tester
|
||||
.widget<ColoredBox>(
|
||||
find.descendant(
|
||||
of: find.byKey(key),
|
||||
matching: find.byType(ColoredBox),
|
||||
),
|
||||
)
|
||||
.color,
|
||||
outline,
|
||||
);
|
||||
}
|
||||
// The hairlines frame the stage; the reading width is unchanged.
|
||||
expect(widthOf(tester, 'three'), 950);
|
||||
|
||||
stage.value = false;
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(leftKey), findsNothing);
|
||||
expect(find.byKey(rightKey), findsNothing);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('reduced motion stages at once', (tester) async {
|
||||
wide(tester);
|
||||
final workspace = threePanes();
|
||||
|
||||
Reference in New Issue
Block a user