Initial commit: Krow Worker App

This commit is contained in:
R-Bharathraj
2026-09-17 22:26:11 +05:30
commit cafffd27e0
113 changed files with 13067 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:go_router/go_router.dart';
import 'package:krow_worker_app/core/transitions.dart';
const _detail = Key('detail');
GoRouter buildRouter() => GoRouter(
routes: [
GoRoute(
path: '/',
builder: (_, _) => const Scaffold(body: Text('home')),
),
GoRoute(
path: '/detail',
pageBuilder: (_, state) => Transitions.push(
state,
const Scaffold(body: SizedBox.expand(key: _detail)),
),
),
GoRoute(
path: '/replaced',
pageBuilder: (_, state) => Transitions.fade(
state,
const Scaffold(body: SizedBox.expand(key: _detail)),
),
),
],
);
void main() {
group('Transitions.push', () {
testWidgets('settles flush against the left edge', (tester) async {
final router = buildRouter();
addTearDown(router.dispose);
await tester.pumpWidget(MaterialApp.router(routerConfig: router));
router.push('/detail');
await tester.pumpAndSettle();
// The page is driven by two animations at once, and its resting state
// comes from the one that is *not* running. Reversing that tween leaves
// the screen parked off to the side, which is easy to miss in code and
// obvious on a phone.
final rect = tester.getRect(find.byKey(_detail));
expect(rect.left, 0);
expect(
rect.width,
tester.view.physicalSize.width / tester.view.devicePixelRatio,
);
});
testWidgets('enters from the right rather than appearing', (tester) async {
final router = buildRouter();
addTearDown(router.dispose);
await tester.pumpWidget(MaterialApp.router(routerConfig: router));
router.push('/detail');
await tester.pump();
await tester.pump(const Duration(milliseconds: 80));
expect(tester.getRect(find.byKey(_detail)).left, greaterThan(0));
});
});
group('Transitions.fade', () {
testWidgets('settles flush and fully opaque', (tester) async {
final router = buildRouter();
addTearDown(router.dispose);
await tester.pumpWidget(MaterialApp.router(routerConfig: router));
router.push('/replaced');
await tester.pumpAndSettle();
expect(tester.getRect(find.byKey(_detail)).left, 0);
final fade = tester.widget<FadeTransition>(
find
.ancestor(
of: find.byKey(_detail),
matching: find.byType(FadeTransition),
)
.first,
);
expect(fade.opacity.value, 1);
});
});
}