feat : remember me for LiveStock module
This commit is contained in:
@@ -22,6 +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;
|
||||||
@@ -127,6 +128,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(LiveStockRoutes.init);
|
Get.offAllNamed(LiveStockRoutes.init);
|
||||||
},
|
},
|
||||||
onError: (error, stackTrace) {
|
onError: (error, stackTrace) {
|
||||||
|
|||||||
@@ -194,7 +194,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