todo-app/lib/ui/capture_confirm_mark.dart
Krzysztof kuhy Rudnicki 3a747c2e51
Some checks failed
dependency freshness / dependencies on newest stable (push) Has been cancelled
file-length / file length <= 250 lines (push) Has been cancelled
md-naming / markdown naming convention (push) Has been cancelled
release-apk / release (APK) (push) Has been cancelled
repo-contract / repo contract (push) Has been cancelled
Report errors and slow waits to the board
crdt_sync_flutter 0.9.0's installAppErrors in main(): uncaught errors and
every spinner shown over 1 s (WaitWatch: sync.run, mirror.test) upload to
RTDB /todo/errors/<device> with the versionCode, where the PC app-errors
ingest files board tickets (kuhyx/utils DOCS-app-errors.md).

The app moves to material_ui first: sync_settings_ui 0.8.x and
design_system 0.4.x sit on it, and Flutter 3.50 deprecates
flutter/material. Pins: crdt_sync 0.14.1, csf 0.9.0, ssui 0.8.3,
gda 0.5.1, design_system 0.4.1, image 4.13.1, mcp_dart 2.4.4.
file_picker stays 13.3.3, held by data_transfer_flutter 0.2.2
(allowlisted, self-clearing).

appRoute takes a route name so each report names its screen; the
release build passes APP_BUILD/APP_VERSION. Nothing new on screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 23:07:58 +01:00

92 lines
2.5 KiB
Dart

/// The checkmark confirming a capture; static under "remove animations".
library;
import 'package:design_system/design_system.dart';
import 'package:flutter/foundation.dart';
import 'package:material_ui/material_ui.dart';
/// Plays once each time [captured] changes value.
class CaptureConfirmMark extends StatefulWidget {
/// Creates the mark.
const CaptureConfirmMark({required this.captured, super.key});
/// Key of the checkmark icon while it is visible.
static const ValueKey<String> iconKey = ValueKey('capture-confirm-icon');
/// Width always reserved, so the counter beside it never moves.
static const double slotWidth = 24;
/// Fade in, hold and fade out: three [AppDuration.base] thirds.
static final Duration duration = AppDuration.base * 3;
/// Counts captures; each change plays the confirmation.
final ValueListenable<int> captured;
@override
State<CaptureConfirmMark> createState() => _CaptureConfirmMarkState();
}
class _CaptureConfirmMarkState extends State<CaptureConfirmMark>
with SingleTickerProviderStateMixin {
late final AnimationController _controller = AnimationController(
vsync: this,
duration: CaptureConfirmMark.duration,
animationBehavior: AnimationBehavior.preserve,
);
@override
void initState() {
super.initState();
widget.captured.addListener(_play);
}
@override
void dispose() {
widget.captured.removeListener(_play);
_controller.dispose();
super.dispose();
}
void _play() => _controller.forward(from: 0);
double _opacity({required bool reduced}) {
final t = _controller.value;
if (reduced || (t >= 1 / 3 && t < 2 / 3)) return 1;
if (t < 1 / 3) return AppCurve.decelerate.transform(t * 3);
return 1 - AppCurve.accelerate.transform((t - 2 / 3) * 3);
}
@override
Widget build(BuildContext context) {
final reduced = MediaQuery.disableAnimationsOf(context);
return SizedBox(
width: CaptureConfirmMark.slotWidth,
child: AnimatedBuilder(
animation: _controller,
builder: (context, _) {
if (!_controller.isAnimating) return const SizedBox.shrink();
return Opacity(
opacity: _opacity(reduced: reduced),
child: const _CheckIcon(),
);
},
),
);
}
}
class _CheckIcon extends StatelessWidget {
const _CheckIcon();
@override
Widget build(BuildContext context) {
final color = Theme.of(context).colorScheme.primary;
return Icon(
Icons.check_circle,
key: CaptureConfirmMark.iconKey,
size: 18,
color: color,
);
}
}