diff --git a/packages/chicken/lib/presentation/pages/auth/view.dart b/packages/chicken/lib/presentation/pages/auth/view.dart index 2f2e85c..ef0d429 100644 --- a/packages/chicken/lib/presentation/pages/auth/view.dart +++ b/packages/chicken/lib/presentation/pages/auth/view.dart @@ -198,26 +198,31 @@ class AuthPage extends GetView { SizedBox(height: 26), CaptchaWidget(), - Row( - children: [ - ObxValue((data) { - return Checkbox( - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - visualDensity: VisualDensity(horizontal: -4, vertical: 4), - tristate: true, - value: data.value, - onChanged: (value) { - data.value = value ?? false; - }, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)), - activeColor: AppColor.blueNormal, - ); - }, controller.rememberMe), - Text( - 'مرا به خاطر بسپار', - style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark), - ), - ], + GestureDetector( + onTap: () { + controller.rememberMe.value = !controller.rememberMe.value; + }, + child: Row( + children: [ + ObxValue((data) { + return Checkbox( + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + visualDensity: VisualDensity(horizontal: -4, vertical: 4), + tristate: true, + value: data.value, + onChanged: (value) { + data.value = value ?? false; + }, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)), + activeColor: AppColor.blueNormal, + ); + }, controller.rememberMe), + Text( + 'مرا به خاطر بسپار', + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark), + ), + ], + ), ), Obx(() { diff --git a/packages/inspection/lib/presentation/pages/auth/logic.dart b/packages/inspection/lib/presentation/pages/auth/logic.dart index 3d3bc58..6b1cfc0 100644 --- a/packages/inspection/lib/presentation/pages/auth/logic.dart +++ b/packages/inspection/lib/presentation/pages/auth/logic.dart @@ -22,7 +22,7 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin { late AnimationController _textAnimationController; late Animation textAnimation; RxBool showCard = false.obs; - + RxBool rememberMe = false.obs; Rx> formKeyOtp = GlobalKey().obs; Rx> formKeySentOtp = GlobalKey().obs; Rx usernameController = TextEditingController().obs; @@ -127,6 +127,16 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin { await tokenStorageService.saveModule(_module); await tokenStorageService.saveRefreshToken(result?.refresh ?? ''); await tokenStorageService.saveAccessToken(result?.access ?? ''); + if (rememberMe.value) { + await tokenStorageService.saveUserPass( + UserLocalModel( + username: usernameController.value.text, + password: passwordController.value.text, + module: _module, + ), + ); + } + Get.offAllNamed(InspectionRoutes.init); }, onError: (error, stackTrace) { diff --git a/packages/inspection/lib/presentation/pages/auth/view.dart b/packages/inspection/lib/presentation/pages/auth/view.dart index 6ab8612..0b1afda 100644 --- a/packages/inspection/lib/presentation/pages/auth/view.dart +++ b/packages/inspection/lib/presentation/pages/auth/view.dart @@ -2,6 +2,7 @@ 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 'logic.dart'; class AuthPage extends GetView { @@ -42,10 +43,7 @@ class AuthPage extends GetView { ), Obx(() { - final screenHeight = MediaQuery - .of(context) - .size - .height; + final screenHeight = MediaQuery.of(context).size.height; final targetTop = (screenHeight - 676) / 2; return AnimatedPositioned( @@ -129,13 +127,11 @@ class AuthPage extends GetView { 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) { @@ -157,47 +153,72 @@ class AuthPage extends GetView { ), 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), CaptchaWidget(), - SizedBox(height: 23), + + GestureDetector( + onTap: () { + controller.rememberMe.value = !controller.rememberMe.value; + }, + child: Row( + children: [ + ObxValue((data) { + return Checkbox( + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + visualDensity: VisualDensity(horizontal: -4, vertical: 4), + tristate: true, + value: data.value, + onChanged: (value) { + data.value = value ?? false; + }, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)), + activeColor: AppColor.blueNormal, + ); + }, controller.rememberMe), + Text( + 'مرا به خاطر بسپار', + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark), + ), + ], + ), + ), Obx(() { return RElevated( @@ -206,8 +227,8 @@ class AuthPage extends GetView { onPressed: controller.isDisabled.value ? null : () async { - await controller.submitLoginForm(); - }, + await controller.submitLoginForm(); + }, width: Get.width, height: 48, ); @@ -308,7 +329,7 @@ class AuthPage extends GetView { ); } -/* + /* Widget sendCodeForm() { return ObxValue((data) { return Form(