feat: Implement loading state in ForgotPasswordScreen during password reset process

This commit is contained in:
Vaibhav Surve 2025-06-10 17:26:35 +05:30
parent 18987aa97a
commit 8c2d258848

View File

@ -24,6 +24,19 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen>
Get.put(ForgotPasswordController()); Get.put(ForgotPasswordController());
bool get _isBetaEnvironment => ApiEndpoints.baseUrl.contains("stage"); bool get _isBetaEnvironment => ApiEndpoints.baseUrl.contains("stage");
bool _isLoading = false;
void _handleForgotPassword() async {
setState(() {
_isLoading = true;
});
await controller.onForgotPassword();
setState(() {
_isLoading = false;
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -96,16 +109,26 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen>
), ),
const SizedBox(height: 40), const SizedBox(height: 40),
MyButton.rounded( MyButton.rounded(
onPressed: controller.onForgotPassword, onPressed:
_isLoading ? null : _handleForgotPassword,
elevation: 2, elevation: 2,
padding: MySpacing.xy(80, 16), padding: MySpacing.xy(80, 16),
borderRadiusAll: 10, borderRadiusAll: 10,
backgroundColor: contentTheme.brandRed, backgroundColor: _isLoading ? Colors.red.withOpacity(0.6) : contentTheme.brandRed,
child: MyText.labelLarge( child: _isLoading
'Send Reset Link', ? const SizedBox(
fontWeight: 700, height: 20,
color: Colors.white, width: 20,
), child: CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2,
),
)
: MyText.labelLarge(
'Send Reset Link',
fontWeight: 700,
color: Colors.white,
),
), ),
const SizedBox(height: 24), const SizedBox(height: 24),
TextButton( TextButton(