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:
@@ -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',
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user