Add phone bottom navigation bar

Replace the narrow-layout floating destination pill with a full-width Material 3 NavigationBar. Reuse the shell destination model and badge wiring while preserving re-selection callbacks and hiding the bar for keyboard/detail states.
This commit is contained in:
2026-11-12 02:51:01 +00:00
parent 9bb87e5118
commit aabd22b5ad
12 changed files with 467 additions and 126 deletions
+30 -35
View File
@@ -3,6 +3,7 @@ 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/shell_bar.dart';
import 'package:pipelines_app/shell/shell_navigation_bar.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
Widget _app({required bool open, VoidCallback? back}) {
@@ -45,7 +46,7 @@ void main() {
expect(find.byKey(const Key('run-more')), findsNothing);
});
testWidgets('Search is the fourth tab; Settings is not a tab', (
testWidgets('Search is the fourth tab; Settings is the bar\'s last item', (
tester,
) async {
tester.view.physicalSize = const Size(390, 844);
@@ -65,50 +66,47 @@ void main() {
);
expect(
find.byKey(const ValueKey('shell.destination.settings')),
findsNothing,
findsOneWidget,
);
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
expect(find.byType(FloatingDestinationBar), findsOneWidget);
expect(find.byType(NavigationBar), findsOneWidget);
expect(find.byType(FloatingDestinationBar), findsNothing);
});
testWidgets('floating tabs stay inset and select destinations', (
tester,
) async {
testWidgets('the phone bar is a full-width navigation bar that selects '
'destinations', (tester) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(_app(open: false));
final destinationPill = find.descendant(
of: find.byType(FloatingDestinationBar),
matching: find.byKey(FloatingDestinationBar.rowKey),
);
// Visible captions determine the width while full-size targets stay inset.
final rect = tester.getRect(destinationPill);
expect(rect.width, lessThanOrEqualTo(390 - 2 * 16));
final bar = find.byType(NavigationBar);
final rect = tester.getRect(bar);
expect(rect.left, 0);
expect(rect.right, 390);
expect(rect.bottom, 844);
expect(
tester
.widget<FloatingDestinationBar>(find.byType(FloatingDestinationBar))
.showLabels,
isTrue,
tester.widget<NavigationBar>(bar).destinations,
hasLength(shellBarDestinations.length),
);
for (final destination in shellTabDestinations) {
final caption = find.descendant(
of: find.byType(FloatingDestinationBar),
matching: find.text(destinationDetails(destination).label),
expect(tester.widget<NavigationBar>(bar).selectedIndex, 1);
for (var index = 0; index < shellBarDestinations.length; index++) {
final label = destinationDetails(shellBarDestinations[index]).label;
expect(
find.descendant(of: bar, matching: find.text(label)),
findsOneWidget,
);
expect(caption, findsOneWidget);
expect(rect.contains(tester.getRect(caption).center), isTrue);
// Each destination's whole slot is its target, not just the icon.
final target = tester.getSize(
find.byKey(ValueKey('shell.destination.${destination.name}')),
find.byType(NavigationDestination).at(index),
);
expect(target.width, greaterThanOrEqualTo(44));
expect(target.height, greaterThanOrEqualTo(44));
expect(target.width, greaterThanOrEqualTo(44), reason: label);
expect(target.height, greaterThanOrEqualTo(44), reason: label);
}
expect(tester.getRect(destinationPill).right, 390 - 16);
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
await tester.pump();
expect(find.text('Chat — Not implemented'), findsOneWidget);
expect(tester.widget<NavigationBar>(bar).selectedIndex, 2);
});
testWidgets('tabs show the running and unread counts their screens publish', (
@@ -163,7 +161,7 @@ void main() {
),
);
await tester.pumpWidget(shell());
expect(find.byType(FloatingDestinationBar), findsOneWidget);
expect(find.byType(NavigationBar), findsOneWidget);
final navigator = tester.state<NavigatorState>(find.byType(Navigator));
navigator.push(
MaterialPageRoute<void>(
@@ -171,16 +169,13 @@ void main() {
),
);
await tester.pumpAndSettle();
expect(find.byType(FloatingDestinationBar), findsNothing);
expect(
find.byType(FloatingDestinationBar, skipOffstage: false),
findsOneWidget,
);
expect(find.byType(NavigationBar), findsNothing);
expect(find.byType(NavigationBar, skipOffstage: false), findsOneWidget);
await navigator.maybePop();
await tester.pump(const Duration(milliseconds: 16));
expect(find.byType(FloatingDestinationBar), findsOneWidget);
expect(find.byType(NavigationBar), findsOneWidget);
await tester.pumpAndSettle();
expect(find.byType(FloatingDestinationBar), findsOneWidget);
expect(find.byType(NavigationBar), findsOneWidget);
},
);
}