Files
pipelines/app/test/ui/adaptive/floating_bar_layout_test.dart
T
alan 377ff04aaf Show each floating tab as its own round glass button
Replace the single glass pill (host NavigationBar/CupertinoTabBar with one
gliding highlight) with a row of separate circular GlassPill buttons, 52/50 px
with 12/10 px gaps, at the same bottom-right place. The selected button fills
with the host selection tint and cross-fades; each button pops in on its own,
staggered, only when the bar appears or its tabs change; presses sink like the
top bar's. Tab semantics, keys, tooltips and badges are kept; the row shares
one BackdropGroup for its blurs.
2026-11-02 18:43:05 +00:00

78 lines
2.7 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.byKey(FloatingDestinationBar.rowKey));
// 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.byKey(FloatingDestinationBar.rowKey));
expect(pill.right, 1200 - kFloatingBarMargin);
await tester.tapAt(Offset(pill.left - 24, pill.center.dy));
expect(taps, 1);
await tester.tapAt(tester.getCenter(find.byType(GlassPill).first));
expect(taps, 1, reason: 'the bar takes its own taps');
});
}