Complete Material-only APIs and fixtures
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
This commit is contained in:
@@ -18,12 +18,10 @@ void main() {
|
||||
Key tabKey(int index) => ValueKey('tab-$index');
|
||||
|
||||
Widget bar({
|
||||
required bool cupertino,
|
||||
required int count,
|
||||
required int selected,
|
||||
ValueChanged<int>? onTap,
|
||||
}) => FloatingDestinationBar(
|
||||
cupertino: cupertino,
|
||||
currentIndex: selected,
|
||||
onTap: onTap ?? (_) {},
|
||||
items: [
|
||||
@@ -38,7 +36,6 @@ void main() {
|
||||
|
||||
Future<void> pump(
|
||||
WidgetTester tester, {
|
||||
required bool cupertino,
|
||||
required Size size,
|
||||
required Widget child,
|
||||
double textScale = 1,
|
||||
@@ -76,10 +73,9 @@ void main() {
|
||||
];
|
||||
|
||||
{
|
||||
const cupertino = false;
|
||||
const host = 'Material';
|
||||
final diameter = FloatingDestinationBar.buttonSize(cupertino: cupertino);
|
||||
final gap = FloatingDestinationBar.buttonGap(cupertino: cupertino);
|
||||
final diameter = FloatingDestinationBar.buttonSize();
|
||||
final gap = FloatingDestinationBar.buttonGap();
|
||||
final iconSize = FloatingDestinationBar.materialIconSize;
|
||||
|
||||
test('$host: buttons are larger than the old 44/42 circle, hit targets '
|
||||
@@ -93,11 +89,10 @@ void main() {
|
||||
'centred in it', (tester) async {
|
||||
await pump(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
size: const Size(390, 844),
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: bar(cupertino: cupertino, count: 3, selected: 0),
|
||||
child: bar(count: 3, selected: 0),
|
||||
),
|
||||
);
|
||||
expect(
|
||||
@@ -111,7 +106,7 @@ void main() {
|
||||
final circle = button(tester, index);
|
||||
// Tab 0 is selected: its whole button is larger than the others.
|
||||
final across = index == 0
|
||||
? FloatingDestinationBar.selectedButtonSize(cupertino: cupertino)
|
||||
? FloatingDestinationBar.selectedButtonSize()
|
||||
: diameter;
|
||||
expect(circle.width, moreOrLessEquals(across));
|
||||
expect(circle.height, moreOrLessEquals(across));
|
||||
@@ -129,10 +124,8 @@ void main() {
|
||||
final icon = tester.getRect(find.byIcon(icons[index]));
|
||||
final side = index == 0
|
||||
? iconSize *
|
||||
FloatingDestinationBar.selectedButtonSize(
|
||||
cupertino: cupertino,
|
||||
) /
|
||||
FloatingDestinationBar.buttonSize(cupertino: cupertino)
|
||||
FloatingDestinationBar.selectedButtonSize() /
|
||||
FloatingDestinationBar.buttonSize()
|
||||
: iconSize;
|
||||
expect(icon.width, moreOrLessEquals(side));
|
||||
expect(icon.height, moreOrLessEquals(side));
|
||||
@@ -147,11 +140,10 @@ void main() {
|
||||
final size = placement.size;
|
||||
await pump(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
size: size,
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: bar(cupertino: cupertino, count: count, selected: 0),
|
||||
child: bar(count: count, selected: 0),
|
||||
),
|
||||
);
|
||||
final box = row(tester);
|
||||
@@ -160,15 +152,11 @@ void main() {
|
||||
// As tall as the selected (larger) button.
|
||||
expect(
|
||||
box.height,
|
||||
moreOrLessEquals(
|
||||
FloatingDestinationBar.selectedButtonSize(cupertino: cupertino),
|
||||
),
|
||||
moreOrLessEquals(FloatingDestinationBar.selectedButtonSize()),
|
||||
);
|
||||
expect(
|
||||
box.width,
|
||||
moreOrLessEquals(
|
||||
FloatingDestinationBar.rowWidth(cupertino: cupertino, tabs: count),
|
||||
),
|
||||
moreOrLessEquals(FloatingDestinationBar.rowWidth(tabs: count)),
|
||||
);
|
||||
expect(button(tester, 0).left, box.left);
|
||||
expect(button(tester, count - 1).right, box.right);
|
||||
@@ -192,14 +180,12 @@ void main() {
|
||||
// The shell's wide placement: under the list pane, centred in it.
|
||||
await pump(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
size: const Size(1280, 800),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.bottomStart,
|
||||
child: SizedBox(
|
||||
width: listWidth,
|
||||
child: FloatingDestinationBar(
|
||||
cupertino: cupertino,
|
||||
currentIndex: 1,
|
||||
onTap: (_) {},
|
||||
alignment: Alignment.bottomCenter,
|
||||
@@ -221,12 +207,7 @@ void main() {
|
||||
expect(
|
||||
box.center.dy,
|
||||
moreOrLessEquals(
|
||||
800 -
|
||||
16 -
|
||||
FloatingDestinationBar.selectedButtonSize(
|
||||
cupertino: cupertino,
|
||||
) /
|
||||
2,
|
||||
800 - 16 - FloatingDestinationBar.selectedButtonSize() / 2,
|
||||
),
|
||||
);
|
||||
expect(box.left, greaterThanOrEqualTo(16 - 0.01));
|
||||
@@ -235,8 +216,7 @@ void main() {
|
||||
expect(
|
||||
button(tester, 1).width / button(tester, 0).width,
|
||||
moreOrLessEquals(
|
||||
FloatingDestinationBar.selectedButtonSize(cupertino: cupertino) /
|
||||
diameter,
|
||||
FloatingDestinationBar.selectedButtonSize() / diameter,
|
||||
),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
@@ -249,7 +229,6 @@ void main() {
|
||||
var content = 0;
|
||||
await pump(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
size: const Size(390, 844),
|
||||
child: Stack(
|
||||
children: [
|
||||
@@ -261,12 +240,7 @@ void main() {
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: bar(
|
||||
cupertino: cupertino,
|
||||
count: 3,
|
||||
selected: 1,
|
||||
onTap: tapped.add,
|
||||
),
|
||||
child: bar(count: 3, selected: 1, onTap: tapped.add),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -287,12 +261,11 @@ void main() {
|
||||
'stay within the margins', (tester) async {
|
||||
await pump(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
size: const Size(320, 640),
|
||||
textScale: 2,
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: bar(cupertino: cupertino, count: 5, selected: 4),
|
||||
child: bar(count: 5, selected: 4),
|
||||
),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
@@ -300,9 +273,7 @@ void main() {
|
||||
expect(box.right, 320 - 16);
|
||||
expect(box.left, greaterThanOrEqualTo(16));
|
||||
// Tab 4 is selected and larger; the gaps narrow around it.
|
||||
final selected = FloatingDestinationBar.selectedButtonSize(
|
||||
cupertino: cupertino,
|
||||
);
|
||||
final selected = FloatingDestinationBar.selectedButtonSize();
|
||||
final narrowed = (288 - 4 * diameter - selected) / 4;
|
||||
for (var index = 1; index < 5; index += 1) {
|
||||
expect(
|
||||
@@ -320,13 +291,12 @@ void main() {
|
||||
'reads from the right', (tester) async {
|
||||
await pump(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
size: const Size(390, 844),
|
||||
child: Directionality(
|
||||
textDirection: TextDirection.rtl,
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: bar(cupertino: cupertino, count: 3, selected: 0),
|
||||
child: bar(count: 3, selected: 0),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -12,7 +12,6 @@ void main() {
|
||||
home: Scaffold(
|
||||
body: FloatingBarOverlay(
|
||||
bar: FloatingDestinationBar(
|
||||
cupertino: false,
|
||||
currentIndex: 0,
|
||||
onTap: (_) {},
|
||||
items: const [
|
||||
|
||||
@@ -16,7 +16,6 @@ void main() {
|
||||
children: [
|
||||
TextField(focusNode: focus),
|
||||
FloatingDestinationBar(
|
||||
cupertino: false,
|
||||
currentIndex: 0,
|
||||
showLabels: true,
|
||||
items: const [
|
||||
|
||||
@@ -49,7 +49,6 @@ void main() {
|
||||
builder: (context, setState) => Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: FloatingDestinationBar(
|
||||
cupertino: false,
|
||||
currentIndex: selected,
|
||||
onTap: (index) => setState(() => selected = index),
|
||||
items: items(count),
|
||||
@@ -95,7 +94,7 @@ void main() {
|
||||
}
|
||||
|
||||
final host = 'Material';
|
||||
final size = FloatingDestinationBar.buttonSize(cupertino: false);
|
||||
final size = FloatingDestinationBar.buttonSize();
|
||||
final iconSize = FloatingDestinationBar.materialIconSize;
|
||||
|
||||
testWidgets('$host: each button pops in on its own, staggered, from '
|
||||
@@ -106,7 +105,7 @@ void main() {
|
||||
final tab = find.byKey(tabKey(index));
|
||||
expect(opacityOf(tester, tab), 0);
|
||||
final rest = index == 0
|
||||
? FloatingDestinationBar.selectedButtonSize(cupertino: false)
|
||||
? FloatingDestinationBar.selectedButtonSize()
|
||||
: size;
|
||||
expect(widthOf(tester, tab), moreOrLessEquals(rest * 0.6));
|
||||
}
|
||||
@@ -123,9 +122,7 @@ void main() {
|
||||
// Tab 0 is selected, so it settles at the larger size.
|
||||
expect(
|
||||
widthOf(tester, tab),
|
||||
index == 0
|
||||
? FloatingDestinationBar.selectedButtonSize(cupertino: false)
|
||||
: size,
|
||||
index == 0 ? FloatingDestinationBar.selectedButtonSize() : size,
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -168,7 +165,6 @@ void main() {
|
||||
return Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: FloatingDestinationBar(
|
||||
cupertino: false,
|
||||
currentIndex: 0,
|
||||
onTap: (_) {},
|
||||
items: items(count),
|
||||
@@ -219,8 +215,8 @@ void main() {
|
||||
iconWidth(tester, 2),
|
||||
moreOrLessEquals(
|
||||
iconSize *
|
||||
FloatingDestinationBar.selectedButtonSize(cupertino: false) /
|
||||
FloatingDestinationBar.buttonSize(cupertino: false),
|
||||
FloatingDestinationBar.selectedButtonSize() /
|
||||
FloatingDestinationBar.buttonSize(),
|
||||
),
|
||||
);
|
||||
expect(iconWidth(tester, 0), moreOrLessEquals(iconSize));
|
||||
@@ -251,15 +247,12 @@ void main() {
|
||||
// Tab 0 is selected, so it is the larger button; the press leaves it.
|
||||
expect(
|
||||
widthOf(tester, find.byKey(tabKey(0))),
|
||||
FloatingDestinationBar.selectedButtonSize(cupertino: false),
|
||||
FloatingDestinationBar.selectedButtonSize(),
|
||||
);
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
// The tap selected it: it springs back to the selected size.
|
||||
expect(
|
||||
widthOf(tester, tab),
|
||||
FloatingDestinationBar.selectedButtonSize(cupertino: false),
|
||||
);
|
||||
expect(widthOf(tester, tab), FloatingDestinationBar.selectedButtonSize());
|
||||
});
|
||||
|
||||
testWidgets('$host: under reduced motion the tint jumps and the buttons '
|
||||
@@ -280,8 +273,8 @@ void main() {
|
||||
iconWidth(tester, 2),
|
||||
moreOrLessEquals(
|
||||
iconSize *
|
||||
FloatingDestinationBar.selectedButtonSize(cupertino: false) /
|
||||
FloatingDestinationBar.buttonSize(cupertino: false),
|
||||
FloatingDestinationBar.selectedButtonSize() /
|
||||
FloatingDestinationBar.buttonSize(),
|
||||
),
|
||||
);
|
||||
expect(iconWidth(tester, 0), moreOrLessEquals(iconSize));
|
||||
@@ -289,7 +282,7 @@ void main() {
|
||||
|
||||
testWidgets('switching the shell tabs never replays the main '
|
||||
"bar's entrance", (tester) async {
|
||||
final size = FloatingDestinationBar.buttonSize(cupertino: false);
|
||||
final size = FloatingDestinationBar.buttonSize();
|
||||
animate(tester, on: true);
|
||||
var destination = AppDestination.runs;
|
||||
final shell = StatefulBuilder(
|
||||
|
||||
@@ -17,7 +17,6 @@ void main() {
|
||||
home: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(
|
||||
cupertino: false,
|
||||
title: 'Release train run',
|
||||
subtitle: 'Run 7',
|
||||
expandableTitle: true,
|
||||
@@ -49,7 +48,7 @@ void main() {
|
||||
testWidgets('a lone piece reads the backdrop on its own', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Center(child: GlassPill(cupertino: false, child: Text('Tabs'))),
|
||||
home: Center(child: GlassPill(child: Text('Tabs'))),
|
||||
),
|
||||
);
|
||||
expect(_keys(tester), [isNull]);
|
||||
|
||||
@@ -139,7 +139,7 @@ void main() {
|
||||
if (count > 1) {
|
||||
_expectEvenNeighbours(controls.sublist(controls.length - 2));
|
||||
}
|
||||
expect(pill.height, closeTo(GlassBarMetrics.height(false), 1));
|
||||
expect(pill.height, closeTo(GlassBarMetrics.height(), 1));
|
||||
expect(tester.takeException(), isNull);
|
||||
}
|
||||
});
|
||||
@@ -240,7 +240,7 @@ void main() {
|
||||
// The controls keep to the field's last line: each end control is as
|
||||
// far from the pill's side as from its bottom, and while the field is
|
||||
// one line (no taller than a control) as far from its top.
|
||||
final row = GlassBarMetrics.controlExtent(false);
|
||||
final row = GlassBarMetrics.controlExtent();
|
||||
final oneLine =
|
||||
pill.height <= row + 2 * GlassBarMetrics.fieldEdgeGap + 0.5;
|
||||
for (final (control, start) in [(attach, true), (send, false)]) {
|
||||
@@ -273,11 +273,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: SegmentedBar(
|
||||
cupertino: false,
|
||||
title: 'Title',
|
||||
actions: actions,
|
||||
),
|
||||
appBar: SegmentedBar(title: 'Title', actions: actions),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -307,16 +303,13 @@ void _expectPager(WidgetTester tester, Finder inside, Finder position) {
|
||||
_expectEvenNeighbours(controls);
|
||||
final text = tester.getRect(position);
|
||||
final gap = (pill.height - last.height) / 2;
|
||||
expect(
|
||||
text.left - pill.left,
|
||||
closeTo(gap + GlassBarMetrics.iconInset(false), 1),
|
||||
);
|
||||
expect(text.left - pill.left, closeTo(gap + GlassBarMetrics.iconInset(), 1));
|
||||
// The chevrons keep the same gap from the position as from each other's
|
||||
// icons: one icon inset on each side.
|
||||
expect(
|
||||
controls.first.left - text.right,
|
||||
greaterThanOrEqualTo(GlassBarMetrics.iconInset(false) - 1),
|
||||
greaterThanOrEqualTo(GlassBarMetrics.iconInset() - 1),
|
||||
);
|
||||
expect(pill.height, closeTo(GlassBarMetrics.height(false), 1));
|
||||
expect(pill.height, closeTo(GlassBarMetrics.height(), 1));
|
||||
expect(tester.takeException(), isNull);
|
||||
}
|
||||
|
||||
@@ -9,9 +9,7 @@ Widget _pill({Brightness brightness = Brightness.light, bool solid = false}) =>
|
||||
theme: ThemeData(brightness: brightness),
|
||||
home: MediaQuery(
|
||||
data: MediaQueryData(highContrast: solid),
|
||||
child: const Center(
|
||||
child: GlassPill(cupertino: false, child: Text('Runs')),
|
||||
),
|
||||
child: const Center(child: GlassPill(child: Text('Runs'))),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/application/app.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/platform.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
||||
|
||||
void main() {
|
||||
test('no platform prefers the Cupertino host', () {
|
||||
expect(prefersCupertino(), isFalse);
|
||||
});
|
||||
|
||||
for (final platform in TargetPlatform.values) {
|
||||
testWidgets('the app uses the Material host on $platform', (tester) async {
|
||||
debugDefaultTargetPlatformOverride = platform;
|
||||
addTearDown(() => debugDefaultTargetPlatformOverride = null);
|
||||
await tester.pumpWidget(const MyApp());
|
||||
expect(find.byType(MaterialApp), findsOneWidget);
|
||||
expect(find.byType(CupertinoApp), findsNothing);
|
||||
// Native hosts keep the target platform so Flutter's automatic
|
||||
// behaviours (scroll physics, text selection, back-swipe) still apply.
|
||||
final expected = kIsWeb ? TargetPlatform.android : platform;
|
||||
|
||||
@@ -7,21 +7,15 @@ import 'package:pipelines_app/ui/motion/motion.dart';
|
||||
/// Every piece of the top bar (Back, the title, the actions pill and each
|
||||
/// action in it) pops in with the tab buttons' entrance, once.
|
||||
void main() {
|
||||
Widget page(
|
||||
bool cupertino, {
|
||||
Widget page({
|
||||
String title = 'Runs',
|
||||
List<Widget> actions = const [],
|
||||
Object? actionsKey,
|
||||
bool reduced = false,
|
||||
}) {
|
||||
final bar = SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
title: title,
|
||||
leading: SegmentedBackButton(
|
||||
key: const Key('back'),
|
||||
cupertino: cupertino,
|
||||
onPressed: () {},
|
||||
),
|
||||
leading: SegmentedBackButton(key: const Key('back'), onPressed: () {}),
|
||||
actions: actions,
|
||||
actionsKey: actionsKey,
|
||||
);
|
||||
@@ -56,7 +50,6 @@ void main() {
|
||||
const step = Motion.tabEntranceStagger;
|
||||
|
||||
{
|
||||
const cupertino = false;
|
||||
const host = 'Material';
|
||||
const icon = Icons.refresh;
|
||||
Widget action(String key) =>
|
||||
@@ -67,9 +60,7 @@ void main() {
|
||||
testWidgets('$host: each piece pops in turn, left to right, from 0.6', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, actions: [action('a'), action('b')]),
|
||||
);
|
||||
await tester.pumpWidget(page(actions: [action('a'), action('b')]));
|
||||
expect(scaleOf(tester, back), begin);
|
||||
expect(scaleOf(tester, title), begin);
|
||||
expect(scaleOf(tester, a), begin, reason: 'the pill');
|
||||
@@ -104,7 +95,7 @@ void main() {
|
||||
testWidgets('$host: a lone action pops as its pill, not twice', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino, actions: [action('a')]));
|
||||
await tester.pumpWidget(page(actions: [action('a')]));
|
||||
expect(scaleOf(tester, a), begin);
|
||||
expect(scaleOf(tester, a, inner: true), 1);
|
||||
await tester.pump(step * 2 + const Duration(milliseconds: 40));
|
||||
@@ -117,11 +108,9 @@ void main() {
|
||||
testWidgets('$host: a rebuild or new title does not replay it', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino, actions: [action('a')]));
|
||||
await tester.pumpWidget(page(actions: [action('a')]));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, title: 'Other', actions: [action('a')]),
|
||||
);
|
||||
await tester.pumpWidget(page(title: 'Other', actions: [action('a')]));
|
||||
await tester.pump();
|
||||
expect(scaleOf(tester, back), 1);
|
||||
expect(scaleOf(tester, find.text('Other')), 1);
|
||||
@@ -133,11 +122,9 @@ void main() {
|
||||
testWidgets('$host: an action that becomes available pops in alone', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino, actions: [action('a')]));
|
||||
await tester.pumpWidget(page(actions: [action('a')]));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, actions: [action('b'), action('a')]),
|
||||
);
|
||||
await tester.pumpWidget(page(actions: [action('b'), action('a')]));
|
||||
expect(scaleOf(tester, b, inner: true), begin);
|
||||
// The pill, the action already there and the rest stay put.
|
||||
expect(scaleOf(tester, a), 1);
|
||||
@@ -154,21 +141,16 @@ void main() {
|
||||
tester,
|
||||
) async {
|
||||
final list = Object();
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, actionsKey: list, actions: [action('a')]),
|
||||
);
|
||||
await tester.pumpWidget(page(actionsKey: list, actions: [action('a')]));
|
||||
await tester.pumpAndSettle();
|
||||
// The same screen republishing its bar is not a new entrance.
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, actionsKey: list, actions: [action('a')]),
|
||||
);
|
||||
await tester.pumpWidget(page(actionsKey: list, actions: [action('a')]));
|
||||
await tester.pump();
|
||||
expect(tester.hasRunningAnimations, isFalse);
|
||||
// Another screen's actions are new, though keyed alike; Back, the
|
||||
// title and the pill stay.
|
||||
await tester.pumpWidget(
|
||||
page(
|
||||
cupertino,
|
||||
title: 'Chats',
|
||||
actionsKey: Object(),
|
||||
actions: [action('a'), action('b')],
|
||||
@@ -189,11 +171,9 @@ void main() {
|
||||
testWidgets('$host: a pill arriving later pops, then its actions', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino));
|
||||
await tester.pumpWidget(page());
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, actions: [action('a'), action('b')]),
|
||||
);
|
||||
await tester.pumpWidget(page(actions: [action('a'), action('b')]));
|
||||
expect(scaleOf(tester, back), 1);
|
||||
await tester.pump(const Duration(milliseconds: 20));
|
||||
expect(scaleOf(tester, a), greaterThan(begin), reason: 'at once');
|
||||
@@ -206,7 +186,7 @@ void main() {
|
||||
|
||||
testWidgets('$host: reduced motion shows the bar at once', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, actions: [action('a'), action('b')], reduced: true),
|
||||
page(actions: [action('a'), action('b')], reduced: true),
|
||||
);
|
||||
expect(scaleOf(tester, back), 1);
|
||||
expect(scaleOf(tester, title), 1);
|
||||
|
||||
@@ -10,8 +10,7 @@ import 'package:pipelines_app/ui/motion/motion.dart';
|
||||
/// The top bar's glass fades in with its blur, and its controls sink when
|
||||
/// pressed (its entrance is in segmented_bar_entrance_test.dart).
|
||||
void main() {
|
||||
Widget page(
|
||||
bool cupertino, {
|
||||
Widget page({
|
||||
String title = 'Runs',
|
||||
List<Widget> actions = const [],
|
||||
VoidCallback? onTitle,
|
||||
@@ -19,12 +18,10 @@ void main() {
|
||||
VoidCallback? onBack,
|
||||
}) {
|
||||
final bar = SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
title: title,
|
||||
onTitlePressed: onTitle,
|
||||
leading: SegmentedBackButton(
|
||||
key: const Key('back'),
|
||||
cupertino: cupertino,
|
||||
onPressed: onBack ?? () {},
|
||||
),
|
||||
actions: actions,
|
||||
@@ -70,7 +67,6 @@ void main() {
|
||||
final title = find.text('Runs');
|
||||
|
||||
{
|
||||
const cupertino = false;
|
||||
const host = 'Material';
|
||||
const icon = Icons.refresh;
|
||||
Widget action(String key) =>
|
||||
@@ -79,7 +75,7 @@ void main() {
|
||||
testWidgets('$host: the glass fades in with its blur, not under a layer', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino));
|
||||
await tester.pumpWidget(page());
|
||||
// Back and the title are both still popping in.
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
final backdrops = tester.layers.whereType<BackdropFilterLayer>().toList();
|
||||
@@ -106,7 +102,7 @@ void main() {
|
||||
'$host: Back sinks and tints while pressed, then springs back',
|
||||
(tester) async {
|
||||
var backs = 0;
|
||||
await tester.pumpWidget(page(cupertino, onBack: () => backs++));
|
||||
await tester.pumpWidget(page(onBack: () => backs++));
|
||||
await tester.pumpAndSettle();
|
||||
expect(pressScale(tester, back), 1);
|
||||
expect(pressTint(tester, back).a, 0);
|
||||
@@ -126,7 +122,7 @@ void main() {
|
||||
testWidgets('$host: a quick tap still shows the whole press', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino, actions: [action('a')]));
|
||||
await tester.pumpWidget(page(actions: [action('a')]));
|
||||
await tester.pumpAndSettle();
|
||||
final a = find.byKey(const Key('a'));
|
||||
await tester.tap(a);
|
||||
@@ -144,11 +140,7 @@ void main() {
|
||||
) async {
|
||||
var taps = 0;
|
||||
await tester.pumpWidget(
|
||||
page(
|
||||
cupertino,
|
||||
onTitle: () => taps++,
|
||||
actions: [action('a'), action('b')],
|
||||
),
|
||||
page(onTitle: () => taps++, actions: [action('a'), action('b')]),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final a = find.byKey(const Key('a'));
|
||||
@@ -168,13 +160,13 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('$host: hit testing is unchanged at rest', (tester) async {
|
||||
await tester.pumpWidget(page(cupertino, actions: [action('a')]));
|
||||
await tester.pumpWidget(page(actions: [action('a')]));
|
||||
await tester.pumpAndSettle();
|
||||
final pill = tester.getRect(
|
||||
find.ancestor(of: back, matching: find.byType(GlassPill)).first,
|
||||
);
|
||||
expect(pill.left, 12);
|
||||
expect(pill.height, segmentedPieceHeight(cupertino));
|
||||
expect(pill.height, segmentedPieceHeight());
|
||||
// A tap between the pieces reaches no piece; on Back it reaches Back.
|
||||
final backBox = tester.renderObject(back);
|
||||
bool hitsBack(Offset at) =>
|
||||
|
||||
@@ -14,7 +14,7 @@ const _names = ['Needs you', 'Usage', 'Filter', 'Sort', 'Select'];
|
||||
Key _key(String name) => ValueKey('action.$name');
|
||||
|
||||
/// An icon action like the list bars' own, at the host's touch target.
|
||||
Widget _icon(bool cupertino, String name, VoidCallback onPressed) => IconButton(
|
||||
Widget _icon(String name, VoidCallback onPressed) => IconButton(
|
||||
key: _key(name),
|
||||
tooltip: name,
|
||||
onPressed: onPressed,
|
||||
@@ -22,10 +22,10 @@ Widget _icon(bool cupertino, String name, VoidCallback onPressed) => IconButton(
|
||||
);
|
||||
|
||||
/// The Runs bar's shape: a bell that always stays, then four that may move.
|
||||
List<Widget> _actions(bool cupertino, List<String> pressed) => [
|
||||
List<Widget> _actions(List<String> pressed) => [
|
||||
for (final name in _names)
|
||||
if (name == 'Needs you')
|
||||
_icon(cupertino, name, () => pressed.add(name))
|
||||
_icon(name, () => pressed.add(name))
|
||||
else
|
||||
SegmentedOverflowAction(
|
||||
overflowEntry: SegmentedOverflowEntry(
|
||||
@@ -33,19 +33,18 @@ List<Widget> _actions(bool cupertino, List<String> pressed) => [
|
||||
icon: Icons.circle_outlined,
|
||||
onPressed: () => pressed.add(name),
|
||||
),
|
||||
child: _icon(cupertino, name, () => pressed.add(name)),
|
||||
child: _icon(name, () => pressed.add(name)),
|
||||
),
|
||||
];
|
||||
|
||||
Widget _app(bool cupertino, SegmentedBar bar, {Brightness? brightness}) =>
|
||||
MaterialApp(
|
||||
theme: ThemeData(brightness: brightness ?? Brightness.light),
|
||||
home: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: bar,
|
||||
body: const SizedBox.expand(),
|
||||
),
|
||||
);
|
||||
Widget _app(SegmentedBar bar, {Brightness? brightness}) => MaterialApp(
|
||||
theme: ThemeData(brightness: brightness ?? Brightness.light),
|
||||
home: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: bar,
|
||||
body: const SizedBox.expand(),
|
||||
),
|
||||
);
|
||||
|
||||
/// Pumps the bar and the frame its More menu settles in.
|
||||
Future<void> _pump(WidgetTester tester, Widget app) async {
|
||||
@@ -66,7 +65,6 @@ bool _whole(WidgetTester tester, String text) {
|
||||
|
||||
void main() {
|
||||
{
|
||||
const cupertino = false;
|
||||
const host = 'Material';
|
||||
for (final width in [240.0, 270.0, 320.0]) {
|
||||
for (final brightness in Brightness.values) {
|
||||
@@ -79,13 +77,8 @@ void main() {
|
||||
await _pump(
|
||||
tester,
|
||||
_app(
|
||||
cupertino,
|
||||
brightness: brightness,
|
||||
SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
title: 'Runs',
|
||||
actions: _actions(cupertino, pressed),
|
||||
),
|
||||
SegmentedBar(title: 'Runs', actions: _actions(pressed)),
|
||||
),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
@@ -139,14 +132,7 @@ void main() {
|
||||
_size(tester, 800);
|
||||
await _pump(
|
||||
tester,
|
||||
_app(
|
||||
cupertino,
|
||||
SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
title: 'Runs',
|
||||
actions: _actions(cupertino, []),
|
||||
),
|
||||
),
|
||||
_app(SegmentedBar(title: 'Runs', actions: _actions([]))),
|
||||
);
|
||||
for (final name in _names) {
|
||||
expect(find.byKey(_key(name)).hitTestable(), findsOneWidget);
|
||||
@@ -162,14 +148,7 @@ void main() {
|
||||
_size(tester, 240);
|
||||
await _pump(
|
||||
tester,
|
||||
_app(
|
||||
cupertino,
|
||||
SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
title: 'Pipelines',
|
||||
actions: _actions(cupertino, []),
|
||||
),
|
||||
),
|
||||
_app(SegmentedBar(title: 'Pipelines', actions: _actions([]))),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
// The test font's glyphs are squares, wider than a real font's, so
|
||||
@@ -189,9 +168,7 @@ void main() {
|
||||
await _pump(
|
||||
tester,
|
||||
_app(
|
||||
cupertino,
|
||||
SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
title: 'Runs',
|
||||
actions: [
|
||||
for (final name in ['A', 'B', 'C'])
|
||||
@@ -208,7 +185,7 @@ void main() {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: _icon(cupertino, name, () {}),
|
||||
child: _icon(name, () {}),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -47,7 +47,6 @@ void main() {
|
||||
home: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(
|
||||
cupertino: false,
|
||||
leading: const BackButton(),
|
||||
title: 'A conversation with a rather long title indeed',
|
||||
subtitle: 'tank',
|
||||
@@ -69,8 +68,7 @@ void main() {
|
||||
testWidgets('320px at 2x text lays out without overflow', (tester) async {
|
||||
_size(tester, 320, scale: 2);
|
||||
final bar = SegmentedBar(
|
||||
cupertino: false,
|
||||
leading: SegmentedBackButton(cupertino: false, onPressed: () {}),
|
||||
leading: SegmentedBackButton(onPressed: () {}),
|
||||
title: 'A long conversation title',
|
||||
subtitle: 'a-working-folder',
|
||||
subtitleIcon: Icons.folder_outlined,
|
||||
@@ -103,7 +101,6 @@ void main() {
|
||||
home: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(
|
||||
cupertino: false,
|
||||
leading: BackButton(onPressed: () => back++),
|
||||
title: 'Short',
|
||||
),
|
||||
@@ -130,7 +127,7 @@ void main() {
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SegmentedBarOverlay(
|
||||
bar: const SegmentedBar(cupertino: false, title: 'Overlay'),
|
||||
bar: const SegmentedBar(title: 'Overlay'),
|
||||
child: ListView(
|
||||
children: const [ListTile(title: Text('First row'))],
|
||||
),
|
||||
@@ -152,7 +149,7 @@ void main() {
|
||||
home: MediaQuery(
|
||||
data: MediaQueryData(highContrast: highContrast),
|
||||
child: Scaffold(
|
||||
appBar: const SegmentedBar(cupertino: false, title: 'Glass'),
|
||||
appBar: const SegmentedBar(title: 'Glass'),
|
||||
body: const SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
@@ -170,7 +167,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: SegmentedBar(cupertino: false, title: 'Title'),
|
||||
appBar: SegmentedBar(title: 'Title'),
|
||||
body: SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -41,7 +41,6 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
page(
|
||||
SegmentedBar(
|
||||
cupertino: false,
|
||||
title: 'Search',
|
||||
titleWidget: field,
|
||||
titleWidgetMaxWidth: 840,
|
||||
@@ -71,9 +70,8 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
page(
|
||||
SegmentedBar(
|
||||
cupertino: false,
|
||||
title: 'Search',
|
||||
leading: SegmentedBackButton(cupertino: false, onPressed: () {}),
|
||||
leading: SegmentedBackButton(onPressed: () {}),
|
||||
titleWidget: field,
|
||||
titleWidgetMaxWidth: 600,
|
||||
actions: const [Icon(Icons.info_outline, key: Key('action'))],
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
|
||||
@@ -23,13 +22,8 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
Widget page(Widget body, {bool cupertino = false}) {
|
||||
final bar = SegmentedBar(cupertino: cupertino, title: 'Page');
|
||||
if (cupertino) {
|
||||
return CupertinoApp(
|
||||
home: CupertinoPageScaffold(navigationBar: bar, child: body),
|
||||
);
|
||||
}
|
||||
Widget page(Widget body) {
|
||||
final bar = SegmentedBar(title: 'Page');
|
||||
return MaterialApp(
|
||||
home: Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: body),
|
||||
);
|
||||
@@ -46,13 +40,13 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
{
|
||||
const host = 'Material';
|
||||
|
||||
testWidgets('$host: a list reaches the top edge, starts below the bar at '
|
||||
'rest and scrolls behind it', (tester) async {
|
||||
await setSize(tester, const Size(390, 844));
|
||||
await tester.pumpWidget(page(rows(), cupertino: cupertino));
|
||||
await tester.pumpWidget(page(rows()));
|
||||
|
||||
expect(tester.getTopLeft(find.byKey(const Key('list'))).dy, 0);
|
||||
final bar = barRect(tester);
|
||||
@@ -162,7 +156,6 @@ void main() {
|
||||
child: FloatingBarOverlay(
|
||||
edge: FloatingBarEdge.top,
|
||||
bar: FloatingDestinationBar(
|
||||
cupertino: false,
|
||||
edge: FloatingBarEdge.top,
|
||||
currentIndex: 0,
|
||||
onTap: (_) {},
|
||||
|
||||
@@ -18,7 +18,7 @@ void _window(WidgetTester tester, {double top = 10, double width = 800}) {
|
||||
}
|
||||
|
||||
SegmentedBar _bar({String title = 'Chat', List<Widget> actions = const []}) =>
|
||||
SegmentedBar(cupertino: false, title: title, actions: actions);
|
||||
SegmentedBar(title: title, actions: actions);
|
||||
|
||||
Widget _page(SegmentedBar bar, {ValueListenable<Rect?>? controls}) {
|
||||
final page = Scaffold(
|
||||
|
||||
@@ -138,7 +138,7 @@ void main() {
|
||||
final context = tester.element(row);
|
||||
expect(
|
||||
tester.widget<Material>(surface).color,
|
||||
AppListRow.selectedColor(context, cupertino: false),
|
||||
AppListRow.selectedColor(context),
|
||||
);
|
||||
final accent = Theme.of(context).colorScheme.primary;
|
||||
expect(_paint(tester, 'Fixture run').fontWeight, FontWeight.w700);
|
||||
|
||||
@@ -31,7 +31,6 @@ class _List extends StatelessWidget {
|
||||
onTap: () => Navigator.of(context).push(
|
||||
ContainerTransformPageRoute<void>(
|
||||
link: sources.link(() => id),
|
||||
cupertino: false,
|
||||
builder: (_) => _Page(id: id),
|
||||
),
|
||||
),
|
||||
@@ -172,7 +171,6 @@ void main() {
|
||||
navigator.push(
|
||||
ContainerTransformPageRoute<void>(
|
||||
link: sources.link(() => 'missing'),
|
||||
cupertino: false,
|
||||
builder: (_) => const _Page(id: 'x'),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
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';
|
||||
@@ -14,7 +13,6 @@ Widget _row(List<Widget> children) {
|
||||
BarIconButton _action(Key key, {bool busy = false}) => BarIconButton(
|
||||
key: key,
|
||||
icon: Icons.refresh,
|
||||
cupertinoIcon: CupertinoIcons.refresh,
|
||||
label: 'Refresh',
|
||||
busy: busy,
|
||||
onPressed: () {},
|
||||
|
||||
@@ -19,13 +19,12 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
test('page backgrounds are gray in dark mode and unchanged in light', () {
|
||||
expect(AppColors.background.darkColor, const Color(0xFF141416));
|
||||
expect(AppColors.background.color, const Color(0xFFFFFFFF));
|
||||
expect(
|
||||
AppColors.groupedBackground.darkColor,
|
||||
isNot(const Color(0xFF000000)),
|
||||
);
|
||||
test('page backgrounds use their Material surface roles', () {
|
||||
final dark = appDarkTheme();
|
||||
final light = appLightTheme();
|
||||
expect(dark.scaffoldBackgroundColor, dark.colorScheme.surface);
|
||||
expect(light.scaffoldBackgroundColor, light.colorScheme.surface);
|
||||
expect(dark.colorScheme.surface, isNot(const Color(0xFF000000)));
|
||||
});
|
||||
|
||||
test('Android pages retain native predictive Back in both themes', () {
|
||||
|
||||
Reference in New Issue
Block a user