e34fa1050e
- SegmentedBar.titleWidget (and ShellBar/ShellBarSpec titleWidget, backgroundColor): a bar's main pill can be an input in place of the title; Search uses it so the field fills the bar with Kind and info, capped at the result column width so field and results share edges on wide windows. - Templates page/frame drop the top SafeArea again (BelowTopBar gate, TopBarNotices banners); Cupertino uses the grouped background. - Settings on Cupertino in the shell publishes the grouped background so the bar scrim matches the page (no white band or seam). - TopGlassStrip: the run detail header (status, actions, decision, notices) and the Schedules search/filter toolbar float as glass under the bar; tabs and lists scroll behind both. - Stage page: stage title and Visit/Run subtitle in the bar, facts lead the Summary scroll, sections scroll behind the bar under floating tabs. - Tests for content-behind-bar on each page and the title-widget bar mode; notes/chrome-gaps-fixes.md.
146 lines
4.6 KiB
Dart
146 lines
4.6 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
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/shell_bar.dart';
|
|
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
|
|
|
/// A bar whose main pill is an input (Search): the widget takes the title
|
|
/// pill's place and fills the bar, up to its cap, from the leading edge.
|
|
void main() {
|
|
void setSize(WidgetTester tester, double width) {
|
|
tester.view.physicalSize = Size(width, 800);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
}
|
|
|
|
const fieldKey = Key('field');
|
|
|
|
Widget field(bool cupertino) => cupertino
|
|
? const CupertinoTextField(key: fieldKey, placeholder: 'Find')
|
|
: const TextField(key: fieldKey);
|
|
|
|
Rect pillOf(WidgetTester tester, Finder child) => tester.getRect(
|
|
find.ancestor(of: child, matching: find.byType(GlassPill)).first,
|
|
);
|
|
|
|
Widget page(bool cupertino, SegmentedBar bar) => cupertino
|
|
? CupertinoApp(
|
|
home: CupertinoPageScaffold(
|
|
navigationBar: bar,
|
|
child: const SizedBox.expand(),
|
|
),
|
|
)
|
|
: MaterialApp(
|
|
home: Scaffold(
|
|
extendBodyBehindAppBar: true,
|
|
appBar: bar,
|
|
body: const SizedBox.expand(),
|
|
),
|
|
);
|
|
|
|
for (final cupertino in [false, true]) {
|
|
final host = cupertino ? 'Cupertino' : 'Material';
|
|
|
|
testWidgets('$host: the widget replaces the title and fills a phone bar', (
|
|
tester,
|
|
) async {
|
|
setSize(tester, 390);
|
|
await tester.pumpWidget(
|
|
page(
|
|
cupertino,
|
|
SegmentedBar(
|
|
cupertino: cupertino,
|
|
title: 'Search',
|
|
titleWidget: field(cupertino),
|
|
titleWidgetMaxWidth: 840,
|
|
),
|
|
),
|
|
);
|
|
|
|
expect(find.text('Search'), findsNothing, reason: 'no title pill');
|
|
expect(
|
|
find.descendant(
|
|
of: find.byType(SegmentedBar),
|
|
matching: find.byType(GlassPill),
|
|
),
|
|
findsOneWidget,
|
|
reason: 'one pill: the field',
|
|
);
|
|
final pill = pillOf(tester, find.byKey(fieldKey));
|
|
expect(pill.left, 12);
|
|
expect(pill.right, 390 - 12);
|
|
});
|
|
|
|
testWidgets('$host: on a wide bar the pill stops at its cap from the '
|
|
'leading edge, beside a Back and any actions', (tester) async {
|
|
setSize(tester, 1200);
|
|
await tester.pumpWidget(
|
|
page(
|
|
cupertino,
|
|
SegmentedBar(
|
|
cupertino: cupertino,
|
|
title: 'Search',
|
|
leading: SegmentedBackButton(
|
|
cupertino: cupertino,
|
|
onPressed: () {},
|
|
),
|
|
titleWidget: field(cupertino),
|
|
titleWidgetMaxWidth: 600,
|
|
actions: const [Icon(Icons.info_outline, key: Key('action'))],
|
|
),
|
|
),
|
|
);
|
|
|
|
final pill = pillOf(tester, find.byKey(fieldKey));
|
|
final back = pillOf(tester, find.byType(SegmentedBackButton));
|
|
expect(pill.width, 600);
|
|
expect(pill.left, back.right + 8);
|
|
// The actions keep to the trailing edge.
|
|
expect(pillOf(tester, find.byKey(const Key('action'))).right, 1200 - 12);
|
|
});
|
|
|
|
testWidgets('$host: a shell tab publishing a field gets it in place of '
|
|
'the title, without the Search action', (tester) async {
|
|
setSize(tester, 560);
|
|
await tester.pumpWidget(
|
|
_shellApp(
|
|
cupertino,
|
|
AdaptiveShell(
|
|
cupertino: cupertino,
|
|
destination: AppDestination.search,
|
|
onSearch: () {},
|
|
destinationBodies: {
|
|
AppDestination.search: (_) => ShellBar(
|
|
titleWidget: field(cupertino),
|
|
titleWidgetMaxWidth: 840,
|
|
child: const SizedBox.expand(),
|
|
),
|
|
},
|
|
),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
|
|
final bar = find.byType(SegmentedBar);
|
|
expect(
|
|
find.descendant(of: bar, matching: find.byKey(fieldKey)),
|
|
findsOneWidget,
|
|
);
|
|
expect(
|
|
find.descendant(of: bar, matching: find.text('Search')),
|
|
findsNothing,
|
|
);
|
|
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
|
|
final pill = pillOf(tester, find.byKey(fieldKey));
|
|
expect(pill.left, 12);
|
|
expect(pill.right, 560 - 12);
|
|
});
|
|
}
|
|
}
|
|
|
|
Widget _shellApp(bool cupertino, Widget shell) =>
|
|
cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell);
|