109ea72252
ListDetailPanes takes listHidden and slides the list to zero width (at once with reduced motion), keeping its expanded or compact mode for when it comes back. A wide chat offers Hide chat list in the list's bar and the pane menu, Ctrl+B (Cmd+B on Apple; a focused terminal keeps Ctrl+B) and, while hidden, a Show chat list button at the start of the top-left pane's bar. The choice is device-local (pipelines.chat.listHidden.v1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
74 lines
2.5 KiB
Dart
74 lines
2.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/shell/list_detail.dart';
|
|
import 'package:pipelines_app/shell/list_pane_divider.dart';
|
|
|
|
final _body = find.byKey(const ValueKey('list-detail-body'));
|
|
|
|
Widget _panes({required bool hidden, bool reduceMotion = false}) => MaterialApp(
|
|
home: Builder(
|
|
builder: (context) => MediaQuery(
|
|
data: MediaQuery.of(context).copyWith(disableAnimations: reduceMotion),
|
|
child: Scaffold(
|
|
body: ListDetailPanes(
|
|
listHidden: hidden,
|
|
list: const Focus(
|
|
autofocus: true,
|
|
child: Text('The list', key: Key('list-text')),
|
|
),
|
|
detail: const SizedBox.expand(),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
void _size(WidgetTester tester) {
|
|
tester.view.physicalSize = const Size(1200, 800);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
}
|
|
|
|
void main() {
|
|
testWidgets('a hidden list slides to zero width and comes back as it was', (
|
|
tester,
|
|
) async {
|
|
_size(tester);
|
|
await tester.pumpWidget(_panes(hidden: false));
|
|
await tester.pumpAndSettle();
|
|
final shown = tester.getRect(_body).left;
|
|
expect(shown, greaterThan(200));
|
|
expect(find.byType(ListPaneDivider), findsOneWidget);
|
|
|
|
await tester.pumpWidget(_panes(hidden: true));
|
|
await tester.pump(const Duration(milliseconds: 60));
|
|
final sliding = tester.getRect(_body).left;
|
|
expect(sliding, inExclusiveRange(0, shown), reason: 'animates');
|
|
// The handle is not offered while the list slides or is hidden.
|
|
expect(find.byType(ListPaneDivider), findsNothing);
|
|
await tester.pumpAndSettle();
|
|
expect(tester.getRect(_body).left, 0);
|
|
expect(tester.getRect(_body).width, 1200);
|
|
// Nothing in the hidden list keeps the keyboard.
|
|
final listFocus = Focus.of(
|
|
tester.element(find.byKey(const Key('list-text'))),
|
|
);
|
|
expect(listFocus.hasFocus, isFalse);
|
|
|
|
await tester.pumpWidget(_panes(hidden: false));
|
|
await tester.pumpAndSettle();
|
|
expect(tester.getRect(_body).left, shown);
|
|
expect(find.byType(ListPaneDivider), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('with reduced motion the list hides at once', (tester) async {
|
|
_size(tester);
|
|
await tester.pumpWidget(_panes(hidden: false, reduceMotion: true));
|
|
await tester.pumpAndSettle();
|
|
await tester.pumpWidget(_panes(hidden: true, reduceMotion: true));
|
|
await tester.pump();
|
|
await tester.pump();
|
|
expect(tester.getRect(_body).left, 0);
|
|
});
|
|
}
|