Keep the shell tab bar over the list pane on wide splits; cap schedules and reading bodies; share the empty-pane placeholder

This commit is contained in:
2026-10-31 12:09:47 +00:00
parent 06f6eda360
commit 2c4c4891ea
24 changed files with 851 additions and 154 deletions
@@ -0,0 +1,52 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/empty_detail_pane.dart';
/// One placeholder for an empty detail pane: the destination's icon above a
/// short muted line, centred, on both hosts.
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
for (final destination in [
AppDestination.runs,
AppDestination.chat,
AppDestination.pipelines,
]) {
testWidgets('$host ${destination.name}: icon over a muted line', (
tester,
) async {
final content = EmptyDetailPane(
destination: destination,
message: 'Select one to open it here.',
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: content))
: MaterialApp(home: Scaffold(body: content)),
);
final details = destinationDetails(destination);
final icon = find.byIcon(
cupertino ? details.cupertinoIcon : details.icon,
);
expect(icon, findsOneWidget);
final text = find.text('Select one to open it here.');
expect(
tester.getTopLeft(text).dy,
greaterThan(tester.getRect(icon).bottom),
);
// Centred in the pane.
final size = tester.view.physicalSize / tester.view.devicePixelRatio;
expect(tester.getCenter(text).dx, closeTo(size.width / 2, 1));
// Muted: the same secondary colour on the icon and the line.
final context = tester.element(text);
final muted = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
expect(tester.widget<Icon>(icon).color, muted);
expect(tester.widget<Text>(text).style?.color, muted);
});
}
}
}
@@ -0,0 +1,151 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
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/ui/adaptive/floating_bar_layout.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
/// While a tab shows its list beside an open item, the shell's destination
/// bar floats over the list pane only: it never covers the item, and the
/// item's own bottom control (a composer) owns the pane's bottom edge.
void main() {
Future<void> setSize(WidgetTester tester, Size size) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
}
/// A detail whose composer sits at the bottom, padded by the media inset
/// the way the chat composer is.
Widget composerDetail() => Builder(
builder: (context) => Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: EdgeInsets.only(bottom: MediaQuery.paddingOf(context).bottom),
child: const SizedBox(
key: Key('composer'),
height: 56,
width: double.infinity,
),
),
),
);
Widget listBody() => Builder(
builder: (context) => ListView(
key: const Key('list'),
children: [
for (var index = 0; index < 40; index++)
SizedBox(height: 40, child: Text('row $index')),
],
),
);
Widget shell({
required bool cupertino,
bool split = true,
double textScale = 1,
}) {
final app = AdaptiveShell(
cupertino: cupertino,
destination: AppDestination.chat,
destinationBodies: {
AppDestination.chat: (_) => split
? ListDetailPanes(list: listBody(), detail: composerDetail())
: listBody(),
},
);
return MediaQuery(
data: MediaQueryData.fromView(
WidgetsBinding.instance.platformDispatcher.views.first,
).copyWith(textScaler: TextScaler.linear(textScale)),
child: cupertino ? CupertinoApp(home: app) : MaterialApp(home: app),
);
}
Rect destinationPill(WidgetTester tester) => tester.getRect(
find
.ancestor(
of: find.byKey(const ValueKey('shell.destination.chat')).first,
matching: find.byType(GlassPill),
)
.first,
);
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
for (final width in [1200.0, 1600.0]) {
testWidgets('$host $width split: the destination bar stays over the '
'list pane and the composer owns the detail bottom', (tester) async {
await setSize(tester, Size(width, 800));
await tester.pumpWidget(shell(cupertino: cupertino));
await tester.pump();
await tester.pump();
final list = tester.getRect(
find.byKey(const ValueKey('list-detail-list')),
);
final body = tester.getRect(
find.byKey(const ValueKey('list-detail-body')),
);
final pill = destinationPill(tester);
expect(pill.right, lessThanOrEqualTo(list.right));
expect(pill.left, greaterThanOrEqualTo(list.left));
expect(pill.overlaps(body), isFalse, reason: 'no overlap with detail');
expect(pill.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
// The detail keeps only the system inset (none here): its composer
// reaches the bottom edge, below the level of the shell's pill.
final composer = tester.getRect(find.byKey(const Key('composer')));
expect(composer.bottom, 800);
expect(composer.left, body.left);
expect(composer.top, greaterThan(pill.top));
// The list still clears the bar.
final listContext = tester.element(find.byKey(const Key('list')));
expect(
MediaQuery.paddingOf(listContext).bottom,
greaterThanOrEqualTo(pill.height),
);
});
}
testWidgets('$host 1200 unsplit: the bar is compact at the right edge', (
tester,
) async {
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino: cupertino, split: false));
await tester.pump();
final pill = destinationPill(tester);
expect(pill.right, closeTo(1200 - kFloatingBarMargin, 0.5));
expect(pill.width, lessThan(1200 * 0.6));
});
testWidgets('$host 390: the bar spans the phone', (tester) async {
await setSize(tester, const Size(390, 844));
await tester.pumpWidget(shell(cupertino: cupertino, split: false));
await tester.pump();
final pill = destinationPill(tester);
expect(pill.left, closeTo(kFloatingBarMargin, 0.5));
expect(pill.right, closeTo(390 - kFloatingBarMargin, 0.5));
});
for (final width in [600.0, 840.0]) {
testWidgets('$host $width split at 2x: the narrow list pane bar lays '
'out without overflow', (tester) async {
await setSize(tester, Size(width, 800));
await tester.pumpWidget(shell(cupertino: cupertino, textScale: 2));
await tester.pump();
await tester.pump();
expect(tester.takeException(), isNull);
final list = tester.getRect(
find.byKey(const ValueKey('list-detail-list')),
);
expect(destinationPill(tester).right, lessThanOrEqualTo(list.right));
});
}
}
}