fix : login api call
This commit is contained in:
@@ -38,6 +38,7 @@ class AuthLogic extends GetxController {
|
||||
Rx<OtpStatus> otpStatus = OtpStatus.init.obs;
|
||||
|
||||
RxInt secondsRemaining = 120.obs;
|
||||
int wsd = 120;
|
||||
Timer? _timer;
|
||||
|
||||
AuthRepositoryImpl authRepository = diAuth.get<AuthRepositoryImpl>();
|
||||
@@ -111,7 +112,7 @@ class AuthLogic extends GetxController {
|
||||
isLoading.value = true;
|
||||
await safeCall<AuthResponseModel?>(
|
||||
call: () => authRepository.login(authRequest: loginRequestModel.toJson()),
|
||||
onSuccess: (result) async{
|
||||
onSuccess: (result) async {
|
||||
await tokenStorageService.saveRefreshToken(result!.refresh!);
|
||||
await tokenStorageService.saveAccessToken(result!.access!);
|
||||
//Get.offAndToNamed(Routes.home);
|
||||
@@ -125,4 +126,9 @@ class AuthLogic extends GetxController {
|
||||
);
|
||||
isLoading.value = false;
|
||||
}
|
||||
|
||||
adder() {
|
||||
tokenStorageService.tsss.value = (wsd++).toString();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ class AuthPage extends GetView<AuthLogic> {
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
recognizer: TapGestureRecognizer()..onTap = () {},
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {},
|
||||
text: 'حریم خصوصی',
|
||||
style: AppFonts.yekan14.copyWith(
|
||||
color: AppColor.blueNormal,
|
||||
@@ -55,22 +56,22 @@ class AuthPage extends GetView<AuthLogic> {
|
||||
children: [
|
||||
TextSpan(
|
||||
recognizer:
|
||||
TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
if (controller.authType.value == AuthType.otp) {
|
||||
controller.authType.value = AuthType.useAndPass;
|
||||
if (controller.otpStatus.value !=
|
||||
OtpStatus.init) {
|
||||
controller.otpStatus.value = OtpStatus.init;
|
||||
}
|
||||
} else {
|
||||
controller.authType.value = AuthType.otp;
|
||||
}
|
||||
},
|
||||
TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
if (controller.authType.value == AuthType.otp) {
|
||||
controller.authType.value = AuthType.useAndPass;
|
||||
if (controller.otpStatus.value !=
|
||||
OtpStatus.init) {
|
||||
controller.otpStatus.value = OtpStatus.init;
|
||||
}
|
||||
} else {
|
||||
controller.authType.value = AuthType.otp;
|
||||
}
|
||||
},
|
||||
text:
|
||||
controller.authType.value == AuthType.otp
|
||||
? 'ورود با رمز ثابت'
|
||||
: 'ورود با رمز یکبار مصرف',
|
||||
controller.authType.value == AuthType.otp
|
||||
? 'ورود با رمز ثابت'
|
||||
: 'ورود با رمز یکبار مصرف',
|
||||
|
||||
style: AppFonts.yekan14.copyWith(
|
||||
color: AppColor.blueNormal,
|
||||
@@ -94,84 +95,88 @@ class AuthPage extends GetView<AuthLogic> {
|
||||
child: Column(
|
||||
children: [
|
||||
ObxValue(
|
||||
(phoneController) => RTextField(
|
||||
label: 'نام کاربری',
|
||||
maxLength: 11,
|
||||
maxLines: 1,
|
||||
controller: phoneController.value,
|
||||
keyboardType: TextInputType.number,
|
||||
initText: phoneController.value.text,
|
||||
onChanged: (value) {
|
||||
phoneController.value.text = value;
|
||||
phoneController.refresh();
|
||||
},
|
||||
prefixIcon: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 6, 8),
|
||||
child: vecWidget(Assets.vecCallSvg),
|
||||
),
|
||||
suffixIcon:
|
||||
phoneController.value.text.trim().isNotEmpty
|
||||
(phoneController) =>
|
||||
RTextField(
|
||||
label: 'نام کاربری',
|
||||
maxLength: 11,
|
||||
maxLines: 1,
|
||||
controller: phoneController.value,
|
||||
keyboardType: TextInputType.number,
|
||||
initText: phoneController.value.text,
|
||||
onChanged: (value) {
|
||||
phoneController.value.text = value;
|
||||
phoneController.refresh();
|
||||
},
|
||||
prefixIcon: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 6, 8),
|
||||
child: vecWidget(Assets.vecCallSvg),
|
||||
),
|
||||
suffixIcon:
|
||||
phoneController.value.text
|
||||
.trim()
|
||||
.isNotEmpty
|
||||
? clearButton(() {
|
||||
phoneController.value.clear();
|
||||
phoneController.refresh();
|
||||
})
|
||||
phoneController.value.clear();
|
||||
phoneController.refresh();
|
||||
})
|
||||
: null,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return '⚠️ شماره موبایل را وارد کنید';
|
||||
}
|
||||
/*else if (value.length < 11) {
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return '⚠️ شماره موبایل را وارد کنید';
|
||||
}
|
||||
/*else if (value.length < 11) {
|
||||
return '⚠️ شماره موبایل باید 11 رقم باشد';
|
||||
}*/
|
||||
return null;
|
||||
},
|
||||
style: AppFonts.yekan13,
|
||||
errorStyle: AppFonts.yekan13.copyWith(
|
||||
color: AppColor.redNormal,
|
||||
),
|
||||
labelStyle: AppFonts.yekan13,
|
||||
boxConstraints: const BoxConstraints(
|
||||
maxHeight: 40,
|
||||
minHeight: 40,
|
||||
maxWidth: 40,
|
||||
minWidth: 40,
|
||||
),
|
||||
),
|
||||
return null;
|
||||
},
|
||||
style: AppFonts.yekan13,
|
||||
errorStyle: AppFonts.yekan13.copyWith(
|
||||
color: AppColor.redNormal,
|
||||
),
|
||||
labelStyle: AppFonts.yekan13,
|
||||
boxConstraints: const BoxConstraints(
|
||||
maxHeight: 40,
|
||||
minHeight: 40,
|
||||
maxWidth: 40,
|
||||
minWidth: 40,
|
||||
),
|
||||
),
|
||||
controller.phoneNumberController,
|
||||
),
|
||||
const SizedBox(height: 26),
|
||||
ObxValue(
|
||||
(passwordController) => RTextField(
|
||||
label: 'رمز عبور',
|
||||
filled: false,
|
||||
controller: passwordController.value,
|
||||
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: vecWidget(Assets.vecKeySvg),
|
||||
),
|
||||
boxConstraints: const BoxConstraints(
|
||||
maxHeight: 34,
|
||||
minHeight: 34,
|
||||
maxWidth: 34,
|
||||
minWidth: 34,
|
||||
),
|
||||
),
|
||||
(passwordController) =>
|
||||
RTextField(
|
||||
label: 'رمز عبور',
|
||||
filled: false,
|
||||
controller: passwordController.value,
|
||||
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: vecWidget(Assets.vecKeySvg),
|
||||
),
|
||||
boxConstraints: const BoxConstraints(
|
||||
maxHeight: 34,
|
||||
minHeight: 34,
|
||||
maxWidth: 34,
|
||||
minWidth: 34,
|
||||
),
|
||||
),
|
||||
controller.passwordController,
|
||||
),
|
||||
SizedBox(height: 26),
|
||||
@@ -188,13 +193,16 @@ class AuthPage extends GetView<AuthLogic> {
|
||||
height: 48,
|
||||
);
|
||||
}, controller.isLoading),
|
||||
FloatingActionButton(onPressed: () {
|
||||
controller.adder();
|
||||
}, child: Icon(Icons.add),)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
Widget sendCodeForm() {
|
||||
return ObxValue((data) {
|
||||
return Form(
|
||||
|
||||
Reference in New Issue
Block a user