Add desktop navigation rail with Settings
Replace wide-layout floating destination controls with a full-height Material navigation rail, keeping badges and existing navigation behavior. Pin Settings to the rail and preserve the phone layout and pane/window clearance.
This commit is contained in:
@@ -13,9 +13,9 @@ import '../features/pipelines/fixtures.dart';
|
||||
import 'pipelines_app_test.dart' show webServer;
|
||||
import 'pipelines_replies.dart';
|
||||
|
||||
/// Settings is not a tab: it opens as a page from the gear in the Pipelines
|
||||
/// bar, keeps its `/settings` route (and deep link), and closes back to
|
||||
/// Pipelines. The tab bar keeps Pipelines selected meanwhile.
|
||||
/// Settings is not a tab: it opens as a page (from the gear in the Pipelines
|
||||
/// bar on a phone, from the rail's foot on a wide window), keeps its
|
||||
/// `/settings` route (and deep link), and closes back to Pipelines. The tab bar keeps Pipelines selected meanwhile.
|
||||
void main() {
|
||||
Future<PlatformRouteInformationProvider> pumpApp(
|
||||
WidgetTester tester, {
|
||||
@@ -50,7 +50,9 @@ void main() {
|
||||
.widget<FloatingDestinationBar>(find.byType(FloatingDestinationBar))
|
||||
.currentIndex;
|
||||
|
||||
for (final size in [const Size(390, 844), const Size(1200, 800)]) {
|
||||
// A phone's Pipelines bar keeps the gear; a wide window's rail offers
|
||||
// Settings instead (see the wide test below).
|
||||
for (final size in [const Size(390, 844)]) {
|
||||
testWidgets('${size.width}: the Pipelines bar gear opens Settings '
|
||||
'as a page and Back returns', (tester) async {
|
||||
final provider = await pumpApp(
|
||||
@@ -101,6 +103,57 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('1200: the rail offers Settings at its foot and no gear is '
|
||||
'left in the Pipelines toolbar; Settings is a page and Back returns', (
|
||||
tester,
|
||||
) async {
|
||||
final provider = await pumpApp(
|
||||
tester,
|
||||
location: '/pipelines',
|
||||
size: const Size(1200, 800),
|
||||
);
|
||||
expect(find.byType(NavigationRail), findsOneWidget);
|
||||
expect(find.byKey(const Key('pipelines-open-settings')), findsNothing);
|
||||
expect(find.byType(FloatingDestinationBar), findsNothing);
|
||||
final rail = tester.widget<NavigationRail>(find.byType(NavigationRail));
|
||||
expect(rail.selectedIndex, 0);
|
||||
for (final label in ['Pipelines', 'Runs', 'Chat', 'Search', 'Settings']) {
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byType(NavigationRail),
|
||||
matching: find.text(label),
|
||||
),
|
||||
findsOneWidget,
|
||||
reason: label,
|
||||
);
|
||||
}
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.settings')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/settings');
|
||||
expect(find.byType(SettingsScreen), findsOneWidget);
|
||||
// Settings is a page of Pipelines: the rail marks Settings, not a tab.
|
||||
expect(
|
||||
tester.widget<NavigationRail>(find.byType(NavigationRail)).selectedIndex,
|
||||
isNull,
|
||||
);
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('shell.back')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/pipelines');
|
||||
expect(find.byKey(const Key('pipelines-open-settings')), findsNothing);
|
||||
expect(
|
||||
tester.widget<NavigationRail>(find.byType(NavigationRail)).selectedIndex,
|
||||
0,
|
||||
);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets('the /settings deep link opens the Settings page and '
|
||||
'the system Back closes it to Pipelines', (tester) async {
|
||||
final provider = await pumpApp(
|
||||
|
||||
Reference in New Issue
Block a user