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-07-06 20:44:11 +03:30
|
|
|
TextEditingController textController = TextEditingController();
|
2025-05-17 15:24:06 +03:30
|
|
|
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-07-07 08:36:26 +03:30
|
|
|
textController.clear();
|
|
|
|
|
textController.dispose();
|
2025-05-17 09:08:46 +03:30
|
|
|
super.onClose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getCaptcha() async {
|
|
|
|
|
change(null, status: RxStatus.loading());
|
2025-07-07 08:36:26 +03:30
|
|
|
textController.clear();
|
2025-06-03 16:55:49 +03:30
|
|
|
await Future.delayed(Duration(milliseconds: 800));
|
2025-06-29 09:44:19 +03:30
|
|
|
captchaKey.value = (random.nextInt(900000)+100000).toString();
|
2025-06-03 16:55:49 +03:30
|
|
|
change(value, status: RxStatus.success());
|
|
|
|
|
|
2025-05-17 09:08:46 +03:30
|
|
|
}
|
|
|
|
|
}
|