From 821d1a8836404ccc35be4ff2504505b5155c0734 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Sun, 1 Nov 2026 02:05:06 +0000 Subject: [PATCH] Keep pager controls clear of floating bars --- .../artifacts/ui/artifact_viewer_body.dart | 77 ++++++++++--------- .../changes/widgets/changes_viewer.dart | 24 ++++-- .../ui/artifact_viewer_page_test.dart | 49 +++++++++++- .../features/changes/visit_paging_test.dart | 29 +++++++ 4 files changed, 134 insertions(+), 45 deletions(-) diff --git a/app/lib/features/artifacts/ui/artifact_viewer_body.dart b/app/lib/features/artifacts/ui/artifact_viewer_body.dart index 2d962a15..d18bca5a 100644 --- a/app/lib/features/artifacts/ui/artifact_viewer_body.dart +++ b/app/lib/features/artifacts/ui/artifact_viewer_body.dart @@ -101,45 +101,48 @@ class ArtifactViewerBody extends StatelessWidget { // no empty glass bar, and no bottom clearance reserved for one. if (resolved == null && count <= 1) return swipe; return FloatingBarOverlay( - bar: SafeArea( - top: false, - minimum: const EdgeInsets.all(8), - child: SizedBox( - height: 56, - child: GlassPill( - cupertino: usesCupertinoHost(context), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2), - child: Row( - key: const Key('artifact-viewer-actions'), - children: [ - if (resolved != null && !resolved.external) - ArtifactFileActions( - key: ValueKey( - 'viewer-files-${page.group.stageKey}\u0000' - '${page.group.visit}\u0000${page.artifact.url}', + bar: Padding( + padding: withFloatingBarClearance(context, EdgeInsets.zero), + child: SafeArea( + top: false, + minimum: const EdgeInsets.all(8), + child: SizedBox( + height: 56, + child: GlassPill( + cupertino: usesCupertinoHost(context), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2), + child: Row( + key: const Key('artifact-viewer-actions'), + children: [ + if (resolved != null && !resolved.external) + ArtifactFileActions( + key: ValueKey( + 'viewer-files-${page.group.stageKey}\u0000' + '${page.group.visit}\u0000${page.artifact.url}', + ), + artifact: page.artifact, + resolved: resolved, + fetch: fetch, + bridge: fileBridge, + compact: true, + ), + if (resolved != null) + _Actions( + resolved: resolved, + onOpen: onOpen, + onCopy: onCopy, + ), + Expanded( + child: _Pager( + index: index, + count: count, + onPrevious: onPrevious, + onNext: onNext, ), - artifact: page.artifact, - resolved: resolved, - fetch: fetch, - bridge: fileBridge, - compact: true, ), - if (resolved != null) - _Actions( - resolved: resolved, - onOpen: onOpen, - onCopy: onCopy, - ), - Expanded( - child: _Pager( - index: index, - count: count, - onPrevious: onPrevious, - onNext: onNext, - ), - ), - ], + ], + ), ), ), ), diff --git a/app/lib/features/changes/widgets/changes_viewer.dart b/app/lib/features/changes/widgets/changes_viewer.dart index 49c22eb4..a3314f86 100644 --- a/app/lib/features/changes/widgets/changes_viewer.dart +++ b/app/lib/features/changes/widgets/changes_viewer.dart @@ -231,12 +231,24 @@ class _ChangesViewerState extends State { alignment: AlignmentDirectional.centerEnd, heightFactor: 1, widthFactor: 1, - child: Padding( - padding: const EdgeInsets.all(8), - child: IntrinsicWidth( - child: GlassPill( - cupertino: usesCupertinoHost(context), - child: pager, + child: MediaQuery.removePadding( + context: context, + removeBottom: true, + child: Padding( + // The inherited bottom inset belongs to the shell bar. Include it + // in this overlay's measured bar height so the pager is stacked + // above it rather than translating into a constrained layout. + padding: EdgeInsets.only( + bottom: MediaQuery.paddingOf(context).bottom, + ), + child: Padding( + padding: const EdgeInsets.all(8), + child: IntrinsicWidth( + child: GlassPill( + cupertino: usesCupertinoHost(context), + child: pager, + ), + ), ), ), ), diff --git a/app/test/features/artifacts/ui/artifact_viewer_page_test.dart b/app/test/features/artifacts/ui/artifact_viewer_page_test.dart index adc7c35d..dd3e675d 100644 --- a/app/test/features/artifacts/ui/artifact_viewer_page_test.dart +++ b/app/test/features/artifacts/ui/artifact_viewer_page_test.dart @@ -45,6 +45,7 @@ Future _pumpViewer( ArtifactFetch? fetch, Widget Function(BuildContext, String)? markdownBuilder, ArtifactExternalOpen? openExternal, + double bottomClearance = 0, }) async { final page = ArtifactViewerPage( groups: groups, @@ -55,10 +56,14 @@ Future _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( diff --git a/app/test/features/changes/visit_paging_test.dart b/app/test/features/changes/visit_paging_test.dart index bc0ae765..b8013e7c 100644 --- a/app/test/features/changes/visit_paging_test.dart +++ b/app/test/features/changes/visit_paging_test.dart @@ -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())));