diet-guard/app/lib/widgets/progress_motion.dart
Krzysztof kuhy Rudnicki 49144a2c49 Move the app to material_ui for Flutter 3.50
Flutter 3.50 deprecates package:flutter/material.dart; 73 deprecation
infos failed flutter analyze --fatal-infos, and four Dart pins were
behind (crdt_sync_flutter 0.8.2, flutter_local_notifications 23.0.2,
github_device_auth 0.5.0, sync_settings_ui 0.8.2). Those UI packages
now sit on material_ui, so the app has to as well or their widgets lose
MaterialLocalizations.

Imports swap one-for-one and dart fix re-sorted the directives; no
behaviour change. analyze is clean and all six test shards pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWWfb63jncj9Lca2jeX
2026-11-16 09:25:34 +01:00

67 lines
2.0 KiB
Dart

/// Motion for the post-log progress card: an entrance and a count-up.
library;
import 'package:diet_guard_app/ui/theme.dart';
import 'package:material_ui/material_ui.dart';
/// Fades [child] in and slides it up by [AppSpacing.md] when first built.
///
/// Key it per card instance to replay it; under reduced motion the first
/// frame is already the final one.
class ProgressEntrance extends StatelessWidget {
/// Creates a [ProgressEntrance].
const ProgressEntrance({required this.child, super.key});
/// The widget to bring in.
final Widget child;
@override
Widget build(BuildContext context) => TweenAnimationBuilder<double>(
tween: Tween<double>(begin: 0, end: 1),
duration: AppDuration.resolve(context, AppDuration.base),
curve: AppCurve.decelerate,
child: child,
builder: (context, t, child) => Opacity(
opacity: t,
child: Transform.translate(
offset: Offset(0, (1 - t) * AppSpacing.md),
child: child,
),
),
);
}
/// Drives [builder] with a number running from [from] to [to].
///
/// Neutral on purpose: it never knows whether the number is "good", so no
/// value gets a different curve or colour for being under budget. The last
/// frame passes [to] untouched, so callers render exactly the static value.
class CountUp extends StatelessWidget {
/// Creates a [CountUp].
const CountUp({
required this.from,
required this.to,
required this.builder,
super.key,
});
/// Starting value.
final double from;
/// Final value.
final double to;
/// Builds the UI for the current animated value.
final Widget Function(BuildContext context, double value) builder;
@override
Widget build(BuildContext context) => TweenAnimationBuilder<double>(
tween: Tween<double>(begin: from, end: to),
duration: from == to
? Duration.zero
: AppDuration.resolve(context, AppDuration.slow),
curve: AppCurve.standard,
builder: (context, value, _) => builder(context, value),
);
}