wake-alarm/phone_app/lib/ui/motion_route.dart
Krzysztof kuhy Rudnicki 38fb4f3763 Add motion tokens and haptics to the phone app
Motion tokens hand-copied from DOCS-motion.md into theme.dart; every
page route goes through appRoute() (slow, decelerate in, accelerate
out, instant under Remove animations). mediumImpact on the picker
confirm, heavyImpact on a refused time. The Clock app line shows only
when the SET_ALARM handoff finished before its 3 s timeout. Sound is
skipped on purpose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 08:09:48 +01:00

28 lines
1019 B
Dart

/// The app's one page route: slow slide, decelerate in, accelerate out.
library;
import 'package:material_ui/material_ui.dart';
import 'package:wake_alarm_sync/ui/theme.dart';
/// A route to [builder]'s page using the shared motion tokens; instant under
/// the OS "Remove animations" setting.
PageRoute<T> appRoute<T>(BuildContext context, WidgetBuilder builder) {
final duration = motionDuration(context, MotionDuration.slow);
return PageRouteBuilder<T>(
transitionDuration: duration,
reverseTransitionDuration: duration,
pageBuilder: (context, _, _) => builder(context),
transitionsBuilder: (context, animation, secondary, child) {
final slide = Tween<Offset>(begin: const Offset(1, 0), end: Offset.zero)
.animate(
CurvedAnimation(
parent: animation,
curve: MotionCurve.decelerate,
reverseCurve: MotionCurve.accelerate,
),
);
return SlideTransition(position: slide, child: child);
},
);
}