fixed designs and flow
This commit is contained in:
@@ -4,6 +4,8 @@ import 'package:krow_worker_app/core/theme.dart';
|
||||
import 'package:krow_worker_app/widgets/common.dart';
|
||||
import 'package:krow_worker_app/widgets/glass_segments.dart';
|
||||
import 'package:krow_worker_app/widgets/krow_nav_bar.dart';
|
||||
import 'package:krow_worker_app/widgets/motion.dart';
|
||||
import 'package:krow_worker_app/widgets/swipe_action.dart';
|
||||
|
||||
Widget wrap(Widget child) => MaterialApp(
|
||||
theme: buildKrowTheme(),
|
||||
@@ -192,4 +194,86 @@ void main() {
|
||||
expect(calls, 1);
|
||||
});
|
||||
});
|
||||
|
||||
group('Entrance', () {
|
||||
testWidgets('settles opaque and in place', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
Column(
|
||||
children: Entrance.stagger(const [Text('one'), Text('two')]),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
for (final o in tester.widgetList<Opacity>(find.byType(Opacity))) {
|
||||
expect(o.opacity, 1);
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('leaves no timer behind when disposed mid-flight', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
wrap(Column(children: Entrance.stagger(const [Text('one')]))),
|
||||
);
|
||||
|
||||
// Torn down before the entrance finishes. A delay implemented as a
|
||||
// stray timer survives this and fails the test at teardown.
|
||||
await tester.pump(const Duration(milliseconds: 20));
|
||||
await tester.pumpWidget(wrap(const SizedBox()));
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
});
|
||||
|
||||
group('SwipeAction', () {
|
||||
Widget swipe({
|
||||
required VoidCallback onConfirm,
|
||||
bool enabled = true,
|
||||
}) => wrap(
|
||||
SizedBox(
|
||||
width: 320,
|
||||
child: SwipeAction(
|
||||
icon: Icons.login,
|
||||
label: 'Swipe to clock in',
|
||||
enabled: enabled,
|
||||
onConfirm: onConfirm,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
testWidgets('confirms once dragged across the track', (tester) async {
|
||||
var confirms = 0;
|
||||
await tester.pumpWidget(swipe(onConfirm: () => confirms++));
|
||||
|
||||
await tester.drag(find.byIcon(Icons.login), const Offset(320, 0));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(confirms, 1);
|
||||
});
|
||||
|
||||
testWidgets('snaps back when the drag stops short', (tester) async {
|
||||
var confirms = 0;
|
||||
await tester.pumpWidget(swipe(onConfirm: () => confirms++));
|
||||
|
||||
// Well under the commit fraction: a brush, not a deliberate swipe.
|
||||
await tester.drag(find.byIcon(Icons.login), const Offset(60, 0));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(confirms, 0);
|
||||
});
|
||||
|
||||
testWidgets('ignores the drag while disabled', (tester) async {
|
||||
var confirms = 0;
|
||||
await tester.pumpWidget(
|
||||
swipe(onConfirm: () => confirms++, enabled: false),
|
||||
);
|
||||
|
||||
await tester.drag(find.byIcon(Icons.login), const Offset(320, 0));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(confirms, 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user