feat : remember me for LiveStock module

This commit is contained in:
2025-08-31 11:10:21 +03:30
parent 6a3bce3397
commit e4ceb1c0ac
2 changed files with 38 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ class AuthLogic extends GetxController with GetTickerProviderStateMixin {
late AnimationController _textAnimationController;
late Animation<double> textAnimation;
RxBool showCard = false.obs;
RxBool rememberMe = false.obs;
Rx<GlobalKey<FormState>> formKeyOtp = 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.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(LiveStockRoutes.init);
},
onError: (error, stackTrace) {

View File

@@ -194,7 +194,33 @@ class AuthPage extends GetView<AuthLogic> {
),
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(