2025-06-03 16:55:49 +03:30
|
|
|
import 'dart:math';
|
|
|
|
|
|
2025-05-17 09:08:46 +03:30
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:rasadyar_auth/data/di/auth_di.dart';
|
|
|
|
|
import 'package:rasadyar_auth/data/models/response/captcha/captcha_response_model.dart';
|
|
|
|
|
import 'package:rasadyar_auth/data/repositories/auth_repository_imp.dart';
|
|
|
|
|
import 'package:rasadyar_core/core.dart';
|
|
|
|
|
|
2025-06-02 09:38:02 +03:30
|
|
|
class CaptchaWidgetLogic extends GetxController with StateMixin<CaptchaResponseModel> {
|
2025-05-17 15:24:06 +03:30
|
|
|
Rx<TextEditingController> textController = TextEditingController().obs;
|
|
|
|
|
RxnString captchaKey = RxnString();
|
2025-05-17 09:08:46 +03:30
|
|
|
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
|
|
|
|
AuthRepositoryImpl authRepository = diAuth.get<AuthRepositoryImpl>();
|
2025-06-03 16:55:49 +03:30
|
|
|
final Random random = Random();
|
2025-05-17 09:08:46 +03:30
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void onInit() {
|
|
|
|
|
super.onInit();
|
|
|
|
|
|
|
|
|
|
getCaptcha();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void onClose() {
|
2025-05-17 15:24:06 +03:30
|
|
|
textController.value.dispose();
|
2025-05-17 09:08:46 +03:30
|
|
|
super.onClose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getCaptcha() async {
|
|
|
|
|
change(null, status: RxStatus.loading());
|
2025-05-17 15:24:06 +03:30
|
|
|
textController.value.clear();
|
2025-06-03 16:55:49 +03:30
|
|
|
await Future.delayed(Duration(milliseconds: 800));
|
2025-06-03 23:57:25 +03:30
|
|
|
captchaKey.value = (random.nextInt(999999)+100000).toString();
|
2025-06-03 16:55:49 +03:30
|
|
|
change(value, status: RxStatus.success());
|
|
|
|
|
|
2025-05-17 09:08:46 +03:30
|
|
|
}
|
|
|
|
|
}
|