feat: bloom tap lens with dock follow and soft edge overflow
This commit is contained in:
@@ -11,6 +11,77 @@ import 'navigation_test.dart' show uiController;
|
||||
|
||||
void main() {
|
||||
setUpAll(tzdata.initializeTimeZones);
|
||||
testWidgets('edge overflow respects the actual dock parent and safe insets', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(320, 800);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
var selected = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: MediaQuery(
|
||||
data: const MediaQueryData(size: Size(320, 800)),
|
||||
child: StatefulBuilder(
|
||||
builder: (context, setState) => Scaffold(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.only(left: 30),
|
||||
child: Center(
|
||||
child: GlassDock(
|
||||
selectedIndex: selected,
|
||||
onSelected: (i) => setState(() => selected = i),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byIcon(Icons.person_rounded));
|
||||
await tester.pump();
|
||||
for (var i = 0; i < 70; i++) {
|
||||
await tester.pump(const Duration(milliseconds: 16));
|
||||
expect(
|
||||
tester.getRect(find.byType(GlassRefraction).last).right,
|
||||
lessThanOrEqualTo(312.5),
|
||||
);
|
||||
}
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
testWidgets(
|
||||
'tap pulls the dock along and enlarged edge lens can overflow its body',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(320, 800);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(_dock());
|
||||
await tester.pumpAndSettle();
|
||||
final dock = find.byType(GlassDock),
|
||||
lens = find.byType(GlassRefraction).last;
|
||||
final icon = find.byIcon(Icons.calendar_month_rounded);
|
||||
final x = tester.getCenter(icon).dx;
|
||||
var pulled = x, overflow = 0.0;
|
||||
await tester.tap(find.byIcon(Icons.person_rounded));
|
||||
await tester.pump();
|
||||
for (var i = 0; i < 70; i++) {
|
||||
await tester.pump(const Duration(milliseconds: 16));
|
||||
pulled = math.max(pulled, tester.getCenter(icon).dx);
|
||||
final r = tester.getRect(lens);
|
||||
overflow = math.max(overflow, r.right - tester.getRect(dock).right);
|
||||
expect(r.left, greaterThanOrEqualTo(7.5));
|
||||
expect(r.right, lessThanOrEqualTo(312.5));
|
||||
}
|
||||
expect(pulled, greaterThan(x + 3));
|
||||
expect(overflow, greaterThan(5));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.getCenter(icon).dx, closeTo(x, 0.1));
|
||||
expect(tester.getRect(lens).right, lessThan(tester.getRect(dock).right));
|
||||
},
|
||||
);
|
||||
testWidgets('drag tugs the leading edge and lens follows with elastic lag', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -79,12 +150,12 @@ void main() {
|
||||
narrowest = narrowest < rect.width ? narrowest : rect.width;
|
||||
tallest = tallest > rect.height ? tallest : rect.height;
|
||||
furthest = furthest > rect.center.dx ? furthest : rect.center.dx;
|
||||
expect(rect.width, lessThan(resting.width * 1.4));
|
||||
expect(rect.center.dx, lessThan(target + 14));
|
||||
expect(rect.width, lessThan(resting.width * 1.7));
|
||||
expect(rect.center.dx, lessThan(target + 22));
|
||||
}
|
||||
expect(widest, greaterThan(resting.width * 1.20));
|
||||
expect(widest, greaterThan(resting.width * 1.40));
|
||||
expect(narrowest, lessThan(resting.width * 0.97));
|
||||
expect(tallest, greaterThan(resting.height * 1.10));
|
||||
expect(tallest, greaterThan(resting.height * 1.25));
|
||||
expect(furthest, greaterThan(target + 0.1));
|
||||
expect(tester.getCenter(lens).dx, closeTo(target, 0.1));
|
||||
expect(tester.getSize(lens).width, closeTo(resting.width, 0.1));
|
||||
|
||||
Reference in New Issue
Block a user