feat: REV-004 — spring elasticOut animation on review submit success

This commit is contained in:
2026-04-04 17:39:32 +05:30
parent e3f501ae4b
commit 3729ee0abf

View File

@@ -23,13 +23,16 @@ class ReviewForm extends StatefulWidget {
enum _FormState { idle, loading, success } enum _FormState { idle, loading, success }
class _ReviewFormState extends State<ReviewForm> { class _ReviewFormState extends State<ReviewForm> with SingleTickerProviderStateMixin {
int _rating = 0; int _rating = 0;
final _commentController = TextEditingController(); final _commentController = TextEditingController();
_FormState _state = _FormState.idle; _FormState _state = _FormState.idle;
bool _isLoggedIn = false; bool _isLoggedIn = false;
String? _error; String? _error;
late final AnimationController _checkController;
late final Animation<double> _checkScale;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@@ -38,6 +41,8 @@ class _ReviewFormState extends State<ReviewForm> {
_rating = widget.existingReview!.rating; _rating = widget.existingReview!.rating;
_commentController.text = widget.existingReview!.comment ?? ''; _commentController.text = widget.existingReview!.comment ?? '';
} }
_checkController = AnimationController(vsync: this, duration: const Duration(milliseconds: 600));
_checkScale = CurvedAnimation(parent: _checkController, curve: Curves.elasticOut);
} }
Future<void> _checkAuth() async { Future<void> _checkAuth() async {
@@ -56,6 +61,7 @@ class _ReviewFormState extends State<ReviewForm> {
await widget.onSubmit(_rating, _commentController.text); await widget.onSubmit(_rating, _commentController.text);
if (mounted) { if (mounted) {
setState(() => _state = _FormState.success); setState(() => _state = _FormState.success);
_checkController.forward(from: 0);
Future.delayed(const Duration(seconds: 3), () { Future.delayed(const Duration(seconds: 3), () {
if (mounted) setState(() => _state = _FormState.idle); if (mounted) setState(() => _state = _FormState.idle);
}); });
@@ -68,6 +74,7 @@ class _ReviewFormState extends State<ReviewForm> {
@override @override
void dispose() { void dispose() {
_commentController.dispose(); _commentController.dispose();
_checkController.dispose();
super.dispose(); super.dispose();
} }
@@ -106,10 +113,13 @@ class _ReviewFormState extends State<ReviewForm> {
), ),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: const [ children: [
Icon(Icons.check_circle, color: Color(0xFF10B981), size: 24), ScaleTransition(
SizedBox(width: 8), scale: _checkScale,
Text('Review submitted!', style: TextStyle(color: Color(0xFF10B981), fontWeight: FontWeight.w600, fontSize: 15)), child: const Icon(Icons.check_circle, color: Color(0xFF10B981), size: 24),
),
const SizedBox(width: 8),
const Text('Review submitted!', style: TextStyle(color: Color(0xFF10B981), fontWeight: FontWeight.w600, fontSize: 15)),
], ],
), ),
) )