fix : text filed error in auth page

This commit is contained in:
2025-07-06 20:44:11 +03:30
parent d6f7cb4930
commit 1c732efc2f
2 changed files with 28 additions and 29 deletions

View File

@@ -7,7 +7,7 @@ import 'package:rasadyar_auth/data/repositories/auth_repository_imp.dart';
import 'package:rasadyar_core/core.dart'; import 'package:rasadyar_core/core.dart';
class CaptchaWidgetLogic extends GetxController with StateMixin<CaptchaResponseModel> { class CaptchaWidgetLogic extends GetxController with StateMixin<CaptchaResponseModel> {
Rx<TextEditingController> textController = TextEditingController().obs; TextEditingController textController = TextEditingController();
RxnString captchaKey = RxnString(); RxnString captchaKey = RxnString();
GlobalKey<FormState> formKey = GlobalKey<FormState>(); GlobalKey<FormState> formKey = GlobalKey<FormState>();
AuthRepositoryImpl authRepository = diAuth.get<AuthRepositoryImpl>(); AuthRepositoryImpl authRepository = diAuth.get<AuthRepositoryImpl>();
@@ -23,6 +23,7 @@ class CaptchaWidgetLogic extends GetxController with StateMixin<CaptchaResponseM
@override @override
void onClose() { void onClose() {
textController.value.dispose(); textController.value.dispose();
textController.close();
super.onClose(); super.onClose();
} }

View File

@@ -39,7 +39,7 @@ class CaptchaWidget extends GetView<CaptchaWidgetLogic> {
), ),
onLoading: const Center(child: CupertinoActivityIndicator(color: AppColor.blueNormal)), onLoading: const Center(child: CupertinoActivityIndicator(color: AppColor.blueNormal)),
onError: (error) { onError: (error) {
return const Center(child: Text('خطا در بارگذاری کد امنیتی', style: AppFonts.yekan13)); return Center(child: Text('خطا ', style: AppFonts.yekan13.copyWith(color: Colors.red)));
}, },
), ),
), ),
@@ -50,36 +50,34 @@ class CaptchaWidget extends GetView<CaptchaWidgetLogic> {
child: Form( child: Form(
key: controller.formKey, key: controller.formKey,
autovalidateMode: AutovalidateMode.disabled, autovalidateMode: AutovalidateMode.disabled,
child: ObxValue((data) { child: RTextField(
return RTextField( label: 'کد امنیتی',
label: 'کد امنیتی', controller: controller.textController,
controller: data.value, keyboardType: TextInputType.numberWithOptions(decimal: false, signed: false),
keyboardType: TextInputType.numberWithOptions(decimal: false, signed: false), maxLines: 1,
maxLines: 1, maxLength: 6,
maxLength: 6, suffixIcon: (controller.textController.text.trim().isNotEmpty ?? false)
suffixIcon: (data.value.text.trim().isNotEmpty ?? false) ? clearButton(() => controller.textController.clear())
? clearButton(() => controller.textController.value.clear()) : null,
: null,
validator: (value) { validator: (value) {
if (value == null || value.isEmpty) { if (value == null || value.isEmpty) {
return 'کد امنیتی را وارد کنید'; return 'کد امنیتی را وارد کنید';
} else if (controller.captchaKey.value != null && controller.captchaKey.value != value) { } else if (controller.captchaKey.value != null && controller.captchaKey.value != value) {
return 'کد امنیتی اشتباه است'; return 'کد امنیتی اشتباه است';
} }
return null; return null;
}, },
onChanged: (pass) { onChanged: (pass) {
if(pass.length== 6) { if(pass.length== 6) {
if(controller.formKey.currentState?.validate()??false) { if(controller.formKey.currentState?.validate()??false) {
Get.find<AuthLogic>().isDisabled.value = false; Get.find<AuthLogic>().isDisabled.value = false;
}
} }
}, }
style: AppFonts.yekan13, },
); style: AppFonts.yekan13,
}, controller.textController), )
), ),
), ),
], ],