From 10a47b08c85e2964f0ae447d4fc08cdbb081f7ac Mon Sep 17 00:00:00 2001 From: AlaaElattar Date: Sun, 5 Jan 2025 17:12:18 +0200 Subject: [PATCH] fix email counter --- .../screens/identity_verification_screen.dart | 102 ++++++++++++------ 1 file changed, 71 insertions(+), 31 deletions(-) diff --git a/app/lib/screens/identity_verification_screen.dart b/app/lib/screens/identity_verification_screen.dart index 7c5054a95..3acd24a7c 100644 --- a/app/lib/screens/identity_verification_screen.dart +++ b/app/lib/screens/identity_verification_screen.dart @@ -988,6 +988,37 @@ class _IdentityVerificationScreenState ) ], ), + if (step == 1) + ValueListenableBuilder( + valueListenable: countdownNotifier, + builder: + (context, countdownValue, child) { + if (countdownValue > 0) { + return Row( + children: [ + Expanded( + child: Text( + 'Verification email sent, retry in $countdownValue second${countdownValue == 1 ? '' : 's'}', + overflow: TextOverflow.clip, + style: Theme.of(context) + .textTheme + .bodySmall! + .copyWith( + fontWeight: + FontWeight.bold, + color: + Theme.of(context) + .colorScheme + .warning), + ), + ), + ], + ); + } else { + return Container(); + } + }, + ), step == 2 && Globals().hidePhoneButton.value == true @@ -1019,37 +1050,46 @@ class _IdentityVerificationScreenState ]))), Globals().hidePhoneButton.value == true && step == 2 ? Container() - : Padding( - padding: const EdgeInsets.only(left: 15), - child: ElevatedButton( - onPressed: () async { - switch (step) { - // Verify email - case 1: - { - verifyEmail(); - } - break; - - // Verify phone - case 2: - { - await verifyPhone(); - } - break; - - // Verify identity - case 3: - { - await verifyIdentityProcess(); - } - break; - default: - {} - break; - } - }, - child: const Text('Verify'))), + : ValueListenableBuilder( + valueListenable: countdownNotifier, + builder: (context, countdownValue, child) { + return Padding( + padding: const EdgeInsets.only(left: 12), + child: ElevatedButton( + onPressed: countdownValue > 0 + ? null + : () async { + switch (step) { + // Verify email + case 1: + { + startOrResumeEmailCountdown( + startNew: true); + verifyEmail(); + } + break; + + // Verify phone + case 2: + { + await verifyPhone(); + } + break; + + // Verify identity + case 3: + { + await verifyIdentityProcess(); + } + break; + default: + {} + break; + } + }, + child: const Text('Verify')), + ); + }) ], ), ))