Top bar: every piece pops in like the tab buttons
One shared pop (pop_entrance.dart: PopTransition, popWindow, PopEntrance) drives the floating tab buttons and the top bar, on Motion.tabEntrance* (0.6 -> 1, 260 ms, 70 ms stagger, ease-out-back, glass fading in). SegmentedEntrance and the barEntrance* constants are gone. Back, the title, the actions pill and each action pop in turn from the leading edge (SegmentedEntrancePlanner). A lone action pops once, with its pill. A newcomer pops alone. Rebuilds and title changes never replay it. The shell passes published actions one by one, keyed by their screen (actionsKey), not as one cross-fading Row. The chat thread's model and mode are separate actions. The folder picker now uses SegmentedBar.
This commit is contained in:
@@ -138,7 +138,9 @@ void main() {
|
||||
// Content may still extend under the bars and the status bar.
|
||||
expect(tester.getTopLeft(find.byKey(const Key('list'))).dy, 0);
|
||||
expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0);
|
||||
// At rest the first rows start below the bars.
|
||||
// At rest (the bars' pieces have popped in) the first rows start
|
||||
// below the bars.
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
final paneBottom = pillsOf(tester, paneBar).first.bottom;
|
||||
expect(
|
||||
tester.getTopLeft(find.text('item 0')).dy,
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/pop_entrance.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
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, {
|
||||
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: () {},
|
||||
),
|
||||
actions: actions,
|
||||
actionsKey: actionsKey,
|
||||
);
|
||||
final Widget home = cupertino
|
||||
? CupertinoPageScaffold(
|
||||
navigationBar: bar,
|
||||
child: const SizedBox.expand(),
|
||||
)
|
||||
: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: bar,
|
||||
body: const SizedBox.expand(),
|
||||
);
|
||||
final app = cupertino ? CupertinoApp(home: home) : MaterialApp(home: home);
|
||||
return MediaQuery(
|
||||
data: MediaQueryData(disableAnimations: reduced),
|
||||
child: app,
|
||||
);
|
||||
}
|
||||
|
||||
/// The entrance scale of the piece holding [of]: its pill's, or with
|
||||
/// [inner] its own inside the actions pill.
|
||||
double scaleOf(WidgetTester tester, Finder of, {bool inner = false}) {
|
||||
final entrances = find.ancestor(of: of, matching: find.byType(PopEntrance));
|
||||
final entrance = inner ? entrances.first : entrances.last;
|
||||
// The pop rises (a translation), then scales.
|
||||
final transform = tester.widget<Transform>(
|
||||
find.descendant(of: entrance, matching: find.byType(Transform)).at(1),
|
||||
);
|
||||
return transform.transform.storage[0];
|
||||
}
|
||||
|
||||
final back = find.byKey(const Key('back'));
|
||||
final title = find.text('Runs');
|
||||
const begin = Motion.tabEntranceScaleBegin;
|
||||
const step = Motion.tabEntranceStagger;
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
final icon = cupertino ? CupertinoIcons.refresh : Icons.refresh;
|
||||
Widget action(String key) =>
|
||||
IconButton(key: Key(key), icon: Icon(icon), onPressed: () {});
|
||||
final a = find.byKey(const Key('a'));
|
||||
final b = find.byKey(const Key('b'));
|
||||
|
||||
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')]),
|
||||
);
|
||||
expect(scaleOf(tester, back), begin);
|
||||
expect(scaleOf(tester, title), begin);
|
||||
expect(scaleOf(tester, a), begin, reason: 'the pill');
|
||||
expect(scaleOf(tester, a, inner: true), begin);
|
||||
expect(scaleOf(tester, b, inner: true), begin);
|
||||
// Back, the title, the pill, then each action: one stagger apart.
|
||||
await tester.pump(step * 2 + const Duration(milliseconds: 20));
|
||||
final backNow = scaleOf(tester, back);
|
||||
final titleNow = scaleOf(tester, title);
|
||||
final pillNow = scaleOf(tester, a);
|
||||
expect(backNow, greaterThan(titleNow), reason: 'Back leads');
|
||||
expect(titleNow, greaterThan(pillNow), reason: 'the title follows');
|
||||
expect(pillNow, greaterThan(begin), reason: 'the pill has started');
|
||||
expect(scaleOf(tester, a, inner: true), begin, reason: 'a waits');
|
||||
await tester.pump(step);
|
||||
expect(scaleOf(tester, a, inner: true), greaterThan(begin));
|
||||
expect(scaleOf(tester, b, inner: true), begin, reason: 'b waits for a');
|
||||
await tester.pump(step);
|
||||
expect(scaleOf(tester, b, inner: true), greaterThan(begin));
|
||||
await tester.pumpAndSettle();
|
||||
for (final scale in [
|
||||
scaleOf(tester, back),
|
||||
scaleOf(tester, title),
|
||||
scaleOf(tester, a),
|
||||
scaleOf(tester, a, inner: true),
|
||||
scaleOf(tester, b, inner: true),
|
||||
]) {
|
||||
expect(scale, 1);
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('$host: a lone action pops as its pill, not twice', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino, actions: [action('a')]));
|
||||
expect(scaleOf(tester, a), begin);
|
||||
expect(scaleOf(tester, a, inner: true), 1);
|
||||
await tester.pump(step * 2 + const Duration(milliseconds: 40));
|
||||
expect(scaleOf(tester, a), greaterThan(begin));
|
||||
expect(scaleOf(tester, a, inner: true), 1);
|
||||
await tester.pumpAndSettle();
|
||||
expect(scaleOf(tester, a), 1);
|
||||
});
|
||||
|
||||
testWidgets('$host: a rebuild or new title does not replay it', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino, actions: [action('a')]));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, title: 'Other', actions: [action('a')]),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(scaleOf(tester, back), 1);
|
||||
expect(scaleOf(tester, find.text('Other')), 1);
|
||||
expect(scaleOf(tester, a), 1);
|
||||
expect(scaleOf(tester, a, inner: true), 1);
|
||||
expect(tester.hasRunningAnimations, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('$host: an action that becomes available pops in alone', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino, actions: [action('a')]));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, 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);
|
||||
expect(scaleOf(tester, a, inner: true), 1);
|
||||
expect(scaleOf(tester, back), 1);
|
||||
expect(scaleOf(tester, title), 1);
|
||||
await tester.pump(Motion.tabEntranceDuration ~/ 2);
|
||||
expect(scaleOf(tester, b, inner: true), greaterThan(0.9));
|
||||
await tester.pumpAndSettle();
|
||||
expect(scaleOf(tester, b, inner: true), 1);
|
||||
});
|
||||
|
||||
testWidgets('$host: a tab switch keeps what stays, pops what is new', (
|
||||
tester,
|
||||
) async {
|
||||
final list = Object();
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, 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.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')],
|
||||
),
|
||||
);
|
||||
expect(scaleOf(tester, back), 1);
|
||||
expect(scaleOf(tester, find.text('Chats')), 1);
|
||||
expect(scaleOf(tester, a), 1, reason: 'the pill stays');
|
||||
expect(scaleOf(tester, a, inner: true), begin);
|
||||
expect(scaleOf(tester, b, inner: true), begin);
|
||||
await tester.pump(step);
|
||||
expect(scaleOf(tester, a, inner: true), greaterThan(begin));
|
||||
expect(scaleOf(tester, b, inner: true), begin);
|
||||
await tester.pumpAndSettle();
|
||||
expect(scaleOf(tester, b, inner: true), 1);
|
||||
});
|
||||
|
||||
testWidgets('$host: a pill arriving later pops, then its actions', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, 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');
|
||||
expect(scaleOf(tester, a, inner: true), begin);
|
||||
await tester.pump(step);
|
||||
expect(scaleOf(tester, a, inner: true), greaterThan(begin));
|
||||
expect(scaleOf(tester, b, inner: true), begin);
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
|
||||
testWidgets('$host: reduced motion shows the bar at once', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, actions: [action('a'), action('b')], reduced: true),
|
||||
);
|
||||
expect(scaleOf(tester, back), 1);
|
||||
expect(scaleOf(tester, title), 1);
|
||||
expect(scaleOf(tester, a), 1);
|
||||
expect(scaleOf(tester, a, inner: true), 1);
|
||||
expect(scaleOf(tester, b, inner: true), 1);
|
||||
expect(tester.hasRunningAnimations, isFalse);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,8 @@ import 'package:pipelines_app/ui/adaptive/segmented_bar_motion.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar_pieces.dart';
|
||||
import 'package:pipelines_app/ui/motion/motion.dart';
|
||||
|
||||
/// The top bar's islands pop in once, and its controls sink when pressed.
|
||||
/// 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, {
|
||||
@@ -46,20 +47,6 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
/// The entrance scale of the island holding [of]: its pill's, or with
|
||||
/// [inner] its own inside the actions pill.
|
||||
double entranceScale(WidgetTester tester, Finder of, {bool inner = false}) {
|
||||
final entrances = find.ancestor(
|
||||
of: of,
|
||||
matching: find.byType(SegmentedEntrance),
|
||||
);
|
||||
final entrance = inner ? entrances.first : entrances.last;
|
||||
final transform = tester.widget<Transform>(
|
||||
find.descendant(of: entrance, matching: find.byType(Transform)).first,
|
||||
);
|
||||
return transform.transform.storage[0];
|
||||
}
|
||||
|
||||
/// The press scale of the control holding [of], or with [pill] of the
|
||||
/// pill holding it.
|
||||
double pressScale(WidgetTester tester, Finder of, {bool pill = false}) {
|
||||
@@ -93,77 +80,12 @@ void main() {
|
||||
Widget action(String key) =>
|
||||
IconButton(key: Key(key), icon: Icon(icon), onPressed: () {});
|
||||
|
||||
testWidgets('$host: the islands pop in left to right on first show', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino, actions: [action('a')]));
|
||||
final a = find.byKey(const Key('a'));
|
||||
expect(entranceScale(tester, back), Motion.barEntranceScaleBegin);
|
||||
await tester.pump(const Duration(milliseconds: 120));
|
||||
final b = entranceScale(tester, back);
|
||||
final t = entranceScale(tester, title);
|
||||
final r = entranceScale(tester, a);
|
||||
expect(b, greaterThan(t), reason: 'Back leads the title');
|
||||
expect(t, greaterThan(r), reason: 'the title leads the actions');
|
||||
expect(r, greaterThan(Motion.barEntranceScaleBegin));
|
||||
await tester.pumpAndSettle();
|
||||
expect(entranceScale(tester, back), 1);
|
||||
expect(entranceScale(tester, title), 1);
|
||||
expect(entranceScale(tester, a), 1);
|
||||
});
|
||||
|
||||
testWidgets('$host: a rebuild or new title does not replay it', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino, actions: [action('a')]));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, title: 'Other', actions: [action('a')]),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(entranceScale(tester, back), 1);
|
||||
expect(entranceScale(tester, find.text('Other')), 1);
|
||||
expect(entranceScale(tester, find.byKey(const Key('a'))), 1);
|
||||
expect(tester.hasRunningAnimations, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('$host: an action that becomes available pops in alone', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino, actions: [action('a')]));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, actions: [action('b'), action('a')]),
|
||||
);
|
||||
final newcomer = find.byKey(const Key('b'));
|
||||
expect(
|
||||
entranceScale(tester, newcomer, inner: true),
|
||||
Motion.barEntranceScaleBegin,
|
||||
);
|
||||
// The pill and the action already there stay put.
|
||||
expect(entranceScale(tester, find.byKey(const Key('a'))), 1);
|
||||
expect(entranceScale(tester, find.byKey(const Key('a')), inner: true), 1);
|
||||
expect(entranceScale(tester, back), 1);
|
||||
await tester.pump(Motion.barEntranceDuration ~/ 2);
|
||||
expect(entranceScale(tester, newcomer, inner: true), greaterThan(0.9));
|
||||
await tester.pumpAndSettle();
|
||||
expect(entranceScale(tester, newcomer, inner: true), 1);
|
||||
});
|
||||
|
||||
testWidgets('$host: reduced motion shows the bar at once', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, actions: [action('a')], reduced: true),
|
||||
);
|
||||
expect(entranceScale(tester, back), 1);
|
||||
expect(entranceScale(tester, title), 1);
|
||||
expect(tester.hasRunningAnimations, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('$host: the glass fades in with its blur, not under a layer', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino));
|
||||
await tester.pump(const Duration(milliseconds: 40));
|
||||
// Back and the title are both still popping in.
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
final backdrops = tester.layers.whereType<BackdropFilterLayer>().toList();
|
||||
expect(backdrops, hasLength(2), reason: 'Back and the title');
|
||||
expect(backdrops.first.backdropKey, isNotNull, reason: 'still grouped');
|
||||
|
||||
Reference in New Issue
Block a user