Files
pipelines/app/test/ui/adaptive/floating_bar_layout_test.dart
T
alan 963adec122 Float glass tab bars everywhere the app has bottom tabs
One floating frosted tab bar (host NavigationBar / CupertinoTabBar in the
shared GlassPill) replaces the NavigationRail, the Cupertino sidebar and the
run detail, stage page and pipeline detail tab strips. Below 600px it spans
the width minus 16px margins; wider it is sized to its tabs at the right edge.
Content keeps the full width, scrolls behind the bar and learns its height as
bottom media padding; lists pad their end clear of it and FABs sit above it.

The bar now sizes itself from its own constraints instead of the screen size,
which fixes the widget_test failure where a MediaQuery without a size gave it
negative width constraints.
2026-10-31 01:50:42 +00:00

78 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
void main() {
Widget page({
required Widget Function(BuildContext) list,
VoidCallback? onTap,
}) => MaterialApp(
home: Scaffold(
body: FloatingBarOverlay(
bar: FloatingDestinationBar(
cupertino: false,
currentIndex: 0,
onTap: (_) {},
items: const [
FloatingDestinationItem(icon: Icon(Icons.list), label: 'One'),
FloatingDestinationItem(icon: Icon(Icons.map), label: 'Two'),
],
),
child: GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: onTap,
child: Builder(builder: list),
),
),
),
);
for (final width in [390.0, 1200.0]) {
testWidgets('a padded list scrolls behind the bar and its last item '
'clears it at rest (width $width)', (tester) async {
tester.view.physicalSize = Size(width, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(
page(
list: (context) => ListView(
padding: withFloatingBarClearance(
context,
const EdgeInsets.all(16),
),
children: [
for (var i = 0; i < 40; i += 1)
SizedBox(height: 48, child: Text('Item $i')),
],
),
),
);
final pill = tester.getRect(find.byType(GlassPill));
// The list fills the area, behind the bar.
expect(tester.getRect(find.byType(ListView)).bottom, 800);
await tester.drag(find.byType(ListView), const Offset(0, -5000));
await tester.pumpAndSettle();
final last = tester.getRect(find.text('Item 39'));
expect(last.bottom, lessThanOrEqualTo(pill.top));
});
}
testWidgets('taps beside a wide bar reach the content', (tester) async {
tester.view.physicalSize = const Size(1200, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
var taps = 0;
await tester.pumpWidget(
page(list: (_) => const SizedBox.expand(), onTap: () => taps++),
);
final pill = tester.getRect(find.byType(GlassPill));
expect(pill.right, 1200 - kFloatingBarMargin);
await tester.tapAt(Offset(pill.left - 24, pill.center.dy));
expect(taps, 1);
await tester.tapAt(pill.center);
expect(taps, 1, reason: 'the bar takes its own taps');
});
}