Refine milky Dock and refract symbols beneath the moving lens

This commit is contained in:
david1465833828
2026-10-28 17:56:40 +08:00
parent dc71e411e9
commit 23c1a58ca3
10 changed files with 351 additions and 160 deletions
+52
View File
@@ -9,6 +9,58 @@ import 'navigation_test.dart' show uiController;
void main() {
setUpAll(tzdata.initializeTimeZones);
testWidgets('only the selected tab is blue, including during glass travel', (
tester,
) async {
var selected = 0;
await tester.pumpWidget(
MaterialApp(
home: StatefulBuilder(
builder: (context, setState) => Scaffold(
body: Center(
child: GlassDock(
selectedIndex: selected,
onSelected: (index) => setState(() => selected = index),
),
),
),
),
),
);
Color colour(IconData icon) =>
tester.widget<Icon>(find.byIcon(icon)).color!;
void expectGrey(IconData icon) {
final value = colour(icon);
expect((value.r - value.b).abs(), lessThan(0.12));
expect(value.a, 1);
}
expect(colour(Icons.calendar_month_rounded), const Color(0xFF007AFF));
expectGrey(Icons.assignment_rounded);
expectGrey(Icons.person_rounded);
await tester.tap(find.byIcon(Icons.person_rounded));
await tester.pump();
// Colour follows the selected page, not whichever icon the lens crosses.
expect(colour(Icons.person_rounded), const Color(0xFF007AFF));
expectGrey(Icons.calendar_month_rounded);
await tester.pump(const Duration(milliseconds: 100));
expectGrey(Icons.assignment_rounded);
await tester.pumpAndSettle();
final gesture = await tester.startGesture(
tester.getCenter(find.byKey(const Key('dock-cursor'))),
);
await gesture.moveBy(const Offset(-20, 0));
await tester.pump();
await gesture.moveBy(const Offset(-90, 0));
await tester.pump(const Duration(milliseconds: 150));
expect(colour(Icons.person_rounded), const Color(0xFF007AFF));
expectGrey(Icons.assignment_rounded);
await gesture.up();
await tester.pumpAndSettle();
expect(selected, 1);
expect(colour(Icons.assignment_rounded), const Color(0xFF007AFF));
expectGrey(Icons.person_rounded);
});
testWidgets('dock drags switch tabs while body swipes only change week', (
tester,
) async {