3704d98d4d
- Search: field, compact Kind menu and syntax help in the bar's actions pill; bounds shown only when truncated; rows with bold title, kind tag and one muted line; results run behind the bar in a start-aligned 840 column. - AppSearchField: one search field per platform (Search, Schedules, Runs filter). - BarIconButton: whole 44pt/48dp bar actions; Runs, bell and Pipelines icons use the same 44pt targets on Cupertino. - Templates and Schedules pages put Refresh in the bar and use the shared round SegmentedBackButton; Templates shows one Back at a time. - PipelineBackButton is the round segmented Back. - notes/pages-fixes.md records the batch, tests and evidence.
96 lines
3.0 KiB
Dart
96 lines
3.0 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/ui/input/app_search_field.dart';
|
|
import 'package:pipelines_app/ui/navigation/bar_icon_button.dart';
|
|
|
|
Widget _row(bool cupertino, List<Widget> children) {
|
|
final row = Center(
|
|
child: Row(mainAxisSize: MainAxisSize.min, children: children),
|
|
);
|
|
return cupertino
|
|
? CupertinoApp(home: CupertinoPageScaffold(child: row))
|
|
: MaterialApp(home: Scaffold(body: row));
|
|
}
|
|
|
|
BarIconButton _action(Key key, {bool busy = false}) => BarIconButton(
|
|
key: key,
|
|
icon: Icons.refresh,
|
|
cupertinoIcon: CupertinoIcons.refresh,
|
|
label: 'Refresh',
|
|
busy: busy,
|
|
onPressed: () {},
|
|
);
|
|
|
|
void main() {
|
|
for (final cupertino in [false, true]) {
|
|
final host = cupertino ? 'Cupertino' : 'Material';
|
|
final side = cupertino
|
|
? kMinInteractiveDimensionCupertino
|
|
: kMinInteractiveDimension;
|
|
|
|
testWidgets('$host bar actions are whole, evenly sized touch targets', (
|
|
tester,
|
|
) async {
|
|
await tester.pumpWidget(
|
|
_row(cupertino, [
|
|
_action(const ValueKey('a')),
|
|
_action(const ValueKey('b')),
|
|
_action(const ValueKey('c'), busy: true),
|
|
]),
|
|
);
|
|
for (final key in const ['a', 'b', 'c']) {
|
|
expect(tester.getSize(find.byKey(ValueKey(key))), Size(side, side));
|
|
}
|
|
// Adjacent actions abut: the spacing is the targets', not padding.
|
|
expect(
|
|
tester.getTopLeft(find.byKey(const ValueKey('b'))).dx -
|
|
tester.getTopLeft(find.byKey(const ValueKey('a'))).dx,
|
|
side,
|
|
);
|
|
if (cupertino) expect(find.byType(Material), findsNothing);
|
|
expect(find.bySemanticsLabel('Refresh'), findsWidgets);
|
|
});
|
|
|
|
testWidgets('$host search field is one stadium field with a clear', (
|
|
tester,
|
|
) async {
|
|
final text = TextEditingController();
|
|
addTearDown(text.dispose);
|
|
var cleared = false;
|
|
await tester.pumpWidget(
|
|
_row(cupertino, [
|
|
SizedBox(
|
|
width: 300,
|
|
child: AppSearchField(
|
|
fieldKey: const ValueKey('field'),
|
|
controller: text,
|
|
placeholder: 'Search',
|
|
onCleared: () => cleared = true,
|
|
),
|
|
),
|
|
]),
|
|
);
|
|
if (cupertino) {
|
|
expect(find.byType(CupertinoSearchTextField), findsOneWidget);
|
|
expect(find.byType(Material), findsNothing);
|
|
return;
|
|
}
|
|
final field = tester.widget<TextField>(
|
|
find.byKey(const ValueKey('field')),
|
|
);
|
|
final border = field.decoration!.enabledBorder! as OutlineInputBorder;
|
|
expect(border.borderSide, BorderSide.none);
|
|
expect(field.decoration!.filled, isTrue);
|
|
expect(find.byTooltip('Clear search'), findsNothing);
|
|
|
|
await tester.enterText(find.byKey(const ValueKey('field')), 'abc');
|
|
await tester.pump();
|
|
await tester.tap(find.byTooltip('Clear search'));
|
|
await tester.pump();
|
|
expect(text.text, isEmpty);
|
|
expect(cleared, isTrue);
|
|
});
|
|
}
|
|
}
|