Lay out phone content above navigation bar
Use the phone NavigationBar as a real Scaffold bottom slot so destination content ends at the bar rather than scrolling beneath it. Update shell regression coverage and document the focused verification.
This commit is contained in:
@@ -232,8 +232,8 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
// A phone (narrower than the list-detail split) gets a full-width Material
|
||||
// NavigationBar at the bottom, with Settings as its last destination. Wider
|
||||
// windows without the rail keep the floating glass tab bar, which the list
|
||||
// beside an open item needs (see below). Content keeps the whole width and
|
||||
// scrolls behind the bar, learning its height as its bottom media padding.
|
||||
// beside an open item needs (see below). On phones the NavigationBar is a
|
||||
// real Scaffold bottom child, so content is laid out above its surface.
|
||||
// Neither scaffold's structure depends on the width, so resizing never
|
||||
// remounts a destination. Pushed detail routes cover the shell, and a
|
||||
// bar-less spec (a chat workspace) hides the bar.
|
||||
@@ -272,9 +272,9 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
);
|
||||
},
|
||||
);
|
||||
// Destinations reach the top edge and scroll behind the floating top
|
||||
// bar too: each learns the bar's height as its top media padding and
|
||||
// pads its own lists by it (see withTopBarClearance).
|
||||
// Destinations may still reach the top edge and scroll behind the floating
|
||||
// top bar; the bottom phone bar is different because Scaffold reserves its
|
||||
// complete height rather than overlaying the body.
|
||||
SegmentedBar currentBar() =>
|
||||
_segmentedBar(_bar.specFor(_selected), details.label, page: page);
|
||||
final topBar = _ListPaneBar(
|
||||
@@ -317,7 +317,11 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: topBar,
|
||||
body: _destinationStack(contents),
|
||||
extendBody: true,
|
||||
// Only phone destinations use the Scaffold's real bottom slot. The
|
||||
// narrow tablet layout keeps its existing floating bar over the body.
|
||||
// The NavigationBar owns its SafeArea and therefore also owns the
|
||||
// system gesture inset at the bottom.
|
||||
extendBody: !phone,
|
||||
bottomNavigationBar: rail ? null : bar,
|
||||
);
|
||||
return backable(
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# Phone content ends above the bottom bar
|
||||
|
||||
Changed the adaptive shell to use the phone `NavigationBar` as a real
|
||||
`Scaffold.bottomNavigationBar` without `extendBody`, so destination content is
|
||||
constrained above the opaque bar and its system safe-area inset. The existing
|
||||
floating bar keeps `extendBody` on the narrow tablet layout, preserving its
|
||||
overlay composition; rail layouts are unchanged.
|
||||
|
||||
Added a widget regression asserting that a phone destination body's bottom edge
|
||||
equals the navigation bar's top edge.
|
||||
|
||||
Focused verification:
|
||||
|
||||
- `tool/memwatch/full.sh 'test/shell/shell_navigation_bar_test.dart test/shell/floating_tab_bar_test.dart'` — 15 passed.
|
||||
- `tool/analyze.sh` — clean.
|
||||
|
||||
Browser/device captures were not run in this implementation stage.
|
||||
@@ -139,24 +139,24 @@ void main() {
|
||||
expect(find.text('Chat — Not implemented'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('content learns the bar height as bottom padding', (
|
||||
tester,
|
||||
) async {
|
||||
for (final size in const [Size(390, 844), Size(640, 800)]) {
|
||||
await setSize(tester, size);
|
||||
await tester.pumpWidget(shell());
|
||||
await tester.pump();
|
||||
final rect = size.width < 600
|
||||
? tester.getRect(find.byType(NavigationBar))
|
||||
: tester.getRect(pill());
|
||||
// The content's bottom padding clears the whole bar and its margin.
|
||||
expect(
|
||||
contentBottomPadding,
|
||||
moreOrLessEquals(size.height - rect.top, epsilon: 0.5),
|
||||
reason: '$size',
|
||||
);
|
||||
}
|
||||
});
|
||||
testWidgets(
|
||||
'phone content has no floating-bar padding; tablet content does',
|
||||
(tester) async {
|
||||
for (final size in const [Size(390, 844), Size(640, 800)]) {
|
||||
await setSize(tester, size);
|
||||
await tester.pumpWidget(shell());
|
||||
await tester.pump();
|
||||
final rect = size.width < 600
|
||||
? tester.getRect(find.byType(NavigationBar))
|
||||
: tester.getRect(pill());
|
||||
expect(
|
||||
contentBottomPadding,
|
||||
size.width < 600 ? 0 : size.height - rect.top,
|
||||
reason: '$size',
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('resizing moves the bar without remounting content', (
|
||||
tester,
|
||||
|
||||
@@ -70,6 +70,24 @@ void main() {
|
||||
expect(tester.widget<NavigationBar>(bar()).selectedIndex, 4);
|
||||
});
|
||||
|
||||
testWidgets('the phone destination body ends at the bar top', (tester) async {
|
||||
await pumpPhone(
|
||||
tester,
|
||||
bodies: {
|
||||
AppDestination.pipelines: (_) => const ColoredBox(
|
||||
key: ValueKey('phone.destination-body'),
|
||||
color: Colors.red,
|
||||
),
|
||||
},
|
||||
);
|
||||
|
||||
final body = tester.getRect(
|
||||
find.byKey(const ValueKey('phone.destination-body')),
|
||||
);
|
||||
final navigationBar = tester.getRect(bar());
|
||||
expect(body.bottom, navigationBar.top);
|
||||
});
|
||||
|
||||
testWidgets('a tap shows its destination, and a re-tap of the shown one '
|
||||
'still reports it to the shell', (tester) async {
|
||||
final selected = <AppDestination>[];
|
||||
|
||||
Reference in New Issue
Block a user