100 lines
3.3 KiB
Dart
100 lines
3.3 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:rasadyar_chicken/features/common/presentation/page/auth/logic.dart';
|
|
import 'package:rasadyar_core/core.dart';
|
|
|
|
import 'logic.dart';
|
|
|
|
class CaptchaWidget extends GetView<CaptchaWidgetLogic> {
|
|
const CaptchaWidget({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
height: 50.h,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
GestureDetector(
|
|
onTap: controller.getCaptcha,
|
|
child: Container(
|
|
width: 135.w,
|
|
height: 50.h,
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: AppColor.whiteNormalHover,
|
|
border: Border.all(color: Colors.grey.shade300),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: controller.obx(
|
|
(state) => Text(
|
|
state ?? '',
|
|
style: AppFonts.yekan20Bold.copyWith(
|
|
color: Colors.black,
|
|
letterSpacing: 2.5,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
onLoading: const Center(
|
|
child: CupertinoActivityIndicator(color: AppColor.blueNormal),
|
|
),
|
|
onError: (error) {
|
|
return Center(
|
|
child: Text(
|
|
'خطا ',
|
|
style: AppFonts.yekan13.copyWith(color: Colors.red),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
|
|
const SizedBox(width: 8),
|
|
Expanded(
|
|
child: Form(
|
|
key: controller.formKey,
|
|
autovalidateMode: AutovalidateMode.disabled,
|
|
child: RTextField(
|
|
height: 50.h,
|
|
isFullHeight: true,
|
|
label: 'کد امنیتی',
|
|
controller: controller.textController,
|
|
focusedBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8),
|
|
borderSide: BorderSide(color: AppColor.textColor, width: 1),
|
|
),
|
|
keyboardType: TextInputType.numberWithOptions(
|
|
decimal: false,
|
|
signed: false,
|
|
),
|
|
filled: false,
|
|
borderColor: Colors.grey.shade300,
|
|
maxLines: 1,
|
|
maxLength: 6,
|
|
suffixIcon: (controller.textController.text.trim().isNotEmpty)
|
|
? clearButton(() => controller.textController.clear())
|
|
: null,
|
|
validator: (value) {
|
|
if (value == null || value.isEmpty) {
|
|
return 'کد امنیتی را وارد کنید';
|
|
}
|
|
return null;
|
|
},
|
|
onChanged: (pass) {
|
|
if (pass.length == 6) {
|
|
if (controller.formKey.currentState?.validate() ?? false) {
|
|
Get.find<AuthLogic>().isDisabled.value = false;
|
|
}
|
|
}
|
|
},
|
|
style: AppFonts.yekan13,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|