Keep pager controls clear of floating bars

This commit is contained in:
2026-11-01 02:05:06 +00:00
parent f422d26e32
commit 821d1a8836
4 changed files with 134 additions and 45 deletions
@@ -45,6 +45,7 @@ Future<void> _pumpViewer(
ArtifactFetch? fetch,
Widget Function(BuildContext, String)? markdownBuilder,
ArtifactExternalOpen? openExternal,
double bottomClearance = 0,
}) async {
final page = ArtifactViewerPage(
groups: groups,
@@ -55,10 +56,14 @@ Future<void> _pumpViewer(
markdownBuilder ?? (context, value) => SelectableText(value),
openExternal: openExternal ?? (_) async => true,
);
final child = MediaQuery(
data: MediaQueryData(padding: EdgeInsets.only(bottom: bottomClearance)),
child: page,
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: page)
: MaterialApp(home: Scaffold(body: page)),
? CupertinoApp(home: child)
: MaterialApp(home: Scaffold(body: child)),
);
await tester.pumpAndSettle();
}
@@ -686,6 +691,46 @@ void main() {
}
});
for (final cupertino in [false, true]) {
for (final size in [
const Size(390, 844),
const Size(880, 1000),
const Size(1100, 800),
]) {
testWidgets(
'${cupertino ? 'Cupertino' : 'Material'} pager clears stacked bar at $size',
(tester) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final first = recordedArtifact(
'a.png',
url: '/artifacts/1/1/a.png',
contentType: 'image/png',
);
final second = recordedArtifact(
'b.png',
url: '/artifacts/1/2/b.png',
contentType: 'image/png',
);
final groups = [
_group([first], visit: 1),
_group([second], visit: 2),
];
await _pumpViewer(
tester,
groups: groups,
selected: artifactVisitIdentity(groups[0], first),
cupertino: cupertino,
bottomClearance: 120,
);
final pager = tester.getRect(find.byKey(artifactNextKey));
expect(pager.bottom, lessThanOrEqualTo(size.height - 120));
},
);
}
}
testWidgets('Escape closes the viewer back to the gallery', (tester) async {
await tester.pumpWidget(
MaterialApp(
@@ -85,6 +85,35 @@ void main() {
expect(next.bottom, greaterThan(844 - 80));
});
for (final host in ['Material', 'Cupertino']) {
for (final size in [
const Size(390, 844),
const Size(880, 1000),
const Size(1100, 800),
]) {
testWidgets('$host pager clears an inherited stacked bar at $size', (
tester,
) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final child = ChangesViewer(steps: twoVisitRun());
final hosted = host == 'Material'
? materialHost(child)
: cupertinoHost(child);
await tester.pumpWidget(
MediaQuery(
data: const MediaQueryData(padding: EdgeInsets.only(bottom: 120)),
child: hosted,
),
);
await tester.pump();
final pager = tester.getRect(find.byKey(ChangesVisitPager.nextKey));
expect(pager.bottom, lessThanOrEqualTo(size.height - 120));
});
}
}
testWidgets('paging stops at both ends instead of wrapping', (tester) async {
await tester.pumpWidget(materialHost(ChangesViewer(steps: twoVisitRun())));