From 8c2d2588485d2f20f7f066514a6cd77418f561a3 Mon Sep 17 00:00:00 2001 From: Vaibhav Surve Date: Tue, 10 Jun 2025 17:26:35 +0530 Subject: [PATCH] feat: Implement loading state in ForgotPasswordScreen during password reset process --- lib/view/auth/forgot_password_screen.dart | 37 ++++++++++++++++++----- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/lib/view/auth/forgot_password_screen.dart b/lib/view/auth/forgot_password_screen.dart index b3f925b..e6d0c64 100644 --- a/lib/view/auth/forgot_password_screen.dart +++ b/lib/view/auth/forgot_password_screen.dart @@ -24,6 +24,19 @@ class _ForgotPasswordScreenState extends State Get.put(ForgotPasswordController()); bool get _isBetaEnvironment => ApiEndpoints.baseUrl.contains("stage"); + bool _isLoading = false; + + void _handleForgotPassword() async { + setState(() { + _isLoading = true; + }); + + await controller.onForgotPassword(); + + setState(() { + _isLoading = false; + }); + } @override Widget build(BuildContext context) { @@ -96,16 +109,26 @@ class _ForgotPasswordScreenState extends State ), const SizedBox(height: 40), MyButton.rounded( - onPressed: controller.onForgotPassword, + onPressed: + _isLoading ? null : _handleForgotPassword, elevation: 2, padding: MySpacing.xy(80, 16), borderRadiusAll: 10, - backgroundColor: contentTheme.brandRed, - child: MyText.labelLarge( - 'Send Reset Link', - fontWeight: 700, - color: Colors.white, - ), + backgroundColor: _isLoading ? Colors.red.withOpacity(0.6) : contentTheme.brandRed, + child: _isLoading + ? const SizedBox( + height: 20, + width: 20, + child: CircularProgressIndicator( + color: Colors.white, + strokeWidth: 2, + ), + ) + : MyText.labelLarge( + 'Send Reset Link', + fontWeight: 700, + color: Colors.white, + ), ), const SizedBox(height: 24), TextButton(