Merge branch 'development_mirza' into 'master'

Login with face and finger fixed

See merge request mirza.shafique/mohem_flutter_app!83
faiz_marathon_signalR_critical
Sikander Saleem 2 years ago
commit e090b9be0b

@ -11,6 +11,7 @@
"lastLoginDetails": "تفاصيل تسجيل الدخول الأخير:", "lastLoginDetails": "تفاصيل تسجيل الدخول الأخير:",
"verificationType": "نوع التحقق:", "verificationType": "نوع التحقق:",
"pleaseVerify": "ارجوك تحقق", "pleaseVerify": "ارجوك تحقق",
"pleaseVerifyForBio": "الرجاء التحقق من تسجيل الدخول باستخدام أحد هذه الخيارات",
"verifyThroughFace": "تحقق من خلال الوجه", "verifyThroughFace": "تحقق من خلال الوجه",
"verifyThroughFingerprint": "تحقق من خلال بصمة الإصبع", "verifyThroughFingerprint": "تحقق من خلال بصمة الإصبع",
"verifyThroughSMS": "تحقق من خلال الرسائل القصيرة", "verifyThroughSMS": "تحقق من خلال الرسائل القصيرة",

@ -11,6 +11,7 @@
"lastLoginDetails": "Last Login Details:", "lastLoginDetails": "Last Login Details:",
"verificationType": "Verification Type:", "verificationType": "Verification Type:",
"pleaseVerify": "Please Verify", "pleaseVerify": "Please Verify",
"pleaseVerifyForBio": "Please verify login with one of the following options",
"verifyThroughFace": "Verify Through Face", "verifyThroughFace": "Verify Through Face",
"verifyThroughFingerprint": "Verify Through Fingerprint", "verifyThroughFingerprint": "Verify Through Fingerprint",
"verifyThroughSMS": "Verify Through SMS", "verifyThroughSMS": "Verify Through SMS",

@ -23,7 +23,7 @@ class LoginApiClient {
postParams["DeviceType"] = deviceType; postParams["DeviceType"] = deviceType;
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject((json) {
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
return (responseData.mohemmGetMobileLoginInfoList?.length ?? 0) > 0 ? responseData.mohemmGetMobileLoginInfoList!.first : null; return (responseData.mohemmGetMobileLoginInfoList?.length ?? 0) > 0 ? (responseData.mohemmGetMobileLoginInfoList!.first) : null;
}, url, postParams); }, url, postParams);
} }

@ -87,7 +87,7 @@ class OtpDialog {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
SvgPicture.asset( SvgPicture.asset(
type == 1 ? "assets/images/login/verify_sms.svg" : "assets/images/login/verify_whatsapp.svg", type == 1 ? "assets/images/login/verify_sms.svg" :type==2? "assets/images/login/verify_thumb.svg":type==3? "assets/images/login/verify_face.svg":'assets/images/login/verify_whatsapp.svg',
height: 50, height: 50,
width: 50, width: 50,
), ),

@ -13,6 +13,7 @@ abstract class LocaleKeys {
static const lastLoginDetails = 'lastLoginDetails'; static const lastLoginDetails = 'lastLoginDetails';
static const verificationType = 'verificationType'; static const verificationType = 'verificationType';
static const pleaseVerify = 'pleaseVerify'; static const pleaseVerify = 'pleaseVerify';
static const pleaseVerifyForBio = 'pleaseVerifyForBio';
static const verifyThroughFace = 'verifyThroughFace'; static const verifyThroughFace = 'verifyThroughFace';
static const verifyThroughFingerprint = 'verifyThroughFingerprint'; static const verifyThroughFingerprint = 'verifyThroughFingerprint';
static const verifyThroughSMS = 'verifyThroughSMS'; static const verifyThroughSMS = 'verifyThroughSMS';

@ -22,6 +22,11 @@ import 'package:mohem_flutter_app/models/generic_response_model.dart';
import 'package:mohem_flutter_app/models/get_mobile_login_info_list_model.dart'; import 'package:mohem_flutter_app/models/get_mobile_login_info_list_model.dart';
import 'package:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart';
// WhatsApp 4
// SMS 1
// Face ID 3
// Finger Print 2
class VerifyLastLoginScreen extends StatefulWidget { class VerifyLastLoginScreen extends StatefulWidget {
VerifyLastLoginScreen({Key? key}) : super(key: key); VerifyLastLoginScreen({Key? key}) : super(key: key);
@ -36,6 +41,10 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
List<BiometricType> _availableBioMetricType = []; List<BiometricType> _availableBioMetricType = [];
GetMobileLoginInfoListModel? mobileLoginInfoListModel; GetMobileLoginInfoListModel? mobileLoginInfoListModel;
//For face and finger print verification
int selectedFlag = 0;
bool isNeedVerifyWithFaceIDAndBiometrics = false;
@override @override
void initState() { void initState() {
_getAvailableBiometrics(); _getAvailableBiometrics();
@ -47,6 +56,7 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
mobileLoginInfoListModel ??= ModalRoute.of(context)!.settings.arguments as GetMobileLoginInfoListModel; mobileLoginInfoListModel ??= ModalRoute.of(context)!.settings.arguments as GetMobileLoginInfoListModel;
String empName = AppState().isArabic(context) ? AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEAr! : AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEEn!; String empName = AppState().isArabic(context) ? AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEAr! : AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEEn!;
print("selectedFlag1: " + mobileLoginInfoListModel!.loginType.toString());
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
@ -110,15 +120,16 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
), ),
), ),
LocaleKeys.pleaseVerify.tr().toText16(), LocaleKeys.pleaseVerify.tr().toText16(),
if (isNeedVerifyWithFaceIDAndBiometrics) LocaleKeys.pleaseVerifyForBio.tr().toText12(),
GridView( GridView(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, crossAxisSpacing: 13, mainAxisSpacing: 9), gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, crossAxisSpacing: 13, mainAxisSpacing: 9),
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.only(top: 9), padding: const EdgeInsets.only(top: 9),
shrinkWrap: true, shrinkWrap: true,
children: [ children: [
getButton(3), if (!isNeedVerifyWithFaceIDAndBiometrics) getButton(3),
if (!isNeedVerifyWithFaceIDAndBiometrics) getButton(2),
getButton(4), getButton(4),
getButton(2),
getButton(1), getButton(1),
], ],
) )
@ -164,7 +175,7 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
DefaultButton( DefaultButton(
LocaleKeys.useAnotherAccount.tr(), LocaleKeys.useAnotherAccount.tr(),
() { () {
Navigator.pushNamedAndRemoveUntil(context, AppRoutes.login, (Route<dynamic> route) => false,arguments: false); Navigator.pushNamedAndRemoveUntil(context, AppRoutes.login, (Route<dynamic> route) => false, arguments: false);
}, },
).insideContainer, ).insideContainer,
], ],
@ -221,62 +232,32 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
// isMoreOption = true; // isMoreOption = true;
}); });
} else { } else {
try { if (_flag == 2 || _flag == 3) {
Utils.showLoading(context); bool authenticateWithFaceAndTouchID = await loginWithFaceIDAndBiometrics();
if (_flag == 4 || _flag == 3) { if (!authenticateWithFaceAndTouchID) {
bool authenticateWithFaceAndTouchID = await loginWithFaceIDAndBiometrics(); return;
if (authenticateWithFaceAndTouchID) { } else {
Navigator.pushNamedAndRemoveUntil(context, AppRoutes.dashboard, (Route<dynamic> route) => false); if (mobileLoginInfoListModel!.loginType == 2 || mobileLoginInfoListModel!.loginType == 3) {
return; bool authenticateWithFaceAndTouchID = await loginWithFaceIDAndBiometrics();
if (!authenticateWithFaceAndTouchID) {
return;
} else {
performApiCall(_title, _icon, _flag, isDirectLogin: true);
}
} else { } else {
Utils.hideLoading(context); isNeedVerifyWithFaceIDAndBiometrics = true;
return; selectedFlag = _flag;
setState(() {
return;
});
} }
} }
await LoginApiClient().checkMobileAppVersion(); } else {
await LoginApiClient().memberLogin(AppState().getUserName!, AppState().password!); if (isNeedVerifyWithFaceIDAndBiometrics)
BasicMemberInformationModel? memberInformationModel = await LoginApiClient().mohemmSendActivationCodeByOTPNotificationType( performApiCall(_title, _icon, selectedFlag);
checkBiometricIsAvailable(BiometricType.fingerprint) ? 1 : 0, AppState().memberLoginList?.pMOBILENUMBER, _flag, AppState().getUserName); else
Utils.hideLoading(context); performApiCall(_title, _icon, _flag);
OtpDialog(
context,
_flag,
int.tryParse(AppState().memberLoginList?.pMOBILENUMBER ?? ""),
(value) async {
Utils.showLoading(context);
try {
GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(false, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().getUserName);
GenericResponseModel? genericResponseModel1 = await LoginApiClient().insertMobileLoginInfoNEW(
AppState().memberLoginList?.pEMAILADDRESS ?? "",
genericResponseModel?.pSESSIONID ?? 0,
genericResponseModel?.memberInformationList![0].eMPLOYEENAME ?? "",
_flag,
AppState().memberLoginList?.pMOBILENUMBER ?? "",
AppState().getUserName!,
mobileLoginInfoListModel!.deviceToken!,
Platform.isAndroid ? "android" : "ios");
if (genericResponseModel?.errorMessage != null) {
Utils.showToast(genericResponseModel?.errorMessage ?? "");
// Navigator.pop(context);
}
Utils.hideLoading(context);
Navigator.pop(context);
Navigator.pushNamedAndRemoveUntil(context, AppRoutes.dashboard, (Route<dynamic> route) => false);
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
},
() => {
Navigator.pop(context),
},
).displayDialog(context);
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
} }
// authenticateUser(_flag, isActive: _loginIndex);
} }
}, },
child: Container( child: Container(
@ -305,14 +286,14 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
Widget getButton(int flag) { Widget getButton(int flag) {
switch (flag) { switch (flag) {
case 2:
return _loginOptionButton(LocaleKeys.verifyThroughWhatsapp.tr(), 'assets/images/login/verify_whatsapp.svg', flag, null);
case 1: case 1:
return _loginOptionButton(LocaleKeys.verifyThroughSMS.tr(), 'assets/images/login/verify_sms.svg', flag, null); return _loginOptionButton(LocaleKeys.verifyThroughSMS.tr(), 'assets/images/login/verify_sms.svg', flag, null);
case 4: case 2:
return _loginOptionButton(LocaleKeys.verifyThroughFingerprint.tr(), 'assets/images/login/verify_thumb.svg', flag, BiometricType.fingerprint.index); return _loginOptionButton(LocaleKeys.verifyThroughFingerprint.tr(), 'assets/images/login/verify_thumb.svg', flag, BiometricType.fingerprint.index);
case 3: case 3:
return _loginOptionButton(LocaleKeys.verifyThroughFace.tr(), 'assets/images/login/verify_face.svg', flag, BiometricType.face.index); return _loginOptionButton(LocaleKeys.verifyThroughFace.tr(), 'assets/images/login/verify_face.svg', flag, BiometricType.face.index);
case 4:
return _loginOptionButton(LocaleKeys.verifyThroughWhatsapp.tr(), 'assets/images/login/verify_whatsapp.svg', flag, null);
default: default:
return const SizedBox(); return const SizedBox();
} }
@ -328,6 +309,66 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
} }
return isAvailable; return isAvailable;
} }
Future<void> performApiCall(String _title, String _icon, int _flag, {bool isDirectLogin = false}) async {
try {
if (isDirectLogin)
setState(() {
Utils.showLoading(context);
});
else
Utils.showLoading(context);
await LoginApiClient().checkMobileAppVersion();
await LoginApiClient().memberLogin(AppState().getUserName!, AppState().password!);
if (!isDirectLogin)
BasicMemberInformationModel? memberInformationModel = await LoginApiClient()
.mohemmSendActivationCodeByOTPNotificationType(checkBiometricIsAvailable(BiometricType.fingerprint) ? 1 : 0, AppState().memberLoginList?.pMOBILENUMBER, _flag, AppState().getUserName);
if (isDirectLogin) performDirectApiCall(_title, _icon, _flag, "");
if (!isDirectLogin) Utils.hideLoading(context);
if (!isDirectLogin)
OtpDialog(
context,
_flag,
int.tryParse(AppState().memberLoginList?.pMOBILENUMBER ?? ""),
(value) async {
Utils.showLoading(context);
performDirectApiCall(_title, _icon, _flag, value);
},
() => {
Navigator.pop(context),
},
).displayDialog(context);
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
Future<void> performDirectApiCall(String _title, String _icon, int _flag, String value, {bool isDirectLogin = false}) async {
try {
GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(false, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().getUserName);
GenericResponseModel? genericResponseModel1 = await LoginApiClient().insertMobileLoginInfoNEW(
AppState().memberLoginList?.pEMAILADDRESS ?? "",
genericResponseModel?.pSESSIONID ?? 0,
genericResponseModel?.memberInformationList![0].eMPLOYEENAME ?? "",
_flag,
AppState().memberLoginList?.pMOBILENUMBER ?? "",
AppState().getUserName!,
mobileLoginInfoListModel!.deviceToken!,
Platform.isAndroid ? "android" : "ios");
if (genericResponseModel?.errorMessage != null) {
Utils.showToast(genericResponseModel?.errorMessage ?? "");
// Navigator.pop(context);
}
Utils.hideLoading(context);
Navigator.pop(context);
Navigator.pushNamedAndRemoveUntil(context, AppRoutes.dashboard, (Route<dynamic> route) => false);
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
// //
// formatDate(date) { // formatDate(date) {
// return date; // return date;

@ -13,6 +13,7 @@ import 'package:mohem_flutter_app/classes/consts.dart';
import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/classes/utils.dart';
import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/config/routes.dart';
import 'package:mohem_flutter_app/dialogs/otp_dialog.dart'; import 'package:mohem_flutter_app/dialogs/otp_dialog.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/models/basic_member_information_model.dart'; import 'package:mohem_flutter_app/models/basic_member_information_model.dart';
@ -20,6 +21,11 @@ import 'package:mohem_flutter_app/models/generic_response_model.dart';
import 'package:mohem_flutter_app/models/member_information_list_model.dart'; import 'package:mohem_flutter_app/models/member_information_list_model.dart';
import 'package:mohem_flutter_app/models/privilege_list_model.dart'; import 'package:mohem_flutter_app/models/privilege_list_model.dart';
// WhatsApp 4
// SMS 1
// Face ID 3
// Finger Print 2
class VerifyLoginScreen extends StatefulWidget { class VerifyLoginScreen extends StatefulWidget {
VerifyLoginScreen({Key? key}) : super(key: key); VerifyLoginScreen({Key? key}) : super(key: key);
@ -35,6 +41,10 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
String? firebaseToken; String? firebaseToken;
//For face and finger print verification
int selectedFlag = 0;
bool isNeedVerifyWithFaceIDAndBiometrics = false;
@override @override
void initState() { void initState() {
_getAvailableBiometrics(); _getAvailableBiometrics();
@ -59,15 +69,16 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
physics: const BouncingScrollPhysics(), physics: const BouncingScrollPhysics(),
children: [ children: [
LocaleKeys.pleaseVerify.tr().toText16(), LocaleKeys.pleaseVerify.tr().toText16(),
if (isNeedVerifyWithFaceIDAndBiometrics) LocaleKeys.pleaseVerifyForBio.tr().toText12(),
GridView( GridView(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, crossAxisSpacing: 13, mainAxisSpacing: 9), gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, crossAxisSpacing: 13, mainAxisSpacing: 9),
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.only(top: 9), padding: const EdgeInsets.only(top: 9),
shrinkWrap: true, shrinkWrap: true,
children: [ children: [
getButton(3), if (!isNeedVerifyWithFaceIDAndBiometrics) getButton(3),
if (!isNeedVerifyWithFaceIDAndBiometrics) getButton(2),
getButton(4), getButton(4),
getButton(2),
getButton(1), getButton(1),
], ],
) )
@ -500,6 +511,7 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
// } // }
// //
Future<bool> loginWithFaceIDAndBiometrics() async { Future<bool> loginWithFaceIDAndBiometrics() async {
IOSAuthMessages iosStrings = IOSAuthMessages iosStrings =
const IOSAuthMessages(cancelButton: 'cancel', goToSettingsButton: 'settings', goToSettingsDescription: 'Please set up your Touch ID.', lockOut: 'Please reenable your Touch ID'); const IOSAuthMessages(cancelButton: 'cancel', goToSettingsButton: 'settings', goToSettingsDescription: 'Please set up your Touch ID.', lockOut: 'Please reenable your Touch ID');
@ -525,69 +537,22 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
// isMoreOption = true; // isMoreOption = true;
}); });
} else { } else {
try { if (_flag == 2 || _flag == 3) {
Utils.showLoading(context); bool authenticateWithFaceAndTouchID = await loginWithFaceIDAndBiometrics();
if (_flag == 4 || _flag == 3) { if (!authenticateWithFaceAndTouchID) {
bool authenticateWithFaceAndTouchID = await loginWithFaceIDAndBiometrics(); return;
if (!authenticateWithFaceAndTouchID) { } else {
isNeedVerifyWithFaceIDAndBiometrics = true;
selectedFlag = _flag;
setState(() {
return; return;
} });
} }
await LoginApiClient().checkMobileAppVersion(); } else {
await LoginApiClient().memberLogin(AppState().getUserName!, AppState().password!); if (isNeedVerifyWithFaceIDAndBiometrics)
BasicMemberInformationModel? memberInformationModel = await LoginApiClient().mohemmSendActivationCodeByOTPNotificationType( performApiCall(_title, _icon, selectedFlag);
checkBiometricIsAvailable(BiometricType.fingerprint) ? 1 : 0, AppState().memberLoginList?.pMOBILENUMBER, _flag, AppState().getUserName); else
Utils.hideLoading(context); performApiCall(_title, _icon, _flag);
OtpDialog(
context,
_flag,
int.tryParse(AppState().memberLoginList?.pMOBILENUMBER ?? ""),
(value) async {
Utils.showLoading(context);
try {
GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(true, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().getUserName);
GenericResponseModel? genericResponseModel1 = await LoginApiClient().insertMobileLoginInfoNEW(
AppState().memberLoginList?.pEMAILADDRESS ?? "",
genericResponseModel?.pSESSIONID ?? 0,
genericResponseModel?.memberInformationList![0].eMPLOYEENAME ?? "",
_flag,
AppState().memberLoginList?.pMOBILENUMBER ?? "",
AppState().getUserName!,
firebaseToken!,
Platform.isAndroid ? "android" : "ios");
if (genericResponseModel?.errorMessage != null) {
Utils.showToast(genericResponseModel?.errorMessage ?? "");
} else {
AppState().setPrivilegeListModel = genericResponseModel!.privilegeList ?? [];
AppState().setMemberInformationListModel = genericResponseModel.memberInformationList?.first;
MemberInformationListModel.saveToPrefs(genericResponseModel.memberInformationList ?? []);
genericResponseModel.privilegeList!.forEach((element) {
print(element.serviceName.toString() + " " + element.previlege.toString()); // Check availability
});
PrivilegeListModel.saveToPrefs(genericResponseModel.privilegeList ?? []);
AppState().setMohemmWifiSSID = genericResponseModel.mohemmWifiSSID;
AppState().setMohemmWifiPassword = genericResponseModel.mohemmWifiPassword;
Utils.saveStringFromPrefs(SharedPrefsConsts.username, AppState().getUserName!);
Utils.saveStringFromPrefs(SharedPrefsConsts.password, AppState().password!);
Utils.saveStringFromPrefs(SharedPrefsConsts.mohemmWifiSSID, genericResponseModel.mohemmWifiSSID!);
Utils.saveStringFromPrefs(SharedPrefsConsts.mohemmWifiPassword, genericResponseModel.mohemmWifiPassword!);
}
Utils.hideLoading(context);
Navigator.pop(context);
Navigator.pushNamedAndRemoveUntil(context, AppRoutes.dashboard, (Route<dynamic> route) => false);
} catch (ex) {
print(ex);
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
},
() => {
Navigator.pop(context),
},
).displayDialog(context);
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
} }
} }
}, },
@ -617,14 +582,14 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
Widget getButton(int flag) { Widget getButton(int flag) {
switch (flag) { switch (flag) {
case 2:
return _loginOptionButton(LocaleKeys.verifyThroughWhatsapp.tr(), 'assets/images/login/verify_whatsapp.svg', flag, null);
case 1: case 1:
return _loginOptionButton(LocaleKeys.verifyThroughSMS.tr(), 'assets/images/login/verify_sms.svg', flag, null); return _loginOptionButton(LocaleKeys.verifyThroughSMS.tr(), 'assets/images/login/verify_sms.svg', flag, null);
case 4: case 2:
return _loginOptionButton(LocaleKeys.verifyThroughFingerprint.tr(), 'assets/images/login/verify_thumb.svg', flag, BiometricType.fingerprint.index); return _loginOptionButton(LocaleKeys.verifyThroughFingerprint.tr(), 'assets/images/login/verify_thumb.svg', flag, BiometricType.fingerprint.index);
case 3: case 3:
return _loginOptionButton(LocaleKeys.verifyThroughFace.tr(), 'assets/images/login/verify_face.svg', flag, BiometricType.face.index); return _loginOptionButton(LocaleKeys.verifyThroughFace.tr(), 'assets/images/login/verify_face.svg', flag, BiometricType.face.index);
case 4:
return _loginOptionButton(LocaleKeys.verifyThroughWhatsapp.tr(), 'assets/images/login/verify_whatsapp.svg', flag, null);
default: default:
return const SizedBox(); return const SizedBox();
} }
@ -640,6 +605,67 @@ class _VerifyLoginScreenState extends State<VerifyLoginScreen> {
} }
return isAvailable; return isAvailable;
} }
Future<void> performApiCall(String _title, String _icon, int _flag) async {
try {
Utils.showLoading(context);
await LoginApiClient().checkMobileAppVersion();
await LoginApiClient().memberLogin(AppState().getUserName!, AppState().password!);
BasicMemberInformationModel? memberInformationModel = await LoginApiClient()
.mohemmSendActivationCodeByOTPNotificationType(checkBiometricIsAvailable(BiometricType.fingerprint) ? 1 : 0, AppState().memberLoginList?.pMOBILENUMBER, _flag, AppState().getUserName);
Utils.hideLoading(context);
OtpDialog(
context,
_flag,
int.tryParse(AppState().memberLoginList?.pMOBILENUMBER ?? ""),
(value) async {
Utils.showLoading(context);
try {
GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(true, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().getUserName);
GenericResponseModel? genericResponseModel1 = await LoginApiClient().insertMobileLoginInfoNEW(
AppState().memberLoginList?.pEMAILADDRESS ?? "",
genericResponseModel?.pSESSIONID ?? 0,
genericResponseModel?.memberInformationList![0].eMPLOYEENAME ?? "",
_flag,
AppState().memberLoginList?.pMOBILENUMBER ?? "",
AppState().getUserName!,
firebaseToken!,
Platform.isAndroid ? "android" : "ios");
if (genericResponseModel?.errorMessage != null) {
Utils.showToast(genericResponseModel?.errorMessage ?? "");
} else {
AppState().setPrivilegeListModel = genericResponseModel!.privilegeList ?? [];
AppState().setMemberInformationListModel = genericResponseModel.memberInformationList?.first;
MemberInformationListModel.saveToPrefs(genericResponseModel.memberInformationList ?? []);
genericResponseModel.privilegeList!.forEach((element) {
print(element.serviceName.toString() + " " + element.previlege.toString()); // Check availability
});
PrivilegeListModel.saveToPrefs(genericResponseModel.privilegeList ?? []);
AppState().setMohemmWifiSSID = genericResponseModel.mohemmWifiSSID;
AppState().setMohemmWifiPassword = genericResponseModel.mohemmWifiPassword;
Utils.saveStringFromPrefs(SharedPrefsConsts.username, AppState().getUserName!);
Utils.saveStringFromPrefs(SharedPrefsConsts.password, AppState().password!);
Utils.saveStringFromPrefs(SharedPrefsConsts.mohemmWifiSSID, genericResponseModel.mohemmWifiSSID!);
Utils.saveStringFromPrefs(SharedPrefsConsts.mohemmWifiPassword, genericResponseModel.mohemmWifiPassword!);
}
Utils.hideLoading(context);
Navigator.pop(context);
Navigator.pushNamedAndRemoveUntil(context, AppRoutes.dashboard, (Route<dynamic> route) => false);
} catch (ex) {
print(ex);
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
},
() => {
Navigator.pop(context),
},
).displayDialog(context);
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
// //
// formatDate(date) { // formatDate(date) {
// return date; // return date;

Loading…
Cancel
Save