Shell: on wide split layouts the destination tabs sit under the list pane
The four destination buttons move from the bottom right over the detail pane to the bottom of the list pane, centred in the (dragged) list width. The list now keeps the bar's height as bottom clearance; the detail pane clears only the system inset, so its tabs, the chat composer and the artifact actions sit at its bottom edge. Phone layout is unchanged. kStackedBarGap is gone with the stacked bars.
This commit is contained in:
@@ -4,13 +4,14 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||
import 'package:pipelines_app/shell/destination.dart';
|
||||
import 'package:pipelines_app/shell/list_detail.dart';
|
||||
import 'package:pipelines_app/shell/list_pane_widths.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||
|
||||
/// While a tab shows its list beside an open item, the shell's destination
|
||||
/// bar keeps its place at the bottom right (near the thumb). The item's own
|
||||
/// bottom control (its tabs, or a composer) floats above it with a gap, and
|
||||
/// the item's content clears both.
|
||||
/// bar moves to the bottom of the list pane, centred in the list's (dragged)
|
||||
/// width. The list clears the bar; the item keeps its whole height, its own
|
||||
/// bottom control (its tabs, or a composer) at its bottom edge.
|
||||
void main() {
|
||||
Future<void> setSize(WidgetTester tester, Size size) async {
|
||||
tester.view.physicalSize = size;
|
||||
@@ -75,9 +76,11 @@ void main() {
|
||||
bool split = true,
|
||||
bool tabs = false,
|
||||
double textScale = 1,
|
||||
ListPaneWidthStore? store,
|
||||
}) {
|
||||
final app = AdaptiveShell(
|
||||
cupertino: cupertino,
|
||||
listPaneWidthStore: store ?? MemoryListPaneWidthStore(),
|
||||
destination: AppDestination.chat,
|
||||
destinationBodies: {
|
||||
AppDestination.chat: (_) => split
|
||||
@@ -109,8 +112,8 @@ void main() {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
for (final width in [1200.0, 1600.0]) {
|
||||
testWidgets('$host $width split: the destination bar stays bottom '
|
||||
'right and the composer floats above it', (tester) async {
|
||||
testWidgets('$host $width split: the destination bar sits under the '
|
||||
'list and the composer at the detail\'s bottom edge', (tester) async {
|
||||
await setSize(tester, Size(width, 800));
|
||||
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||
await tester.pump();
|
||||
@@ -123,29 +126,40 @@ void main() {
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
);
|
||||
final pill = destinationPill(tester);
|
||||
// Compact at the window's right edge, over the detail pane only.
|
||||
expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5));
|
||||
// Centred at the bottom of the list pane, never over the detail.
|
||||
expect(pill.center.dx, closeTo(list.center.dx, 0.5));
|
||||
expect(pill.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
||||
expect(pill.width, lessThan(body.width / 2));
|
||||
expect(pill.overlaps(list), isFalse, reason: 'never over the list');
|
||||
expect(pill.left, greaterThan(body.left));
|
||||
expect(pill.right, lessThanOrEqualTo(list.right));
|
||||
expect(pill.overlaps(body), isFalse, reason: 'never over the detail');
|
||||
expect(
|
||||
pill.width,
|
||||
FloatingDestinationBar.rowWidth(cupertino: cupertino, tabs: 4),
|
||||
);
|
||||
|
||||
// The composer's box starts a gap above the shell's pill (the real
|
||||
// composer pads its pill by another 12 inside that box).
|
||||
// The composer reaches the detail's bottom edge: nothing is reserved
|
||||
// there for the shell's bar any more.
|
||||
final composer = tester.getRect(find.byKey(const Key('composer')));
|
||||
expect(composer.left, body.left);
|
||||
expect(composer.bottom, closeTo(800, 0.5));
|
||||
expect(composer.overlaps(pill), isFalse);
|
||||
expect(pill.top - composer.bottom, closeTo(kStackedBarGap, 0.5));
|
||||
|
||||
// The list is not under the bar: it clears only the system inset.
|
||||
// The list clears the bar, so its last rows scroll out from under it.
|
||||
final listContext = tester.element(find.byKey(const Key('list')));
|
||||
expect(MediaQuery.paddingOf(listContext).bottom, 0);
|
||||
expect(
|
||||
MediaQuery.paddingOf(listContext).bottom,
|
||||
greaterThanOrEqualTo(800 - pill.top),
|
||||
);
|
||||
await tester.drag(
|
||||
find.byKey(const Key('list')),
|
||||
const Offset(0, -4000),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final last = tester.getRect(find.text('row 39'));
|
||||
expect(last.bottom, lessThanOrEqualTo(pill.top));
|
||||
});
|
||||
|
||||
testWidgets('$host $width split: the item tabs float above the '
|
||||
'destination bar with a gap, and its content clears both', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('$host $width split: the item tabs sit at the bottom right '
|
||||
'of the detail, and its content clears only them', (tester) async {
|
||||
await setSize(tester, Size(width, 800));
|
||||
await tester.pumpWidget(shell(cupertino: cupertino, tabs: true));
|
||||
await tester.pump();
|
||||
@@ -163,13 +177,13 @@ void main() {
|
||||
)
|
||||
.first,
|
||||
);
|
||||
expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5));
|
||||
expect(tabs.right, closeTo(width - kFloatingBarMargin, 0.5));
|
||||
expect(tabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
||||
expect(tabs.left, greaterThan(body.left));
|
||||
expect(tabs.overlaps(pill), isFalse);
|
||||
expect(pill.top - tabs.bottom, closeTo(kStackedBarGap, 0.5));
|
||||
expect(pill.right, lessThan(body.left));
|
||||
|
||||
// The item's list pads its end clear of both pills.
|
||||
// The item's list pads its end clear of its own tabs.
|
||||
final listContext = tester.element(
|
||||
find.byKey(const Key('detail-list')),
|
||||
);
|
||||
@@ -180,6 +194,23 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('$host 1200 split: the bar follows a dragged list width', (
|
||||
tester,
|
||||
) async {
|
||||
await setSize(tester, const Size(1200, 800));
|
||||
final store = MemoryListPaneWidthStore({'chat': 300});
|
||||
await tester.pumpWidget(shell(cupertino: cupertino, store: store));
|
||||
await tester.pumpAndSettle();
|
||||
final list = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-list')),
|
||||
);
|
||||
expect(list.width, closeTo(300, 0.5));
|
||||
final pill = destinationPill(tester);
|
||||
expect(pill.center.dx, closeTo(list.center.dx, 0.5));
|
||||
expect(pill.left, greaterThanOrEqualTo(kFloatingBarMargin - 0.5));
|
||||
expect(pill.right, lessThanOrEqualTo(list.right - kFloatingBarMargin));
|
||||
});
|
||||
|
||||
testWidgets('$host 1200 unsplit: the bar is compact at the right edge', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -205,8 +236,8 @@ void main() {
|
||||
});
|
||||
|
||||
for (final width in [600.0, 840.0]) {
|
||||
testWidgets('$host $width split at 2x: both bars lay out over the '
|
||||
'detail pane without overflow', (tester) async {
|
||||
testWidgets('$host $width split at 2x: the bar fits the list pane and '
|
||||
'the item tabs the detail, without overflow', (tester) async {
|
||||
await setSize(tester, Size(width, 800));
|
||||
await tester.pumpWidget(
|
||||
shell(cupertino: cupertino, tabs: true, textScale: 2),
|
||||
@@ -214,12 +245,12 @@ void main() {
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(tester.takeException(), isNull);
|
||||
final body = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
final list = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-list')),
|
||||
);
|
||||
final pill = destinationPill(tester);
|
||||
expect(pill.left, greaterThanOrEqualTo(body.left));
|
||||
expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5));
|
||||
expect(pill.left, greaterThanOrEqualTo(list.left));
|
||||
expect(pill.right, lessThanOrEqualTo(list.right));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user