|
|
|
|
@ -126,7 +126,6 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
GetMobileLoginInfoListModel? loginInfo;
|
|
|
|
|
GetMobileLoginInfoDependentModel? dependentLoginInfo;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> checkFirebaseToken() async {
|
|
|
|
|
try {
|
|
|
|
|
await checkPrefs();
|
|
|
|
|
@ -217,11 +216,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
String devType = Platform.isAndroid ? "android" : "ios";
|
|
|
|
|
|
|
|
|
|
if (ApiConsts.selectedMemberType.isDependent) {
|
|
|
|
|
dependentLoginInfo = await LoginApiClient().getMobileLoginInfoNEWDependent(
|
|
|
|
|
devToken,
|
|
|
|
|
devType,
|
|
|
|
|
memberType: MemberType.dependent.value,
|
|
|
|
|
);
|
|
|
|
|
dependentLoginInfo = await LoginApiClient().getMobileLoginInfoNEWDependent(devToken, devType, memberType: MemberType.dependent.value);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
if (dependentLoginInfo != null) {
|
|
|
|
|
_handleDependentLoginInfo(dependentLoginInfo!);
|
|
|
|
|
@ -229,11 +224,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loginInfo = await LoginApiClient().getMobileLoginInfoNEW(
|
|
|
|
|
devToken,
|
|
|
|
|
devType,
|
|
|
|
|
memberType: ApiConsts.selectedMemberType.value,
|
|
|
|
|
);
|
|
|
|
|
loginInfo = await LoginApiClient().getMobileLoginInfoNEW(devToken, devType, memberType: ApiConsts.selectedMemberType.value);
|
|
|
|
|
if (loginInfo == null) {
|
|
|
|
|
await checkPrefs();
|
|
|
|
|
_autoLogin = false;
|
|
|
|
|
@ -257,9 +248,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
nationalId.text = info.dependentID!;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String? rawDob = (info.birthDate != null && info.birthDate!.isNotEmpty)
|
|
|
|
|
? info.birthDate
|
|
|
|
|
: ((info.dob != null && info.dob!.isNotEmpty) ? info.dob : null);
|
|
|
|
|
String? rawDob = (info.birthDate != null && info.birthDate!.isNotEmpty) ? info.birthDate : ((info.dob != null && info.dob!.isNotEmpty) ? info.dob : null);
|
|
|
|
|
|
|
|
|
|
if (rawDob != null && rawDob.isNotEmpty) {
|
|
|
|
|
DateTime? parsed = _parseBirthDate(rawDob);
|
|
|
|
|
@ -341,7 +330,6 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
dobController.text = DateFormat('yyyy-MM-dd').format(parsed);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> checkPrefs() async {
|
|
|
|
|
@ -434,9 +422,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
Utils.handleException(ex, context, null);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
() => {
|
|
|
|
|
Navigator.pop(context),
|
|
|
|
|
},
|
|
|
|
|
() => {Navigator.pop(context)},
|
|
|
|
|
onResendCode: () {
|
|
|
|
|
performForgotPassword();
|
|
|
|
|
},
|
|
|
|
|
@ -467,13 +453,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildCtaCard({
|
|
|
|
|
required BuildContext context,
|
|
|
|
|
required IconData icon,
|
|
|
|
|
required String title,
|
|
|
|
|
required String subtitle,
|
|
|
|
|
required VoidCallback onTap,
|
|
|
|
|
}) {
|
|
|
|
|
Widget _buildCtaCard({required BuildContext context, required IconData icon, required String title, required String subtitle, required VoidCallback onTap}) {
|
|
|
|
|
bool isRtl = Directionality.of(context) == ui.TextDirection.rtl || AppState().isArabic(context);
|
|
|
|
|
|
|
|
|
|
return InkWell(
|
|
|
|
|
@ -482,51 +462,30 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
child: Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
padding: const EdgeInsets.all(14),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: const Color(0xFFEAF8F4),
|
|
|
|
|
borderRadius: BorderRadius.circular(14),
|
|
|
|
|
border: Border.all(color: const Color(0xFFB8E8DB), width: 1.0),
|
|
|
|
|
),
|
|
|
|
|
decoration: BoxDecoration(color: const Color(0xFFEAF8F4), borderRadius: BorderRadius.circular(14), border: Border.all(color: const Color(0xFFB8E8DB), width: 1.0)),
|
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Container(
|
|
|
|
|
width: 40,
|
|
|
|
|
height: 40,
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
|
),
|
|
|
|
|
decoration: const BoxDecoration(color: Colors.white, shape: BoxShape.circle),
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
child: Icon(
|
|
|
|
|
icon,
|
|
|
|
|
color: const Color(0xFF168A89),
|
|
|
|
|
size: 22,
|
|
|
|
|
),
|
|
|
|
|
child: Icon(icon, color: const Color(0xFF168A89), size: 22),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 12),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
title.toText14(
|
|
|
|
|
isBold: true,
|
|
|
|
|
color: const Color(0xFF1E293B),
|
|
|
|
|
textAlign: isRtl ? TextAlign.right : TextAlign.left,
|
|
|
|
|
),
|
|
|
|
|
title.toText14(isBold: true, color: const Color(0xFF1E293B), textAlign: isRtl ? TextAlign.right : TextAlign.left),
|
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
subtitle.toText12(
|
|
|
|
|
color: const Color(0xFF64748B),
|
|
|
|
|
),
|
|
|
|
|
subtitle.toText12(color: const Color(0xFF64748B)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
Icon(
|
|
|
|
|
isRtl ? Icons.chevron_left_rounded : Icons.chevron_right_rounded,
|
|
|
|
|
color: const Color(0xFF64748B),
|
|
|
|
|
size: 20,
|
|
|
|
|
),
|
|
|
|
|
Icon(isRtl ? Icons.chevron_left_rounded : Icons.chevron_right_rounded, color: const Color(0xFF64748B), size: 20),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -564,16 +523,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
firstDate: firstDate,
|
|
|
|
|
lastDate: lastDate,
|
|
|
|
|
builder: (context, child) {
|
|
|
|
|
return Theme(
|
|
|
|
|
data: Theme.of(context).copyWith(
|
|
|
|
|
colorScheme: const ColorScheme.light(
|
|
|
|
|
primary: MyColors.textMixColor,
|
|
|
|
|
onPrimary: Colors.white,
|
|
|
|
|
onSurface: MyColors.darkTextColor,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: child!,
|
|
|
|
|
);
|
|
|
|
|
return Theme(data: Theme.of(context).copyWith(colorScheme: const ColorScheme.light(primary: MyColors.textMixColor, onPrimary: Colors.white, onSurface: MyColors.darkTextColor)), child: child!);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@ -600,15 +550,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
name = await Utils.getStringFromPrefs("P_DEPENDENT_NAME");
|
|
|
|
|
}
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (_) => MazayaAccessResultScreen(
|
|
|
|
|
isGranted: false,
|
|
|
|
|
dependentName: name,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
Navigator.push(context, MaterialPageRoute(builder: (_) => MazayaAccessResultScreen(isGranted: false, dependentName: name)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void performDependentLogin() async {
|
|
|
|
|
@ -664,10 +606,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String? authToken = (depLoginResponse?.authenticationTokenID != null &&
|
|
|
|
|
depLoginResponse!.authenticationTokenID!.trim().isNotEmpty)
|
|
|
|
|
? depLoginResponse.authenticationTokenID!.trim()
|
|
|
|
|
: null;
|
|
|
|
|
String? authToken = (depLoginResponse?.authenticationTokenID != null && depLoginResponse!.authenticationTokenID!.trim().isNotEmpty) ? depLoginResponse.authenticationTokenID!.trim() : null;
|
|
|
|
|
|
|
|
|
|
String? logInTokenID = depLoginResponse?.logInTokenID;
|
|
|
|
|
String? mobileNumber = depLoginResponse?.getWalaplusDepInfoModel?.pEmpMobileNumber;
|
|
|
|
|
@ -676,13 +615,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
// No need to show OTP screen, direct move to dashboard and use AuthenticationTokenID as TokenID for all other requests
|
|
|
|
|
if (authToken != null && authToken.isNotEmpty) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
_completeDependentLogin(
|
|
|
|
|
depLoginResponse,
|
|
|
|
|
logInTokenID ?? authToken,
|
|
|
|
|
mobileNumber ?? "",
|
|
|
|
|
loginType: 1,
|
|
|
|
|
navigateToDashboard: true,
|
|
|
|
|
);
|
|
|
|
|
_completeDependentLogin(depLoginResponse, logInTokenID ?? authToken, mobileNumber ?? "", loginType: 1, navigateToDashboard: true);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -750,13 +683,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
|
|
|
|
|
_completeDependentLogin(
|
|
|
|
|
checkOtpResponse,
|
|
|
|
|
logInTokenID,
|
|
|
|
|
mobileNumber,
|
|
|
|
|
loginType: 1,
|
|
|
|
|
navigateToDashboard: true,
|
|
|
|
|
);
|
|
|
|
|
_completeDependentLogin(checkOtpResponse, logInTokenID, mobileNumber, loginType: 1, navigateToDashboard: true);
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
if (kDebugMode) print(ex);
|
|
|
|
|
_pinPutController.clear();
|
|
|
|
|
@ -776,12 +703,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
onResendCode: () async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
try {
|
|
|
|
|
await LoginApiClient().mohemmSendOTPDependent(
|
|
|
|
|
nationalId: nationalId.text.trim(),
|
|
|
|
|
mobileNumber: mobileNumber,
|
|
|
|
|
logInTokenID: logInTokenID,
|
|
|
|
|
context: context,
|
|
|
|
|
);
|
|
|
|
|
await LoginApiClient().mohemmSendOTPDependent(nationalId: nationalId.text.trim(), mobileNumber: mobileNumber, logInTokenID: logInTokenID, context: context);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.showToast(LocaleKeys.verificationCodeResent.tr());
|
|
|
|
|
_showDependentOtpDialog(logInTokenID, mobileNumber);
|
|
|
|
|
@ -799,25 +721,20 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _completeDependentLogin(GenericResponseModel? checkOtpResponse, String logInTokenID, String mobileNumber, {int loginType = 1, bool navigateToDashboard = true}) {
|
|
|
|
|
String effectiveToken = (checkOtpResponse?.authenticationTokenID != null && checkOtpResponse!.authenticationTokenID!.trim().isNotEmpty)
|
|
|
|
|
? checkOtpResponse.authenticationTokenID!.trim()
|
|
|
|
|
: ((checkOtpResponse?.tokenID != null && checkOtpResponse!.tokenID!.isNotEmpty)
|
|
|
|
|
? checkOtpResponse.tokenID!
|
|
|
|
|
: ((checkOtpResponse?.logInTokenID != null && checkOtpResponse!.logInTokenID!.isNotEmpty)
|
|
|
|
|
? checkOtpResponse.logInTokenID!
|
|
|
|
|
: logInTokenID));
|
|
|
|
|
String effectiveToken =
|
|
|
|
|
(checkOtpResponse?.authenticationTokenID != null && checkOtpResponse!.authenticationTokenID!.trim().isNotEmpty)
|
|
|
|
|
? checkOtpResponse.authenticationTokenID!.trim()
|
|
|
|
|
: ((checkOtpResponse?.tokenID != null && checkOtpResponse!.tokenID!.isNotEmpty)
|
|
|
|
|
? checkOtpResponse.tokenID!
|
|
|
|
|
: ((checkOtpResponse?.logInTokenID != null && checkOtpResponse!.logInTokenID!.isNotEmpty) ? checkOtpResponse.logInTokenID! : logInTokenID));
|
|
|
|
|
|
|
|
|
|
AppState().postParamsObject?.setTokenID = effectiveToken;
|
|
|
|
|
AppState().setAuthenticationTokenID = effectiveToken;
|
|
|
|
|
AppState().postParamsObject?.setLogInTokenID = (checkOtpResponse?.logInTokenID != null && checkOtpResponse!.logInTokenID!.isNotEmpty)
|
|
|
|
|
? checkOtpResponse.logInTokenID!
|
|
|
|
|
: logInTokenID;
|
|
|
|
|
AppState().postParamsObject?.setLogInTokenID = (checkOtpResponse?.logInTokenID != null && checkOtpResponse!.logInTokenID!.isNotEmpty) ? checkOtpResponse.logInTokenID! : logInTokenID;
|
|
|
|
|
AppState().postParamsObject?.setUserName = nationalId.text.trim();
|
|
|
|
|
AppState().postParamsObject?.setPUserName = nationalId.text.trim();
|
|
|
|
|
|
|
|
|
|
String resolvedMobile = mobileNumber.isNotEmpty
|
|
|
|
|
? mobileNumber
|
|
|
|
|
: (checkOtpResponse?.getWalaplusDepInfoModel?.pEmpMobileNumber ?? "");
|
|
|
|
|
String resolvedMobile = mobileNumber.isNotEmpty ? mobileNumber : (checkOtpResponse?.getWalaplusDepInfoModel?.pEmpMobileNumber ?? "");
|
|
|
|
|
if (resolvedMobile.isNotEmpty) {
|
|
|
|
|
AppState().postParamsObject?.setMobileNumer = resolvedMobile;
|
|
|
|
|
Utils.saveStringFromPrefs("P_DEP_MOBILE_NUMBER", resolvedMobile);
|
|
|
|
|
@ -856,7 +773,6 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
if (isAppOpenBySystem == null) {
|
|
|
|
|
@ -894,12 +810,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
LocaleKeys.english.tr().toText14(color: AppState().isArabic(context) ? null : MyColors.textMixColor).onPress(() {
|
|
|
|
|
context.setLocale(const Locale("en", "US"));
|
|
|
|
|
}),
|
|
|
|
|
Container(
|
|
|
|
|
width: 1,
|
|
|
|
|
color: MyColors.darkWhiteColor,
|
|
|
|
|
height: 16,
|
|
|
|
|
margin: const EdgeInsets.only(left: 10, right: 10),
|
|
|
|
|
),
|
|
|
|
|
Container(width: 1, color: MyColors.darkWhiteColor, height: 16, margin: const EdgeInsets.only(left: 10, right: 10)),
|
|
|
|
|
LocaleKeys.arabic.tr().toText14(color: !AppState().isArabic(context) ? null : MyColors.textMixColor).onPress(() {
|
|
|
|
|
context.setLocale(const Locale("ar", "SA"));
|
|
|
|
|
}),
|
|
|
|
|
@ -913,9 +824,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
return SingleChildScrollView(
|
|
|
|
|
physics: const BouncingScrollPhysics(),
|
|
|
|
|
child: ConstrainedBox(
|
|
|
|
|
constraints: BoxConstraints(
|
|
|
|
|
minHeight: constraints.maxHeight,
|
|
|
|
|
),
|
|
|
|
|
constraints: BoxConstraints(minHeight: constraints.maxHeight),
|
|
|
|
|
child: IntrinsicHeight(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
@ -931,11 +840,9 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
9.height,
|
|
|
|
|
Align(
|
|
|
|
|
alignment: AlignmentDirectional.centerEnd,
|
|
|
|
|
child: LocaleKeys.forgotPassword.tr().toText12(isUnderLine: true, color: MyColors.textMixColor).onPress(
|
|
|
|
|
() {
|
|
|
|
|
performForgotPassword();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
child: LocaleKeys.forgotPassword.tr().toText12(isUnderLine: true, color: MyColors.textMixColor).onPress(() {
|
|
|
|
|
performForgotPassword();
|
|
|
|
|
}),
|
|
|
|
|
),
|
|
|
|
|
20.height,
|
|
|
|
|
_buildDependentCtaCard(context),
|
|
|
|
|
@ -948,21 +855,11 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
child: Stack(
|
|
|
|
|
alignment: AlignmentDirectional.centerEnd,
|
|
|
|
|
children: [
|
|
|
|
|
IgnorePointer(
|
|
|
|
|
child: InputWidget(
|
|
|
|
|
LocaleKeys.dateOfBirth.tr(),
|
|
|
|
|
"YYYY-MM-DD",
|
|
|
|
|
dobController,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
IgnorePointer(child: InputWidget(LocaleKeys.dateOfBirth.tr(), "DD-MM-YYYY", dobController)),
|
|
|
|
|
Positioned.directional(
|
|
|
|
|
textDirection: Directionality.of(context),
|
|
|
|
|
end: 16,
|
|
|
|
|
child: const Icon(
|
|
|
|
|
Icons.calendar_today_outlined,
|
|
|
|
|
size: 20,
|
|
|
|
|
color: MyColors.grey70Color,
|
|
|
|
|
),
|
|
|
|
|
child: const Icon(Icons.calendar_today_outlined, size: 20, color: MyColors.grey70Color),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
@ -977,22 +874,19 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
DefaultButton(
|
|
|
|
|
LocaleKeys.login.tr(),
|
|
|
|
|
() async {
|
|
|
|
|
SystemChannels.textInput.invokeMethod('TextInput.hide');
|
|
|
|
|
if (ApiConsts.ISDependetLogin) {
|
|
|
|
|
performDependentLogin();
|
|
|
|
|
} else {
|
|
|
|
|
performLogin();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
).insideContainer
|
|
|
|
|
DefaultButton(LocaleKeys.login.tr(), () async {
|
|
|
|
|
SystemChannels.textInput.invokeMethod('TextInput.hide');
|
|
|
|
|
if (ApiConsts.ISDependetLogin) {
|
|
|
|
|
performDependentLogin();
|
|
|
|
|
} else {
|
|
|
|
|
performLogin();
|
|
|
|
|
}
|
|
|
|
|
}).insideContainer,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|