This commit is contained in:
Hamza-Ayed
2024-06-27 17:41:40 +03:00
parent ce2dfa2ff4
commit 929ecf39f9
26 changed files with 461 additions and 274 deletions

View File

@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:convert';
import 'dart:math';
@@ -27,10 +28,10 @@ class RegisterController extends GetxController {
TextEditingController siteController = TextEditingController();
TextEditingController verfyCode = TextEditingController();
TextEditingController verifyCode = TextEditingController();
int remainingTime = 300; // 5 minutes in seconds
bool isSent = false;
bool isLoading = false;
Timer? _timer;
String birthDate = 'Birth Date'.tr;
String gender = 'Male'.tr;
@override
@@ -38,6 +39,17 @@ class RegisterController extends GetxController {
super.onInit();
}
void startTimer() {
_timer?.cancel(); // Cancel any existing timer
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
if (remainingTime > 0) {
remainingTime--;
} else {
timer.cancel();
}
});
}
getBirthDate() {
Get.defaultDialog(
title: 'Select Date'.tr,
@@ -84,6 +96,8 @@ class RegisterController extends GetxController {
await smsEgyptController.sendSmsEgypt(
phoneController.text.toString(), randomNumber.toString());
isSent = true;
remainingTime = 300; // Reset to 5 minutes
startTimer();
isLoading = false;
update();
}
@@ -159,4 +173,10 @@ class RegisterController extends GetxController {
}
}
}
@override
void onClose() {
_timer?.cancel();
super.onClose();
}
}