chore : delete auth package because each project has different auth , must be separated auth logic
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_core/data/model/response/captcha/captcha_response_model.dart';
|
||||
import 'package:rasadyar_inspection/data/repositories/auth_repository_imp.dart';
|
||||
|
||||
class CaptchaWidgetLogic extends GetxController with StateMixin<CaptchaResponseModel> {
|
||||
TextEditingController textController = TextEditingController();
|
||||
RxnString captchaKey = RxnString();
|
||||
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
//AuthRepositoryImpl authRepository = .get<AuthRepositoryImpl>();
|
||||
final Random random = Random();
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
getCaptcha();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
textController.clear();
|
||||
textController.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
Future<void> getCaptcha() async {
|
||||
change(null, status: RxStatus.loading());
|
||||
textController.clear();
|
||||
await Future.delayed(Duration(milliseconds: 800));
|
||||
captchaKey.value = (random.nextInt(900000) + 100000).toString();
|
||||
change(value, status: RxStatus.success());
|
||||
}
|
||||
}
|
||||
109
packages/inspection/lib/presentation/widget/captcha/view.dart
Normal file
109
packages/inspection/lib/presentation/widget/captcha/view.dart
Normal file
@@ -0,0 +1,109 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_inspection/presentation/pages/auth/logic.dart';
|
||||
import 'package:rasadyar_inspection/presentation/widget/clear_button.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
class CaptchaWidget extends GetView<CaptchaWidgetLogic> {
|
||||
const CaptchaWidget({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: controller.getCaptcha,
|
||||
child: Container(
|
||||
width: 135,
|
||||
height: 50,
|
||||
clipBehavior: Clip.antiAliasWithSaveLayer,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.whiteNormalHover,
|
||||
border: Border.all(color: Colors.grey.shade300),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: controller.obx(
|
||||
(state) => Center(
|
||||
child: Text(
|
||||
controller.captchaKey.value ?? 'دوباره سعی کنید',
|
||||
style: AppFonts.yekan24Bold,
|
||||
),
|
||||
),
|
||||
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(
|
||||
label: 'کد امنیتی',
|
||||
controller: controller.textController,
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: false, signed: false),
|
||||
maxLines: 1,
|
||||
maxLength: 6,
|
||||
suffixIcon: (controller.textController.text.trim().isNotEmpty ?? false)
|
||||
? clearButton(() => controller.textController.clear())
|
||||
: null,
|
||||
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'کد امنیتی را وارد کنید';
|
||||
} else if (controller.captchaKey.value != null &&
|
||||
controller.captchaKey.value != value) {
|
||||
return 'کد امنیتی اشتباه است';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
onChanged: (pass) {
|
||||
if (pass.length == 6) {
|
||||
if (controller.formKey.currentState?.validate() ?? false) {
|
||||
Get.find<AuthLogic>().isDisabled.value = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
style: AppFonts.yekan13,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _CaptchaLinePainter extends CustomPainter {
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final random = Random();
|
||||
final paint1 = Paint()
|
||||
..color = Colors.deepOrange
|
||||
..strokeWidth = 2;
|
||||
final paint2 = Paint()
|
||||
..color = Colors.blue
|
||||
..strokeWidth = 2;
|
||||
|
||||
// First line: top-left to bottom-right
|
||||
canvas.drawLine(Offset(0, 0), Offset(size.width, size.height), paint1);
|
||||
|
||||
// Second line: bottom-left to top-right
|
||||
canvas.drawLine(Offset(0, size.height), Offset(size.width, 0), paint2);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
Widget clearButton(VoidCallback onTap) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Icon(CupertinoIcons.multiply_circle, size: 20),
|
||||
);
|
||||
}
|
||||
23
packages/inspection/lib/presentation/widget/logo_widget.dart
Normal file
23
packages/inspection/lib/presentation/widget/logo_widget.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class LogoWidget extends StatelessWidget {
|
||||
const LogoWidget({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(),
|
||||
Assets.images.innerSplash.image(
|
||||
width: 150,
|
||||
height: 150,
|
||||
),
|
||||
Text(
|
||||
'سامانه رصدیار',
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.darkGreyNormal),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user