feat : remember me for inspection module
This commit is contained in:
@@ -198,7 +198,11 @@ class AuthPage extends GetView<AuthLogic> {
|
|||||||
SizedBox(height: 26),
|
SizedBox(height: 26),
|
||||||
CaptchaWidget(),
|
CaptchaWidget(),
|
||||||
|
|
||||||
Row(
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
controller.rememberMe.value = !controller.rememberMe.value;
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
ObxValue((data) {
|
ObxValue((data) {
|
||||||
return Checkbox(
|
return Checkbox(
|
||||||
@@ -219,6 +223,7 @@ class AuthPage extends GetView<AuthLogic> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
Obx(() {
|
Obx(() {
|
||||||
return RElevated(
|
return RElevated(
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin {
|
|||||||
late AnimationController _textAnimationController;
|
late AnimationController _textAnimationController;
|
||||||
late Animation<double> textAnimation;
|
late Animation<double> textAnimation;
|
||||||
RxBool showCard = false.obs;
|
RxBool showCard = false.obs;
|
||||||
|
RxBool rememberMe = false.obs;
|
||||||
Rx<GlobalKey<FormState>> formKeyOtp = GlobalKey<FormState>().obs;
|
Rx<GlobalKey<FormState>> formKeyOtp = GlobalKey<FormState>().obs;
|
||||||
Rx<GlobalKey<FormState>> formKeySentOtp = GlobalKey<FormState>().obs;
|
Rx<GlobalKey<FormState>> formKeySentOtp = GlobalKey<FormState>().obs;
|
||||||
Rx<TextEditingController> usernameController = TextEditingController().obs;
|
Rx<TextEditingController> usernameController = TextEditingController().obs;
|
||||||
@@ -127,6 +127,16 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin {
|
|||||||
await tokenStorageService.saveModule(_module);
|
await tokenStorageService.saveModule(_module);
|
||||||
await tokenStorageService.saveRefreshToken(result?.refresh ?? '');
|
await tokenStorageService.saveRefreshToken(result?.refresh ?? '');
|
||||||
await tokenStorageService.saveAccessToken(result?.access ?? '');
|
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);
|
Get.offAllNamed(InspectionRoutes.init);
|
||||||
},
|
},
|
||||||
onError: (error, stackTrace) {
|
onError: (error, stackTrace) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:flutter/gestures.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:rasadyar_core/core.dart';
|
import 'package:rasadyar_core/core.dart';
|
||||||
import 'package:rasadyar_inspection/presentation/widget/captcha/view.dart';
|
import 'package:rasadyar_inspection/presentation/widget/captcha/view.dart';
|
||||||
|
|
||||||
import 'logic.dart';
|
import 'logic.dart';
|
||||||
|
|
||||||
class AuthPage extends GetView<AuthLogic> {
|
class AuthPage extends GetView<AuthLogic> {
|
||||||
@@ -42,10 +43,7 @@ class AuthPage extends GetView<AuthLogic> {
|
|||||||
),
|
),
|
||||||
|
|
||||||
Obx(() {
|
Obx(() {
|
||||||
final screenHeight = MediaQuery
|
final screenHeight = MediaQuery.of(context).size.height;
|
||||||
.of(context)
|
|
||||||
.size
|
|
||||||
.height;
|
|
||||||
final targetTop = (screenHeight - 676) / 2;
|
final targetTop = (screenHeight - 676) / 2;
|
||||||
|
|
||||||
return AnimatedPositioned(
|
return AnimatedPositioned(
|
||||||
@@ -129,9 +127,7 @@ class AuthPage extends GetView<AuthLogic> {
|
|||||||
padding: const EdgeInsets.fromLTRB(0, 8, 6, 8),
|
padding: const EdgeInsets.fromLTRB(0, 8, 6, 8),
|
||||||
child: Assets.vec.callSvg.svg(width: 12, height: 12),
|
child: Assets.vec.callSvg.svg(width: 12, height: 12),
|
||||||
),
|
),
|
||||||
suffixIcon: controller.usernameController.value.text
|
suffixIcon: controller.usernameController.value.text.trim().isNotEmpty
|
||||||
.trim()
|
|
||||||
.isNotEmpty
|
|
||||||
? clearButton(() {
|
? clearButton(() {
|
||||||
controller.usernameController.value.clear();
|
controller.usernameController.value.clear();
|
||||||
controller.usernameController.refresh();
|
controller.usernameController.refresh();
|
||||||
@@ -157,8 +153,7 @@ class AuthPage extends GetView<AuthLogic> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 26),
|
const SizedBox(height: 26),
|
||||||
ObxValue(
|
ObxValue(
|
||||||
(passwordController) =>
|
(passwordController) => RTextField(
|
||||||
RTextField(
|
|
||||||
label: 'رمز عبور',
|
label: 'رمز عبور',
|
||||||
filled: false,
|
filled: false,
|
||||||
obscure: true,
|
obscure: true,
|
||||||
@@ -197,7 +192,33 @@ class AuthPage extends GetView<AuthLogic> {
|
|||||||
),
|
),
|
||||||
SizedBox(height: 26),
|
SizedBox(height: 26),
|
||||||
CaptchaWidget(),
|
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(() {
|
Obx(() {
|
||||||
return RElevated(
|
return RElevated(
|
||||||
|
|||||||
Reference in New Issue
Block a user