Fix shell rail surface and empty action island

Paint the navigation rail through its top inset and only add the floating-windows action when a listed window exists. Add focused widget coverage and document the reviewed UI states so the shell no longer shows a white strip or empty trailing pill.
This commit is contained in:
2026-11-12 10:37:56 +00:00
parent 24618964ce
commit e2e61ac005
7 changed files with 296 additions and 31 deletions
@@ -0,0 +1,63 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/navigation_rail.dart';
/// The rail's surface runs from the window's top edge. The system's top inset
/// is kept clear for the rail's content, but it is painted with the rail's
/// surface, so no unpainted strip (white in the app's canvas) shows above it.
void main() {
for (final brightness in Brightness.values) {
testWidgets('the rail top under a system inset is the rail surface '
'(${brightness.name})', (tester) async {
tester.view.physicalSize = const Size(1000, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final theme = ThemeData(
colorSchemeSeed: Colors.purple,
brightness: brightness,
);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Scaffold(
body: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ShellNavigationRail(
selected: AppDestination.pipelines,
icon: (destination) =>
Icon(destinationDetails(destination).icon),
onSelected: (_) {},
padding: const EdgeInsets.only(top: 8),
),
],
),
),
),
);
await tester.pumpAndSettle();
final surface = theme.colorScheme.surface;
final cover = find.byKey(const ValueKey('shell.navigation-rail.surface'));
final rail = find.byKey(const ValueKey('shell.navigation-rail'));
// The cover and the rail's own background are the same surface colour.
expect(tester.widget<ColoredBox>(cover).color, surface);
expect(tester.widget<NavigationRail>(rail).backgroundColor, surface);
// The rail's content starts below the inset, and the cover starts at the
// window's top edge, so the inset strip is covered.
final coverRect = tester.getRect(cover);
final railRect = tester.getRect(rail);
expect(coverRect.top, 0);
expect(railRect.top, 8);
expect(
coverRect.contains(Offset(railRect.center.dx, 2)),
isTrue,
reason: 'the strip above the rail content is painted',
);
});
}
}
@@ -0,0 +1,98 @@
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/windows/window_manager.dart';
import 'windows/window_test_harness.dart';
/// The shell bar's trailing action island is drawn only with actions. The
/// Windows button is one of them only while a floating window is open, so
/// Search and Settings (and every other route) show no empty pill at any size.
void main() {
Future<void> pumpShell(
WidgetTester tester, {
required AppDestination destination,
required double width,
WindowManager? windowManager,
}) async {
tester.view.physicalSize = Size(width, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destination: destination,
windowManager: windowManager,
destinationBodies: {
for (final value in AppDestination.values)
value: (_) => Text('${value.name} body'),
},
),
),
);
await tester.pumpAndSettle();
}
final actionIsland = find.byKey(const ValueKey('segmented.actions'));
for (final width in [1000.0, 430.0]) {
for (final destination in [
AppDestination.search,
AppDestination.settings,
AppDestination.pipelines,
]) {
testWidgets(
'${destination.name} at width ${width.toInt()} draws no empty action '
'island with no floating window',
(tester) async {
await pumpShell(
tester,
destination: destination,
width: width,
windowManager: probeManager(),
);
expect(actionIsland, findsNothing);
expect(find.byKey(const ValueKey('shell.windows')), findsNothing);
},
);
}
}
testWidgets('a shell without a window manager draws no action island', (
tester,
) async {
await pumpShell(tester, destination: AppDestination.settings, width: 1000);
expect(actionIsland, findsNothing);
});
testWidgets('the Windows button is the island only while a window is open', (
tester,
) async {
final manager = probeManager();
await pumpShell(
tester,
destination: AppDestination.search,
width: 1000,
windowManager: manager,
);
expect(actionIsland, findsNothing);
final entry = manager.open('probe', 'a');
await tester.pumpAndSettle();
expect(actionIsland, findsOneWidget);
expect(
find.descendant(
of: actionIsland,
matching: find.byKey(const ValueKey('shell.windows')),
),
findsOneWidget,
);
manager.close(entry.id);
await tester.pumpAndSettle();
expect(actionIsland, findsNothing);
expect(find.byKey(const ValueKey('shell.windows')), findsNothing);
});
}