feat : new auth in chicken

This commit is contained in:
2025-08-02 15:09:06 +03:30
parent fae6703d8d
commit 8b698a8498
27 changed files with 1115 additions and 109 deletions

View File

@@ -2,9 +2,6 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_inspection/presentation/widget/captcha/view.dart';
import 'package:rasadyar_inspection/presentation/widget/clear_button.dart';
import 'package:rasadyar_inspection/presentation/widget/logo_widget.dart';
import 'logic.dart';
class AuthPage extends GetView<AuthLogic> {
@@ -45,7 +42,10 @@ class AuthPage extends GetView<AuthLogic> {
),
Obx(() {
final screenHeight = MediaQuery.of(context).size.height;
final screenHeight = MediaQuery
.of(context)
.size
.height;
final targetTop = (screenHeight - 676) / 2;
return AnimatedPositioned(
@@ -129,11 +129,13 @@ class AuthPage extends GetView<AuthLogic> {
padding: const EdgeInsets.fromLTRB(0, 8, 6, 8),
child: Assets.vec.callSvg.svg(width: 12, height: 12),
),
suffixIcon: controller.usernameController.value.text.trim().isNotEmpty
suffixIcon: controller.usernameController.value.text
.trim()
.isNotEmpty
? clearButton(() {
controller.usernameController.value.clear();
controller.usernameController.refresh();
})
controller.usernameController.value.clear();
controller.usernameController.refresh();
})
: null,
validator: (value) {
if (value == null || value.isEmpty) {
@@ -155,41 +157,42 @@ class AuthPage extends GetView<AuthLogic> {
),
const SizedBox(height: 26),
ObxValue(
(passwordController) => RTextField(
label: 'رمز عبور',
filled: false,
obscure: true,
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(color: AppColor.textColor, width: 1),
),
controller: passwordController.value,
autofillHints: [AutofillHints.password],
variant: RTextFieldVariant.password,
initText: passwordController.value.text,
onChanged: (value) {
passwordController.refresh();
},
validator: (value) {
if (value == null || value.isEmpty) {
return '⚠️ رمز عبور را وارد کنید';
}
return null;
},
style: AppFonts.yekan13,
errorStyle: AppFonts.yekan13.copyWith(color: AppColor.redNormal),
labelStyle: AppFonts.yekan13,
prefixIcon: Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 8, 8),
child: Assets.vec.keySvg.svg(width: 12, height: 12),
),
boxConstraints: const BoxConstraints(
maxHeight: 34,
minHeight: 34,
maxWidth: 34,
minWidth: 34,
),
),
(passwordController) =>
RTextField(
label: 'رمز عبور',
filled: false,
obscure: true,
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(color: AppColor.textColor, width: 1),
),
controller: passwordController.value,
autofillHints: [AutofillHints.password],
variant: RTextFieldVariant.password,
initText: passwordController.value.text,
onChanged: (value) {
passwordController.refresh();
},
validator: (value) {
if (value == null || value.isEmpty) {
return '⚠️ رمز عبور را وارد کنید';
}
return null;
},
style: AppFonts.yekan13,
errorStyle: AppFonts.yekan13.copyWith(color: AppColor.redNormal),
labelStyle: AppFonts.yekan13,
prefixIcon: Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 8, 8),
child: Assets.vec.keySvg.svg(width: 12, height: 12),
),
boxConstraints: const BoxConstraints(
maxHeight: 34,
minHeight: 34,
maxWidth: 34,
minWidth: 34,
),
),
controller.passwordController,
),
SizedBox(height: 26),
@@ -203,8 +206,8 @@ class AuthPage extends GetView<AuthLogic> {
onPressed: controller.isDisabled.value
? null
: () async {
await controller.submitLoginForm();
},
await controller.submitLoginForm();
},
width: Get.width,
height: 48,
);
@@ -305,7 +308,7 @@ class AuthPage extends GetView<AuthLogic> {
);
}
/*
/*
Widget sendCodeForm() {
return ObxValue((data) {
return Form(

View File

@@ -13,6 +13,15 @@ sealed class InspectionPages {
InspectionPages._();
static final pages = [
GetPage(
name: InspectionRoutes.auth,
page: () => AuthPage(),
binding: BindingsBuilder(() {
Get.lazyPut(() => AuthLogic());
Get.lazyPut(() => CaptchaWidgetLogic());
}),
),
GetPage(
name: InspectionRoutes.init,
page: () => RootPage(),
@@ -64,13 +73,6 @@ sealed class InspectionPages {
page: () => AddMobileInspectorPage(),
binding: BindingsBuilder.put(() => AddMobileInspectorLogic()),
),
GetPage(
name: InspectionRoutes.auth,
page: () => AuthPage(),
binding: BindingsBuilder(() {
Get.lazyPut(() => AuthLogic());
Get.lazyPut(() => CaptchaWidgetLogic());
}),
),
];
}

View File

@@ -5,7 +5,7 @@ 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';
@@ -29,7 +29,8 @@ class CaptchaWidget extends GetView<CaptchaWidgetLogic> {
borderRadius: BorderRadius.circular(8),
),
child: controller.obx(
(state) => Image.memory(base64Decode(state?.captchaImage ?? ''), fit: BoxFit.cover),
(state) =>
Image.memory(base64Decode(state?.captchaImage ?? ''), fit: BoxFit.cover),
onLoading: const Center(
child: CupertinoActivityIndicator(color: AppColor.blueNormal),
),
@@ -57,7 +58,9 @@ class CaptchaWidget extends GetView<CaptchaWidgetLogic> {
keyboardType: TextInputType.numberWithOptions(decimal: false, signed: false),
maxLines: 1,
maxLength: 6,
suffixIcon: (controller.textController.text.trim().isNotEmpty ?? false)
suffixIcon: (controller.textController.text
.trim()
.isNotEmpty ?? false)
? clearButton(() => controller.textController.clear())
: null,
@@ -70,7 +73,10 @@ class CaptchaWidget extends GetView<CaptchaWidgetLogic> {
onChanged: (pass) {
if (pass.length == 6) {
if (controller.formKey.currentState?.validate() ?? false) {
Get.find<AuthLogic>().isDisabled.value = false;
Get
.find<AuthLogic>()
.isDisabled
.value = false;
}
}
},

View File

@@ -1,8 +0,0 @@
import 'package:flutter/cupertino.dart';
Widget clearButton(VoidCallback onTap) {
return GestureDetector(
onTap: onTap,
child: Icon(CupertinoIcons.multiply_circle, size: 20),
);
}

View File

@@ -1,23 +0,0 @@
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: 120.w,
height: 120.h,
),
Text(
'سامانه رصدیار',
style: AppFonts.yekan16.copyWith(color: AppColor.darkGreyNormal),
),
],
);
}
}