6/27/1
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user