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:
2026-11-12 02:27:41 +00:00
parent 17af656f00
commit 547d15c842
24 changed files with 835 additions and 90 deletions
+6 -3
View File
@@ -22,13 +22,16 @@ void main() {
}
for (final width in [390.0, 1000.0]) {
final mount = width < 600 ? 'bottom bar' : 'wide bar';
final mount = width < 600 ? 'bottom bar' : 'rail';
// The rail (wide) or the floating bar (phone) carries the same counts.
final navigation = width < 600
? find.byType(FloatingDestinationBar)
: find.byType(NavigationRail);
testWidgets('$mount shows the count on the Runs tab', (tester) async {
final semantics = tester.ensureSemantics();
await pumpShell(tester, width: width, count: 3);
expect(find.byType(FloatingDestinationBar), findsOneWidget);
expect(find.byType(NavigationRail), findsNothing);
expect(navigation, findsOneWidget);
final badge = find.byKey(const ValueKey('shell.badge.runs.running'));
expect(badge, findsOneWidget);
expect(
+8 -7
View File
@@ -110,22 +110,23 @@ void main() {
testWidgets('wide leading bar under the list, content '
'keeps the width and taps beside the bar reach it', (tester) async {
taps = 0;
await setSize(tester, const Size(1200, 800));
await setSize(tester, const Size(640, 800));
await tester.pumpWidget(shell());
final rect = tester.getRect(pill());
// With no item open the bar still sits under the list column, where it
// sits beside an open item, so it never jumps sides.
expect(rect.left, moreOrLessEquals(kFloatingBarMargin, epsilon: 0.5));
expect(rect.bottom, 800 - 16);
expect(rect.width, lessThan(1200 * 0.6));
expect(rect.width, lessThan(640 * 0.6));
// Captions participate in the bar's content-driven width.
await expectLabeledTargets(tester, rect);
await expectNoSharedBackdrop(tester);
expect(
rect.width,
lessThanOrEqualTo(listDetailListWidth(1200, 1200, null) - 2 * 16),
lessThanOrEqualTo(listDetailListWidth(640, 640, null) - 2 * 16),
);
// No rail or sidebar: the content starts at the left edge.
// Below the rail's window width (see kNavigationRailMinWindowWidth) the
// floating bar still sits under the list: no rail, content at the left edge.
expect(find.byType(NavigationRail), findsNothing);
expect(tester.getRect(find.byKey(const Key('content'))).left, 0);
// Beside the bar, at the bar's height, the content takes the tap.
@@ -141,7 +142,7 @@ void main() {
testWidgets('content learns the bar height as bottom padding', (
tester,
) async {
for (final size in const [Size(390, 844), Size(1200, 800)]) {
for (final size in const [Size(390, 844), Size(640, 800)]) {
await setSize(tester, size);
await tester.pumpWidget(shell());
await tester.pump();
@@ -166,13 +167,13 @@ void main() {
expect(find.text('taps 1'), findsOneWidget);
final state = tester.state(find.byType(StatefulBuilder));
tester.view.physicalSize = const Size(1200, 800);
tester.view.physicalSize = const Size(640, 800);
await tester.pump();
expect(
tester.getRect(pill()).left,
moreOrLessEquals(kFloatingBarMargin, epsilon: 0.5),
);
expect(tester.getRect(pill()).width, lessThan(1200 * 0.6));
expect(tester.getRect(pill()).width, lessThan(640 * 0.6));
expect(tester.state(find.byType(StatefulBuilder)), same(state));
tester.view.physicalSize = const Size(390, 844);
+14 -7
View File
@@ -8,6 +8,7 @@ import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/list_detail.dart';
import 'package:pipelines_app/shell/list_pane_divider.dart';
import 'package:pipelines_app/shell/list_pane_widths.dart';
import 'package:pipelines_app/shell/navigation_rail.dart';
import 'package:pipelines_app/shell/shell_bar.dart';
import 'package:pipelines_app/ui/adaptive/resize_grip.dart';
@@ -66,6 +67,7 @@ void main() {
testWidgets('dragging resizes the list live, the shell bar '
'follows, and the width clamps', (tester) async {
await setSize(tester, const Size(1200, 800));
const body = 1200 - kNavigationRailSpace;
final store = MemoryListPaneWidthStore();
await tester.pumpWidget(shell(store: store));
await settle(tester);
@@ -79,7 +81,7 @@ void main() {
// Live, before the drag ends; nothing saved yet.
expect(listWidth(tester), closeTo(340, 0.5));
expect(shellBarWidth(tester), closeTo(340, 0.5));
expect(bodyWidth(tester), closeTo(1200 - 1 - 340, 0.5));
expect(bodyWidth(tester), closeTo(body - 1 - 340, 0.5));
expect(store.values, isEmpty);
await gesture.up();
await tester.pump();
@@ -92,9 +94,10 @@ void main() {
// ...nor wider than leaves the open item half the window.
await tester.drag(divider, const Offset(900, 0));
await settle(tester);
expect(listWidth(tester), closeTo(1200 - 1 - 600, 0.5));
expect(shellBarWidth(tester), closeTo(599, 0.5));
expect(store.values['runs'], closeTo(599, 0.5));
// Half of the body for the open item, the list the rest.
expect(listWidth(tester), closeTo(body - 1 - body * 0.5, 0.5));
expect(shellBarWidth(tester), closeTo(body - 1 - body * 0.5, 0.5));
expect(store.values['runs'], closeTo(body - 1 - body * 0.5, 0.5));
});
testWidgets('a double tap returns to the default policy', (tester) async {
@@ -143,8 +146,11 @@ void main() {
final store = MemoryListPaneWidthStore({'runs': 600});
await tester.pumpWidget(shell(store: store));
await settle(tester);
expect(listWidth(tester), closeTo(1000 - 1 - 500, 0.5));
expect(shellBarWidth(tester), closeTo(499, 0.5));
// Beside the destination rail the panes lay out in the window's width
// less the rail, so the clamp is the body's: half of it for the open item.
const body = 1000 - kNavigationRailSpace;
expect(listWidth(tester), closeTo(body - 1 - body * 0.5, 0.5));
expect(shellBarWidth(tester), closeTo(body - 1 - body * 0.5, 0.5));
expect(store.values['runs'], 600);
await setSize(tester, const Size(1600, 800));
@@ -212,7 +218,8 @@ void main() {
expect(grip().emphasized, isFalse);
Focus.of(tester.element(divider)).requestFocus();
await tester.pump();
// The focus change reaches the grip one frame later beside the rail.
await tester.pumpAndSettle();
expect(grip().emphasized, isTrue);
});
+283
View File
@@ -0,0 +1,283 @@
import 'dart:ui' show Tristate;
import 'package:flutter/material.dart';
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/list_detail.dart';
import 'package:pipelines_app/shell/navigation_rail.dart';
import 'package:pipelines_app/shell/shell_bar.dart';
import 'package:pipelines_app/shell/windows/window_host.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'windows/window_test_harness.dart';
/// On a wide window the destinations sit in a Material navigation rail at the
/// left edge (Settings pinned to its foot); narrower windows keep the floating
/// bar. The rail keeps the badges and the keys of the bar it replaces.
void main() {
Future<void> pumpShell(
WidgetTester tester, {
required double width,
double height = 800,
int runningRunCount = 0,
bool withPanes = false,
}) async {
tester.view.physicalSize = Size(width, height);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final shell = AdaptiveShell(
destination: withPanes ? AppDestination.runs : AppDestination.pipelines,
runningRunCount: runningRunCount,
destinationBodies: {
AppDestination.pipelines: (_) => const Text('pipelines body'),
AppDestination.runs: (_) => withPanes
? ListDetailPanes(
list: const ShellBar(child: Text('runs list')),
detail: const Center(child: Text('runs detail')),
)
: const Text('runs body'),
AppDestination.chat: (_) => const Text('chat body'),
AppDestination.search: (_) => const Text('search body'),
AppDestination.settings: (_) => const Text('settings body'),
},
);
await tester.pumpWidget(MaterialApp(home: shell));
await tester.pumpAndSettle();
}
Finder rail() => find.byType(NavigationRail);
Finder inRail(Finder finder) => find.descendant(of: rail(), matching: finder);
testWidgets('a wide window shows a labelled rail at the left edge, full '
'height, with Settings pinned to its foot', (tester) async {
await pumpShell(tester, width: 1000);
expect(rail(), findsOneWidget);
expect(find.byType(FloatingDestinationBar), findsNothing);
for (final label in ['Pipelines', 'Runs', 'Chat', 'Search', 'Settings']) {
expect(inRail(find.text(label)), findsOneWidget, reason: label);
}
final railRect = tester.getRect(rail());
expect(railRect.left, 0);
expect(railRect.top, 0);
expect(railRect.height, 800);
expect(railRect.width, kNavigationRailWidth);
// Settings sits below every tab, at the bottom of the rail.
final settings = tester.getRect(
find.byKey(const ValueKey('shell.destination.settings')),
);
final runs = tester.getRect(
find.byKey(const ValueKey('shell.destination.runs')),
);
expect(settings.top, greaterThan(runs.bottom));
expect(settings.bottom, closeTo(railRect.bottom, 1));
});
testWidgets('the rail marks the selected tab and one tap selects another', (
tester,
) async {
await pumpShell(tester, width: 1000);
expect(tester.widget<NavigationRail>(rail()).selectedIndex, 0);
expect(find.text('pipelines body'), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pumpAndSettle();
expect(tester.widget<NavigationRail>(rail()).selectedIndex, 1);
expect(find.text('runs body'), findsOneWidget);
});
testWidgets('Settings opens from the rail foot as a page and no tab is '
'selected meanwhile', (tester) async {
final semantics = tester.ensureSemantics();
await pumpShell(tester, width: 1000);
await tester.tap(find.byKey(const ValueKey('shell.destination.settings')));
await tester.pumpAndSettle();
expect(find.text('settings body'), findsOneWidget);
expect(tester.widget<NavigationRail>(rail()).selectedIndex, isNull);
expect(
tester
.getSemantics(inRail(find.bySemanticsLabel('Settings')))
.flagsCollection
.isSelected,
Tristate.isTrue,
);
// The page's own Back returns to Pipelines, the tab it belongs to.
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pumpAndSettle();
expect(tester.widget<NavigationRail>(rail()).selectedIndex, 0);
semantics.dispose();
});
testWidgets('the running count stays on the Runs item of the rail', (
tester,
) async {
await pumpShell(tester, width: 1000, runningRunCount: 3);
final badge = find.byKey(const ValueKey('shell.badge.runs.running'));
expect(
find.descendant(of: badge, matching: find.text('3')),
findsOneWidget,
);
expect(
find.descendant(
of: find.byKey(const ValueKey('shell.destination.runs')),
matching: badge,
),
findsOneWidget,
);
});
testWidgets('a list and its open item lay out to the right of the rail', (
tester,
) async {
await pumpShell(tester, width: 1000, withPanes: true);
final list = tester.getRect(find.byKey(const ValueKey('list-detail-list')));
final body = tester.getRect(find.byKey(const ValueKey('list-detail-body')));
expect(list.left, closeTo(kNavigationRailSpace, 0.5));
expect(body.right, closeTo(1000, 0.5));
expect(body.left, greaterThan(list.right));
});
testWidgets('the rail appears from the threshold width, and below it the '
'floating bar stays', (tester) async {
expect(
kNavigationRailMinWindowWidth,
kListDetailMinWidth + kNavigationRailSpace,
);
await pumpShell(tester, width: kNavigationRailMinWindowWidth - 1);
expect(rail(), findsNothing);
expect(find.byType(FloatingDestinationBar), findsOneWidget);
await pumpShell(tester, width: kNavigationRailMinWindowWidth);
expect(rail(), findsOneWidget);
expect(find.byType(FloatingDestinationBar), findsNothing);
});
testWidgets('at the threshold the body beside the rail meets the list-detail '
'minimum, so the list sits beside its detail', (tester) async {
await pumpShell(
tester,
width: kNavigationRailMinWindowWidth,
withPanes: true,
);
final list = tester.getRect(find.byKey(const ValueKey('list-detail-list')));
final body = tester.getRect(find.byKey(const ValueKey('list-detail-body')));
// The list and detail fill the window beside the rail, at the split
// threshold: the list starts after the rail and the detail ends at the
// window's right edge, with the detail to the right of the list.
expect(list.left, closeTo(kNavigationRailSpace, 0.5));
expect(body.right, closeTo(kNavigationRailMinWindowWidth, 0.5));
expect(body.left, greaterThan(list.right));
});
testWidgets('phone and narrow windows keep the floating bar and no rail', (
tester,
) async {
for (final width in [390.0, 640.0]) {
await pumpShell(tester, width: width);
expect(rail(), findsNothing, reason: '$width');
expect(
find.byKey(const ValueKey('shell.destination.settings')),
findsNothing,
reason: '$width',
);
expect(
find.byType(FloatingDestinationBar),
findsOneWidget,
reason: '$width',
);
}
});
testWidgets('floating windows keep to the right of the rail on a wide '
'window, and use the whole window without one', (tester) async {
final manager = probeManager();
manager.open('probe', 'a');
Future<void> pumpWindows(double width) async {
tester.view.physicalSize = Size(width, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Stack(
fit: StackFit.expand,
children: [
const SizedBox.expand(),
Positioned.fill(
child: WindowHost(manager: manager, reservesRail: true),
),
],
),
),
),
);
await tester.pumpAndSettle();
}
await pumpWindows(1280);
// The probe window opens at x=100; beside the rail it starts after it.
expect(
windowRect(tester, 'Probe a').left,
closeTo(100 + kNavigationRailSpace, 0.5),
);
await pumpWindows(500);
expect(windowRect(tester, 'Probe a').left, closeTo(100, 0.5));
});
testWidgets('crossing the rail threshold keeps the destination mounted and '
'its state', (tester) async {
tester.view.physicalSize = Size(kNavigationRailMinWindowWidth - 1, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destination: AppDestination.runs,
destinationBodies: {AppDestination.runs: (_) => const _Counter()},
),
),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('counter.increment')));
await tester.pump();
final state = tester.state(find.byType(_Counter));
for (final width in [kNavigationRailMinWindowWidth, 390.0]) {
tester.view.physicalSize = Size(width, 800);
await tester.pumpAndSettle();
expect(
tester.state(find.byType(_Counter)),
same(state),
reason: '$width',
);
expect(find.text('count 1'), findsOneWidget, reason: '$width');
}
});
}
class _Counter extends StatefulWidget {
const _Counter();
@override
State<_Counter> createState() => _CounterState();
}
class _CounterState extends State<_Counter> {
int _count = 0;
@override
Widget build(BuildContext context) => Center(
child: TextButton(
key: const ValueKey('counter.increment'),
onPressed: () => setState(() => _count += 1),
child: Text('count $_count'),
),
);
}
+3 -3
View File
@@ -140,9 +140,9 @@ void main() {
expect(find.text('Its context'), findsOneWidget);
});
testWidgets('1200: the item\'s tabs float at the bottom of its '
testWidgets('640: the item\'s tabs float at the bottom of its '
'pane, the shell\'s tab bar under the list', (tester) async {
await setSize(tester, const Size(1200, 800));
await setSize(tester, const Size(640, 800));
await tester.pumpWidget(shell());
await tester.pump();
await tester.pump();
@@ -168,7 +168,7 @@ void main() {
expect(shellTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
expect(shellTabs.right, lessThanOrEqualTo(list.right));
expect(itemTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
expect(itemTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
expect(itemTabs.right, closeTo(640 - kFloatingBarMargin, 0.5));
expect(itemTabs.left, greaterThanOrEqualTo(body.left));
expect(itemTabs.overlaps(shellTabs), isFalse);
// The item's list starts below its bar and clears its tabs at rest.
+12 -11
View File
@@ -106,7 +106,7 @@ void main() {
.first,
);
for (final width in [1200.0, 1600.0]) {
for (final width in [600.0, 640.0]) {
testWidgets('$width split: the destination bar sits under the '
'list and the composer at the detail\'s bottom edge', (tester) async {
await setSize(tester, Size(width, 800));
@@ -211,11 +211,12 @@ void main() {
});
}
testWidgets('1200 split: the bar follows a dragged list width', (
testWidgets('640 split: the bar follows a dragged list width', (
tester,
) async {
await setSize(tester, const Size(1200, 800));
for (final width in [300.0, 520.0]) {
await setSize(tester, const Size(640, 800));
// Within a 640 window's list bounds (at most 0.6 of it, less the body).
for (final width in [260.0, 300.0]) {
final store = MemoryListPaneWidthStore({'chat': width});
await tester.pumpWidget(
KeyedSubtree(
@@ -235,26 +236,26 @@ void main() {
}
});
testWidgets('1200 Settings: a page without a list keeps the bar '
testWidgets('640 Settings: a page without a list keeps the bar '
'at the right edge', (tester) async {
await setSize(tester, const Size(1200, 800));
await setSize(tester, const Size(640, 800));
await tester.pumpWidget(shell(destination: AppDestination.settings));
await tester.pump();
final pill = destinationPill(tester);
expect(pill.right, closeTo(1200 - kFloatingBarMargin, 0.5));
expect(pill.right, closeTo(640 - kFloatingBarMargin, 0.5));
});
testWidgets('1200 unsplit: the bar stays under the list column', (
testWidgets('640 unsplit: the bar stays under the list column', (
tester,
) async {
await setSize(tester, const Size(1200, 800));
await setSize(tester, const Size(640, 800));
await tester.pumpWidget(shell(split: false));
await tester.pump();
final pill = destinationPill(tester);
// Same place as beside an open item (Search has no split), so opening
// or closing an item never moves the bar across the window.
expect(pill.left, closeTo(kFloatingBarMargin, 0.5));
expect(pill.width, lessThan(1200 * 0.6));
expect(pill.width, lessThan(640 * 0.6));
});
testWidgets('390: the bar hugs its tabs at the phone\'s bottom '
@@ -277,7 +278,7 @@ void main() {
expect(pill.right, closeTo(390 - kFloatingBarMargin, 0.5));
});
for (final width in [600.0, 840.0]) {
for (final width in [600.0, 640.0]) {
testWidgets('$width split at 2x: the bar fits the list pane and '
'the item tabs the detail, without overflow', (tester) async {
await setSize(tester, Size(width, 800));
+3 -3
View File
@@ -36,7 +36,7 @@ void main() {
);
Future<void> pumpSplitRun(WidgetTester tester) async {
tester.view.physicalSize = const Size(1200, 800);
tester.view.physicalSize = const Size(640, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final gateway = RunDetailFakeGateway(visitRunFixture());
@@ -71,7 +71,7 @@ void main() {
await tester.pumpAndSettle();
}
testWidgets('1200: run tabs float at the pane\'s bottom beside the '
testWidgets('640: run tabs float at the pane\'s bottom beside the '
'shell bar under the list, and the stage page opens in the pane', (
tester,
) async {
@@ -84,7 +84,7 @@ void main() {
final runTabs = pillOf(tester, find.byKey(const Key('run-detail-tabs')));
expect(runTabs.left, greaterThanOrEqualTo(body.left));
expect(runTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
expect(runTabs.right, closeTo(640 - kFloatingBarMargin, 0.5));
expect(runTabs.overlaps(main), isFalse);
expect(runTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
+2 -2
View File
@@ -158,7 +158,7 @@ void main() {
testWidgets('split: the item tabs sit at the bottom right of the '
'detail pane, the shell tab bar under the list', (tester) async {
// A gesture-navigation inset as on the unfolded foldable.
await setUp(tester, const Size(1200, 800), bottom: 24);
await setUp(tester, const Size(640, 800), bottom: 24);
await tester.pumpWidget(shell(tabbedItem()));
await tester.pump();
await tester.pump();
@@ -188,7 +188,7 @@ void main() {
expect(shellTabs.bottom, closeTo(800 - 24, 0.5));
expect(shellTabs.right, lessThanOrEqualTo(listPane.right));
expect(tabs.bottom, closeTo(800 - 24, 0.5));
expect(tabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
expect(tabs.right, closeTo(640 - kFloatingBarMargin, 0.5));
expect(shellTabs.overlaps(tabs), isFalse);
// The item's list clears its tabs at rest.
final list = tester.element(find.byKey(const Key('item-list')));