Make compact Dock persistent and support week swipes

This commit is contained in:
Codex
2026-10-14 09:49:53 +08:00
parent fe23c65fd9
commit caf7abe0c0
11 changed files with 474 additions and 363 deletions
+36 -37
View File
@@ -54,7 +54,7 @@ void main() {
await tester.pumpAndSettle();
final glass = find.byType(GlassRefraction);
expect(glass, findsNWidgets(2));
expect(tester.getSize(glass.first), const Size(264, 68));
expect(tester.getSize(glass.first), const Size(264, 58));
expect(
tester.widget<GlassRefraction>(glass.first).strength,
greaterThan(0),
@@ -101,42 +101,41 @@ void main() {
expect(tester.getSize(lens).width, closeTo(resting.width, 0.5));
expect(tester.getSize(lens).height, closeTo(resting.height, 0.5));
});
testWidgets(
'Dock stays visible while sliding down instead of abruptly fading',
(tester) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final c = uiController();
await c.initialize();
await c.showDemo();
await tester.pumpWidget(HepanApp(controller: c));
await tester.pumpAndSettle();
final dock = find.byType(GlassDock);
final before = tester.getRect(dock);
final gesture = await tester.startGesture(
tester.getCenter(find.text('周三')),
);
await gesture.moveBy(const Offset(0, -80));
await tester.pump();
await tester.pump(const Duration(milliseconds: 120));
final fading = find.ancestor(
of: dock,
matching: find.byType(FadeTransition),
);
final opacity = fading.evaluate().isEmpty
? 1.0
: tester.widget<FadeTransition>(fading.first).opacity.value;
expect(opacity, greaterThan(0.95));
expect(tester.getRect(dock).top, greaterThan(before.top));
expect(tester.getRect(dock).top, lessThan(844));
await gesture.up();
await tester.pumpAndSettle();
expect(dock.hitTestable(), findsNothing);
c.dispose();
},
);
testWidgets('Dock stays stationary and tappable while scrolling timetable', (
tester,
) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final c = uiController();
await c.initialize();
await c.showDemo();
await tester.pumpWidget(HepanApp(controller: c));
await tester.pumpAndSettle();
final dock = find.byType(GlassDock);
final before = tester.getRect(dock);
final gesture = await tester.startGesture(
tester.getCenter(find.text('周三')),
);
await gesture.moveBy(const Offset(0, -80));
await tester.pump();
await tester.pump(const Duration(milliseconds: 120));
final fading = find.ancestor(
of: dock,
matching: find.byType(FadeTransition),
);
final opacity = fading.evaluate().isEmpty
? 1.0
: tester.widget<FadeTransition>(fading.first).opacity.value;
expect(opacity, greaterThan(0.95));
expect(tester.getRect(dock), before);
expect(tester.getRect(dock).top, lessThan(844));
await gesture.up();
await tester.pumpAndSettle();
expect(dock.hitTestable(), findsOneWidget);
c.dispose();
});
}
Widget _dock({bool reduceMotion = false}) {