Merge remote-tracking branch 'origin/wala_plus_with_dialog_removal' into wala_plus_with_dialog_removal

wala_plus_with_dialog_removal
FaizHashmi 2 weeks ago
commit b931ed8138

@ -703,7 +703,7 @@
"copyLink": "Copy Link",
"done": "Done",
"linkCopied": "Link copied to clipboard",
"mazayaAccessRevoked": "Mazaya access revoked",
"mazayaAccessRevoked": "Mazaya Access",
"mazayaAccessRevokedDesc": "You are not authorized to access the Mazaya Program.",
"contactYourSponsor": "Contact your sponsor",
"contactYourSponsorDesc": "Ask your sponsor to allow Mazaya access again from Dependent Details. Only the sponsor can restore access.",

@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:io';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:mohem_flutter_app/api/api_client.dart';
@ -114,23 +115,50 @@ class LoginApiClient {
}
Future<GenericResponseModel?> insertMobileLoginInfoNEW(
String email, int sessionId, String employeeName, int loginType, String mobileNumber, String userName, String deviceToken, String deviceType,
String email, int sessionId, String employeeName, int loginType, String mobileNumber, String userName, String? deviceToken, String deviceType,
{int? memberType}) async {
String url = "${ApiConsts.erpRest}Mohemm_InsertMobileLoginInfo";
String devType = deviceType.isNotEmpty ? deviceType : (Platform.isAndroid ? "android" : "ios");
String devToken = (deviceToken != null && deviceToken.isNotEmpty && deviceToken != "null")
? deviceToken
: (AppState().getIsHuawei ? AppState().getHuaweiPushToken : (AppState().getDeviceToken ?? ""));
if (devToken.isEmpty || devToken == "null") {
try {
String savedToken = await Utils.getStringFromPrefs("P_DEP_DEVICE_TOKEN");
if (savedToken.isNotEmpty && savedToken != "null") {
devToken = savedToken;
}
} catch (_) {}
}
if (devToken.isEmpty || devToken == "null") {
try {
if (!AppState().getIsHuawei) {
String? tok = await FirebaseMessaging.instance.getToken();
if (tok != null && tok.isNotEmpty) {
devToken = tok;
AppState().setDeviceToken = tok;
Utils.saveStringFromPrefs("P_DEP_DEVICE_TOKEN", tok);
}
}
} catch (_) {}
}
Map<String, dynamic> postParams = {
"MobileNumber": mobileNumber,
"P_USER_NAME": userName,
"UserName": userName,
"CompanyID": 1, // todo 'sikander' @discuss umer for companyID
"DeviceToken": deviceToken,
"DeviceToken": devToken,
"LoginType": loginType,
"EmployeeName": employeeName,
"P_SESSION_ID": sessionId,
"P_EMAIL_ADDRESS": email,
"MemberType": memberType ?? ApiConsts.selectedMemberType.value,
};
postParams["DeviceToken"] = deviceToken;
postParams["DeviceType"] = deviceType;
postParams["DeviceToken"] = devToken;
postParams["DeviceType"] = devType;
postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) {
GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
@ -159,10 +187,32 @@ class LoginApiClient {
}) async {
String url = "${ApiConsts.erpRest}Mohemm_InsertMobileLoginInfo_Dependent";
String devType = deviceType ?? (Platform.isAndroid ? "android" : "ios");
String devToken = (deviceToken != null && deviceToken.isNotEmpty)
String devToken = (deviceToken != null && deviceToken.isNotEmpty && deviceToken != "null")
? deviceToken
: (AppState().getIsHuawei ? AppState().getHuaweiPushToken : (AppState().getDeviceToken ?? ""));
if (devToken.isEmpty || devToken == "null") {
try {
String savedToken = await Utils.getStringFromPrefs("P_DEP_DEVICE_TOKEN");
if (savedToken.isNotEmpty && savedToken != "null") {
devToken = savedToken;
}
} catch (_) {}
}
if (devToken.isEmpty || devToken == "null") {
try {
if (!AppState().getIsHuawei) {
String? tok = await FirebaseMessaging.instance.getToken();
if (tok != null && tok.isNotEmpty) {
devToken = tok;
AppState().setDeviceToken = tok;
Utils.saveStringFromPrefs("P_DEP_DEVICE_TOKEN", tok);
}
}
} catch (_) {}
}
String effectiveToken = (tokenID != null && tokenID.isNotEmpty)
? tokenID
: (AppState().postParamsObject?.tokenID ?? AppState().authenticationTokenID ?? "");

@ -103,7 +103,17 @@ class _DashboardScreenForDependetState extends State<DashboardScreenForDependet>
}
int sessionId = AppState().postParamsObject?.pSessionId ?? 0;
String email = AppState().postParamsObject?.pEmailAddress ?? "";
String deviceToken = AppState().getIsHuawei ? AppState().getHuaweiPushToken : (AppState().getDeviceToken ?? "");
String deviceToken = AppState().getIsHuawei
? AppState().getHuaweiPushToken
: ((AppState().getDeviceToken != null && AppState().getDeviceToken!.isNotEmpty && AppState().getDeviceToken != "null")
? AppState().getDeviceToken!
: "");
if (deviceToken.isEmpty || deviceToken == "null") {
String savedToken = await Utils.getStringFromPrefs("P_DEP_DEVICE_TOKEN");
if (savedToken.isNotEmpty && savedToken != "null") {
deviceToken = savedToken;
}
}
await LoginApiClient().insertMobileLoginInfoDependent(
loginType: loginType,

@ -404,10 +404,26 @@ class _LoginScreenState extends State<LoginScreen> {
AppState().setMohemmWifiPassword = mohemmWifiPassword;
}
Utils.hideLoading(context);
if (firebaseToken == null || firebaseToken!.isEmpty || firebaseToken == "null") {
if (AppState().getDeviceToken != null && AppState().getDeviceToken!.isNotEmpty && AppState().getDeviceToken != "null") {
firebaseToken = AppState().getDeviceToken;
} else {
String saved = await Utils.getStringFromPrefs("P_DEP_DEVICE_TOKEN");
if (saved.isNotEmpty && saved != "null") {
firebaseToken = saved;
}
}
}
String effectiveTokenArg = (firebaseToken != null && firebaseToken!.isNotEmpty && firebaseToken != "null")
? firebaseToken!
: (AppState().getDeviceToken ?? "");
if (_autoLogin && loginInfo != null) {
if (loginInfo!.deviceToken == null || loginInfo!.deviceToken!.isEmpty || loginInfo!.deviceToken == "null") {
loginInfo!.deviceToken = effectiveTokenArg;
}
Navigator.pushReplacementNamed(context, AppRoutes.verifyLastLogin, arguments: loginInfo);
} else {
Navigator.pushNamed(context, AppRoutes.verifyLogin, arguments: "$firebaseToken");
Navigator.pushNamed(context, AppRoutes.verifyLogin, arguments: effectiveTokenArg);
}
Utils.saveStringFromPrefs(SharedPrefsConsts.password, password.text);
} catch (ex) {
@ -967,7 +983,14 @@ class _LoginScreenState extends State<LoginScreen> {
if (checkOtpResponse?.authenticationTokenID != null && checkOtpResponse!.authenticationTokenID!.trim().isNotEmpty) {
Utils.saveStringFromPrefs("P_DEP_AUTHENTICATION_TOKEN_ID", checkOtpResponse.authenticationTokenID!.trim());
}
Utils.saveStringFromPrefs("P_DEP_DEVICE_TOKEN", AppState().getIsHuawei ? AppState().getHuaweiPushToken : firebaseToken ?? "");
String tokenToSave = AppState().getIsHuawei
? AppState().getHuaweiPushToken
: ((firebaseToken != null && firebaseToken!.isNotEmpty && firebaseToken != "null")
? firebaseToken!
: (AppState().getDeviceToken ?? ""));
if (tokenToSave.isNotEmpty && tokenToSave != "null") {
Utils.saveStringFromPrefs("P_DEP_DEVICE_TOKEN", tokenToSave);
}
Utils.saveStringFromPrefs("P_DEP_LOGIN_TYPE", loginType.toString());
if (navigateToDashboard && ApiConsts.ISDependetLogin) {
@ -975,6 +998,30 @@ class _LoginScreenState extends State<LoginScreen> {
}
}
void _ensureDeviceTokenLoaded() async {
if (firebaseToken == null || firebaseToken!.isEmpty || firebaseToken == "null") {
if (AppState().getDeviceToken != null && AppState().getDeviceToken!.isNotEmpty && AppState().getDeviceToken != "null") {
firebaseToken = AppState().getDeviceToken;
} else {
String saved = await Utils.getStringFromPrefs("P_DEP_DEVICE_TOKEN");
if (saved.isNotEmpty && saved != "null") {
firebaseToken = saved;
AppState().setDeviceToken = saved;
} else if (!AppState().getIsHuawei) {
try {
await Firebase.initializeApp();
String? tok = await FirebaseMessaging.instance.getToken();
if (tok != null && tok.isNotEmpty) {
firebaseToken = tok;
AppState().setDeviceToken = tok;
Utils.saveStringFromPrefs("P_DEP_DEVICE_TOKEN", tok);
}
} catch (_) {}
}
}
}
}
@override
Widget build(BuildContext context) {
if (isAppOpenBySystem == null) {
@ -990,7 +1037,11 @@ class _LoginScreenState extends State<LoginScreen> {
// 13777
// Ab12345cd
}
if (isAppOpenBySystem!) checkFirebaseToken();
if (isAppOpenBySystem!) {
checkFirebaseToken();
} else {
_ensureDeviceTokenLoaded();
}
}
// username.text = "15444";
@ -1011,10 +1062,12 @@ class _LoginScreenState extends State<LoginScreen> {
children: [
LocaleKeys.english.tr().toText14(color: AppState().isArabic(context) ? null : MyColors.textMixColor).onPress(() {
context.setLocale(const Locale("en", "US"));
_ensureDeviceTokenLoaded();
}),
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"));
_ensureDeviceTokenLoaded();
}),
],
),

@ -388,6 +388,11 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
Future<void> performDirectApiCall(String _title, String _icon, int _flag, String value, TextEditingController? _pinPutController, {bool isDirectLogin = false}) async {
try {
GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(true, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().getUserName);
String devToken = AppState().getIsHuawei
? AppState().getHuaweiPushToken
: ((mobileLoginInfoListModel?.deviceToken != null && mobileLoginInfoListModel!.deviceToken!.isNotEmpty && mobileLoginInfoListModel!.deviceToken != "null")
? mobileLoginInfoListModel!.deviceToken!
: (AppState().getDeviceToken ?? ""));
GenericResponseModel? genericResponseModel1 = await LoginApiClient().insertMobileLoginInfoNEW(
AppState().memberLoginList?.pEMAILADDRESS ?? "",
genericResponseModel?.pSESSIONID ?? 0,
@ -395,7 +400,7 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
_flag,
AppState().memberLoginList?.pMOBILENUMBER ?? "",
AppState().getUserName!,
AppState().getIsHuawei ? AppState().getHuaweiPushToken : (mobileLoginInfoListModel?.deviceToken ?? AppState().getDeviceToken ?? ""),
devToken,
Platform.isAndroid ? "android" : "ios",
memberType: MemberType.employee.value,
);

@ -55,7 +55,18 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
@override
Widget build(BuildContext context) {
firebaseToken ??= ModalRoute.of(context)!.settings.arguments as String;
Object? rawArg = ModalRoute.of(context)?.settings.arguments;
if (rawArg != null) {
String argStr = rawArg.toString().trim();
if (argStr.isNotEmpty && argStr != "null") {
firebaseToken ??= argStr;
}
}
if (firebaseToken == null || firebaseToken!.isEmpty || firebaseToken == "null") {
if (AppState().getDeviceToken != null && AppState().getDeviceToken!.isNotEmpty && AppState().getDeviceToken != "null") {
firebaseToken = AppState().getDeviceToken;
}
}
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
@ -642,6 +653,11 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
Utils.showLoading(context);
try {
GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(true, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().getUserName);
String devToken = AppState().getIsHuawei
? AppState().getHuaweiPushToken
: ((firebaseToken != null && firebaseToken!.isNotEmpty && firebaseToken != "null")
? firebaseToken!
: (AppState().getDeviceToken ?? ""));
GenericResponseModel? genericResponseModel1 = await LoginApiClient().insertMobileLoginInfoNEW(
AppState().memberLoginList?.pEMAILADDRESS ?? "",
genericResponseModel?.pSESSIONID ?? 0,
@ -649,7 +665,7 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
_flag,
AppState().memberLoginList?.pMOBILENUMBER ?? "",
AppState().getUserName!,
AppState().getIsHuawei ? AppState().getHuaweiPushToken : firebaseToken!,
devToken,
Platform.isAndroid ? "android" : "ios",
memberType: MemberType.employee.value);
if (genericResponseModel?.errorMessage != null) {

@ -866,21 +866,21 @@ class _AddDependentVerifyScreenState extends State<AddDependentVerifyScreen> {
}
}
// 14. Ticket / Education / Medical Insurance Eligibility
else if (prompt.contains('ticket') || colName.contains('TICKET') ||
prompt.contains('education') || colName.contains('EDU') ||
prompt.contains('insurance') || colName.contains('MED')) {
if (eServices != null && eServices.isNotEmpty) {
for (var opt in eServices) {
String valCol = (opt.vALUECOLUMNNAME ?? '').toLowerCase();
String idCol = (opt.iDCOLUMNNAME ?? '').toUpperCase();
if (idCol == 'Y' || valCol.contains('eligible') || valCol.contains('مؤهل') || valCol.contains('نعم') || valCol.contains('yes')) {
details.sEGMENTVALUEDSP = opt.vALUECOLUMNNAME;
details.vARCHAR2VALUE = opt.iDCOLUMNNAME;
break;
}
}
}
}
// else if (prompt.contains('ticket') || colName.contains('TICKET') ||
// prompt.contains('education') || colName.contains('EDU') ||
// prompt.contains('insurance') || colName.contains('MED')) {
// if (eServices != null && eServices.isNotEmpty) {
// for (var opt in eServices) {
// String valCol = (opt.vALUECOLUMNNAME ?? '').toLowerCase();
// String idCol = (opt.iDCOLUMNNAME ?? '').toUpperCase();
// if (idCol == '' || valCol.contains('eligible') || valCol.contains('مؤهل') || valCol.contains('نعم') || valCol.contains('yes')) {
// details.sEGMENTVALUEDSP = opt.vALUECOLUMNNAME;
// details.vARCHAR2VALUE = opt.iDCOLUMNNAME;
// break;
// }
// }
//}
// }
// 15. Relationship Start Date
else if (prompt.contains('start') || colName.contains('DATE_START') || colName.contains('START_DATE')) {
String startVal = ymdDob.isNotEmpty ? ymdDob : DateFormat('yyyy-MM-dd').format(DateTime.now());

Loading…
Cancel
Save