mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Switching between the top-level destinations went through the default CupertinoPage slide, which is meant for forward pushes. For a peer tab-switch it slid the incoming screen in over the outgoing one without animating the old screen away, leaving it visible in the background. Give the top-level routes a CustomTransitionPage crossfade; keep the device-detail route on the default slide since it is a genuine drill-in. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
46 lines
1.6 KiB
Dart
46 lines
1.6 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:frontend/navigation.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
void main() {
|
|
// The app's real [router] is configured so that switching between top-level
|
|
// destinations crossfades (a [CustomTransitionPage]) instead of using the
|
|
// default platform slide, which would otherwise leave the outgoing screen
|
|
// visible behind the incoming one. Drilling into a detail screen keeps the
|
|
// default slide (a plain [GoRoute.builder]).
|
|
List<GoRoute> topLevelRoutes() {
|
|
final shell = router.configuration.routes.single as ShellRoute;
|
|
return shell.routes.cast<GoRoute>();
|
|
}
|
|
|
|
GoRoute routeByName(String name) =>
|
|
topLevelRoutes().firstWhere((r) => r.name == name);
|
|
|
|
group('navigation transitions', () {
|
|
test('top-level destinations use a page builder (crossfade)', () {
|
|
for (final name in ['home', 'devices', 'status', 'settings', 'about']) {
|
|
final route = routeByName(name);
|
|
expect(
|
|
route.pageBuilder,
|
|
isNotNull,
|
|
reason: '"$name" should crossfade via a custom page builder',
|
|
);
|
|
expect(route.builder, isNull, reason: '"$name" should not also build');
|
|
}
|
|
});
|
|
|
|
test('the device detail drill-in keeps the default slide builder', () {
|
|
final devices = routeByName('devices');
|
|
final detail = devices.routes.single as GoRoute;
|
|
|
|
expect(detail.name, 'deviceDetail');
|
|
expect(
|
|
detail.builder,
|
|
isNotNull,
|
|
reason: 'the detail push should keep the default platform slide',
|
|
);
|
|
expect(detail.pageBuilder, isNull);
|
|
});
|
|
});
|
|
}
|