feat: REV-004 — spring elasticOut animation on review submit success
This commit is contained in:
@@ -23,13 +23,16 @@ class ReviewForm extends StatefulWidget {
|
||||
|
||||
enum _FormState { idle, loading, success }
|
||||
|
||||
class _ReviewFormState extends State<ReviewForm> {
|
||||
class _ReviewFormState extends State<ReviewForm> with SingleTickerProviderStateMixin {
|
||||
int _rating = 0;
|
||||
final _commentController = TextEditingController();
|
||||
_FormState _state = _FormState.idle;
|
||||
bool _isLoggedIn = false;
|
||||
String? _error;
|
||||
|
||||
late final AnimationController _checkController;
|
||||
late final Animation<double> _checkScale;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -38,6 +41,8 @@ class _ReviewFormState extends State<ReviewForm> {
|
||||
_rating = widget.existingReview!.rating;
|
||||
_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 {
|
||||
@@ -56,6 +61,7 @@ class _ReviewFormState extends State<ReviewForm> {
|
||||
await widget.onSubmit(_rating, _commentController.text);
|
||||
if (mounted) {
|
||||
setState(() => _state = _FormState.success);
|
||||
_checkController.forward(from: 0);
|
||||
Future.delayed(const Duration(seconds: 3), () {
|
||||
if (mounted) setState(() => _state = _FormState.idle);
|
||||
});
|
||||
@@ -68,6 +74,7 @@ class _ReviewFormState extends State<ReviewForm> {
|
||||
@override
|
||||
void dispose() {
|
||||
_commentController.dispose();
|
||||
_checkController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -106,10 +113,13 @@ class _ReviewFormState extends State<ReviewForm> {
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const [
|
||||
Icon(Icons.check_circle, color: Color(0xFF10B981), size: 24),
|
||||
SizedBox(width: 8),
|
||||
Text('Review submitted!', style: TextStyle(color: Color(0xFF10B981), fontWeight: FontWeight.w600, fontSize: 15)),
|
||||
children: [
|
||||
ScaleTransition(
|
||||
scale: _checkScale,
|
||||
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)),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user