diff --git a/lib/config/shared_pref_kay.dart b/lib/config/shared_pref_kay.dart index 1520207f..376c8dab 100644 --- a/lib/config/shared_pref_kay.dart +++ b/lib/config/shared_pref_kay.dart @@ -12,3 +12,4 @@ final LOGGED_IN_USER = 'loggedUser'; final DASHBOARD_DATA = 'dashboard-data'; final OTP_TYPE = 'otp-type'; final LAST_LOGIN_USER = 'last-login-user'; +final PASSWORD = 'password'; diff --git a/lib/core/model/imei_details.dart b/lib/core/model/imei_details.dart index 614ce67a..eb37e736 100644 --- a/lib/core/model/imei_details.dart +++ b/lib/core/model/imei_details.dart @@ -4,30 +4,30 @@ class GetIMEIDetailsModel { int logInTypeID; bool outSA; String mobile; - Null identificationNo; + dynamic identificationNo; int doctorID; String doctorName; String doctorNameN; int clinicID; String clinicDescription; - Null clinicDescriptionN; + dynamic clinicDescriptionN; int projectID; String projectName; String genderDescription; - Null genderDescriptionN; + dynamic genderDescriptionN; String titleDescription; - Null titleDescriptionN; - Null zipCode; + dynamic titleDescriptionN; + dynamic zipCode; String createdOn; - Null createdBy; + dynamic createdBy; String editedOn; - int editedBy; + dynamic editedBy; bool biometricEnabled; - Null preferredLanguage; + dynamic preferredLanguage; bool isActive; String vidaAuthTokenID; String vidaRefreshTokenID; - + String password; GetIMEIDetailsModel( {this.iD, this.iMEI, @@ -56,7 +56,8 @@ class GetIMEIDetailsModel { this.preferredLanguage, this.isActive, this.vidaAuthTokenID, - this.vidaRefreshTokenID}); + this.vidaRefreshTokenID, + this.password}); GetIMEIDetailsModel.fromJson(Map json) { iD = json['ID']; @@ -87,6 +88,7 @@ class GetIMEIDetailsModel { isActive = json['IsActive']; vidaAuthTokenID = json['VidaAuthTokenID']; vidaRefreshTokenID = json['VidaRefreshTokenID']; + password = json['Password']; } Map toJson() { @@ -119,6 +121,7 @@ class GetIMEIDetailsModel { data['IsActive'] = this.isActive; data['VidaAuthTokenID'] = this.vidaAuthTokenID; data['VidaRefreshTokenID'] = this.vidaRefreshTokenID; + data['Password'] = this.password; return data; } } diff --git a/lib/core/model/insert_imei_model.dart b/lib/core/model/insert_imei_model.dart index 40668dba..25e22b7a 100644 --- a/lib/core/model/insert_imei_model.dart +++ b/lib/core/model/insert_imei_model.dart @@ -1,9 +1,9 @@ class InsertIMEIDetailsModel { String iMEI; int logInTypeID; - Null outSA; - Null mobile; - Null identificationNo; + dynamic outSA; + String mobile; + dynamic identificationNo; int doctorID; String doctorName; String doctorNameN; @@ -31,7 +31,7 @@ class InsertIMEIDetailsModel { int patientOutSA; String vidaAuthTokenID; String vidaRefreshTokenID; - + dynamic password; InsertIMEIDetailsModel( {this.iMEI, this.logInTypeID, @@ -64,13 +64,14 @@ class InsertIMEIDetailsModel { this.isLoginForDoctorApp, this.patientOutSA, this.vidaAuthTokenID, - this.vidaRefreshTokenID}); + this.vidaRefreshTokenID, + this.password}); InsertIMEIDetailsModel.fromJson(Map json) { iMEI = json['IMEI']; logInTypeID = json['LogInTypeID']; outSA = json['OutSA']; - mobile = json['Mobile']; + mobile = json['MobileNo']; identificationNo = json['IdentificationNo']; doctorID = json['DoctorID']; doctorName = json['DoctorName']; @@ -99,6 +100,7 @@ class InsertIMEIDetailsModel { patientOutSA = json['PatientOutSA']; vidaAuthTokenID = json['VidaAuthTokenID']; vidaRefreshTokenID = json['VidaRefreshTokenID']; + password = json['Password']; } Map toJson() { @@ -106,7 +108,7 @@ class InsertIMEIDetailsModel { data['IMEI'] = this.iMEI; data['LogInTypeID'] = this.logInTypeID; data['OutSA'] = this.outSA; - data['Mobile'] = this.mobile; + data['MobileNo'] = this.mobile; data['IdentificationNo'] = this.identificationNo; data['DoctorID'] = this.doctorID; data['DoctorName'] = this.doctorName; @@ -135,6 +137,7 @@ class InsertIMEIDetailsModel { data['PatientOutSA'] = this.patientOutSA; data['VidaAuthTokenID'] = this.vidaAuthTokenID; data['VidaRefreshTokenID'] = this.vidaRefreshTokenID; + data['Password'] = this.password; return data; } } diff --git a/lib/core/service/prescription_service.dart b/lib/core/service/prescription_service.dart index 90b12041..6558ad6e 100644 --- a/lib/core/service/prescription_service.dart +++ b/lib/core/service/prescription_service.dart @@ -7,6 +7,7 @@ import 'package:doctor_app_flutter/core/model/search_drug_request_model.dart'; import 'package:doctor_app_flutter/core/service/base/base_service.dart'; import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/vital_sign/patient-vital-sign-data.dart'; class PrescriptionService extends BaseService { @@ -93,9 +94,24 @@ class PrescriptionService extends BaseService { } Future getDrugToDrug( - VitalSignData vital, List allergy) async { + VitalSignData vital, + List diagnosis, + List allergy, + PatiantInformtion patient, + List prescription) async { + Map request = { + "Prescription": { + "objPatientInfo": {"Gender": patient.gender, "Age": patient.age}, + "objVitalSign": {"Height": vital.heightCm, "Weight": vital.weightKg}, + "objPrescriptionItems": prescription[0].entityList, + "objAllergies": allergy, + "objDiagnosis": diagnosis, + "IsDoctor": "false", + "IsPharmacist": "false" + } + }; + hasError = false; - var request = {}; await baseAppClient.post(DRUG_TO_DRUG, onSuccess: (dynamic response, int statusCode) { drugToDrug = []; @@ -103,6 +119,6 @@ class PrescriptionService extends BaseService { }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: _drugRequestModel.toJson()); + }, body: request); } } diff --git a/lib/core/viewModel/auth_view_model.dart b/lib/core/viewModel/auth_view_model.dart index 960462cd..3a873049 100644 --- a/lib/core/viewModel/auth_view_model.dart +++ b/lib/core/viewModel/auth_view_model.dart @@ -81,11 +81,15 @@ class AuthViewModel extends BaseViewModel { Future insertDeviceImei(request) async { var loggedIn = await sharedPref.getObj(LOGGED_IN_USER); - + var user = await sharedPref.getObj(LAST_LOGIN_USER); + if (user != null) { + user = GetIMEIDetailsModel.fromJson(user); + } request['IMEI'] = DEVICE_TOKEN; request['LogInTypeID'] = await sharedPref.getInt(OTP_TYPE); request['BioMetricEnabled'] = true; - request['MobileNo'] = loggedIn['MobileNumber']; + request['MobileNo'] = + loggedIn != null ? loggedIn['MobileNumber'] : user.mobile; InsertIMEIDetailsModel nRequest = InsertIMEIDetailsModel.fromJson(request); nRequest.genderDescription = request['Gender_Description']; nRequest.genderDescriptionN = request['Gender_DescriptionN']; @@ -93,9 +97,14 @@ class AuthViewModel extends BaseViewModel { nRequest.titleDescription = request['Title_Description']; nRequest.titleDescriptionN = request['Title_DescriptionN']; nRequest.projectID = await sharedPref.getInt(PROJECT_ID); + nRequest.doctorID = loggedIn != null + ? loggedIn['List_MemberInformation'][0]['MemberID'] + : user.doctorID; + nRequest.outSA = loggedIn != null ? loggedIn['PatientOutSA'] : user.outSA; nRequest.vidaAuthTokenID = await sharedPref.getString(VIDA_AUTH_TOKEN_ID); nRequest.vidaRefreshTokenID = await sharedPref.getString(VIDA_REFRESH_TOKEN_ID); + nRequest.password = await sharedPref.getString(PASSWORD); try { var localRes; await baseAppClient.post(INSERT_DEVICE_IMEI, diff --git a/lib/core/viewModel/prescription_view_model.dart b/lib/core/viewModel/prescription_view_model.dart index d7b8f409..3e39a7fa 100644 --- a/lib/core/viewModel/prescription_view_model.dart +++ b/lib/core/viewModel/prescription_view_model.dart @@ -7,6 +7,7 @@ import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; import 'package:doctor_app_flutter/locator.dart'; import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/vital_sign/patient-vital-sign-data.dart'; class PrescriptionViewModel extends BaseViewModel { @@ -72,10 +73,15 @@ class PrescriptionViewModel extends BaseViewModel { } Future getDrugToDrug( - VitalSignData vital, List allergy) async { + VitalSignData vital, + List listOfDiagnosisType, + List allergy, + PatiantInformtion patient, + List prescription) async { hasError = false; setState(ViewState.Busy); - await _prescriptionService.getDrugToDrug(vital, allergy); + await _prescriptionService.getDrugToDrug( + vital, listOfDiagnosisType, allergy, patient, prescription); if (_prescriptionService.hasError) { error = _prescriptionService.error; setState(ViewState.ErrorLocal); diff --git a/lib/models/auth/send_activation_code_model2.dart b/lib/models/auth/send_activation_code_model2.dart index 794887b3..68a90c85 100644 --- a/lib/models/auth/send_activation_code_model2.dart +++ b/lib/models/auth/send_activation_code_model2.dart @@ -11,7 +11,7 @@ class ActivationCodeModel2 { int isMobileFingerPrint; String vidaAuthTokenID; String vidaRefreshTokenID; - + String iMEI; ActivationCodeModel2( {this.oTPSendType, this.mobileNumber, @@ -24,7 +24,8 @@ class ActivationCodeModel2 { this.generalid, this.isMobileFingerPrint, this.vidaAuthTokenID, - this.vidaRefreshTokenID}); + this.vidaRefreshTokenID, + this.iMEI}); ActivationCodeModel2.fromJson(Map json) { oTPSendType = json['OTP_SendType']; @@ -39,6 +40,7 @@ class ActivationCodeModel2 { isMobileFingerPrint = json['IsMobileFingerPrint']; vidaAuthTokenID = json['VidaAuthTokenID']; vidaRefreshTokenID = json['VidaRefreshTokenID']; + iMEI = json['IMEI']; } Map toJson() { @@ -55,6 +57,7 @@ class ActivationCodeModel2 { data['IsMobileFingerPrint'] = this.isMobileFingerPrint; data['VidaAuthTokenID'] = this.vidaAuthTokenID; data['VidaRefreshTokenID'] = this.vidaRefreshTokenID; + data['IMEI'] = this.iMEI; return data; } } diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index 8787eb42..7fd09138 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -70,7 +70,7 @@ class _DashboardScreenState extends State { DEVICE_TOKEN = token; var request = await sharedPref.getObj(DOCTOR_PROFILE); authProvider.insertDeviceImei(request).then((value) { - print(value['ReturnValue']); + print(value); changeIsLoading(false); }); } diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index 8714327d..7d7b45b3 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -3,6 +3,7 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/model/post_prescrition_req_model.dart'; +import 'package:doctor_app_flutter/core/model/Prescription_model.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import 'package:doctor_app_flutter/models/livecare/transfer_to_admin.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; @@ -25,13 +26,13 @@ import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:intl/intl.dart'; -addPrescriptionForm( - context, PrescriptionViewModel model, PatiantInformtion patient) { +addPrescriptionForm(context, PrescriptionViewModel model, + PatiantInformtion patient, prescription) { showModalBottomSheet( isScrollControlled: true, context: context, builder: (BuildContext bc) { - return PrescriptionFormWidget(model, patient); + return PrescriptionFormWidget(model, patient, prescription); }); } @@ -86,7 +87,8 @@ postProcedure( class PrescriptionFormWidget extends StatefulWidget { final PrescriptionViewModel model; PatiantInformtion patient; - PrescriptionFormWidget(this.model, this.patient); + List prescriptionList; + PrescriptionFormWidget(this.model, this.patient, this.prescriptionList); @override _PrescriptionFormWidgetState createState() => _PrescriptionFormWidgetState(); @@ -301,7 +303,7 @@ class _PrescriptionFormWidgetState extends State { ListSelectDialog dialog = ListSelectDialog( list: model.drugsList, - attributeName: 'Description', + attributeName: 'GenericName', attributeValueId: 'ItemId', okText: TranslationBase.of(context) @@ -694,8 +696,8 @@ class _PrescriptionFormWidgetState extends State { .addMedication, onPressed: () { formKey.currentState.save(); - // Navigator.pop(context); - // openDrugToDrug(); + Navigator.pop(context); + openDrugToDrug(); if (strength == null || route == null || frequency == null || @@ -800,9 +802,9 @@ class _PrescriptionFormWidgetState extends State { child: Column( // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - DrugToDrug(widget.patient), + DrugToDrug(widget.patient, widget.prescriptionList), Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 2), + margin: EdgeInsets.all(SizeConfig.widthMultiplier * 3), child: AppButton( title: TranslationBase.of(context).addMedication, onPressed: () { diff --git a/lib/screens/prescription/drugtodrug.dart b/lib/screens/prescription/drugtodrug.dart index 8f51da80..b97dbb2d 100644 --- a/lib/screens/prescription/drugtodrug.dart +++ b/lib/screens/prescription/drugtodrug.dart @@ -1,5 +1,8 @@ import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/model/prescription_model.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/patient-vital-sign-viewmodel.dart'; import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; @@ -16,13 +19,15 @@ import 'package:flutter/material.dart'; class DrugToDrug extends StatefulWidget { final PatiantInformtion patient; - DrugToDrug(this.patient); + final prescription; + DrugToDrug(this.patient, this.prescription); @override _DrugToDrug createState() => _DrugToDrug(); } class _DrugToDrug extends State { int typeID = 1; + bool isLoaded = false; List> expandableList = [ {'name': 'CRITICAL'}, {'name': 'HIGH'}, @@ -30,54 +35,59 @@ class _DrugToDrug extends State { {'name': 'LOW'}, {'name': 'INFO'}, ]; + GeneralGetReqForSOAP generalGetReqForSOAP = GeneralGetReqForSOAP( + patientMRN: 2954208, //widget.patient.patientMRN, + episodeId: 210011002, //widget.patient.episodeNo, + appointmentNo: 2016055308, //widget.patient.appointmentNo, + doctorID: '', + editedBy: ''); + + VitalSignsViewModel model = new VitalSignsViewModel(); + SOAPViewModel model2 = new SOAPViewModel(); @override void initState() { getTypeID(); + getRequestedData(); super.initState(); } @override Widget build(BuildContext context) { - GeneralGetReqForSOAP generalGetReqForSOAP = GeneralGetReqForSOAP( - patientMRN: 2954208, //widget.patient.patientMRN, - episodeId: 210011002, //widget.patient.episodeNo, - appointmentNo: 2016055308, //widget.patient.appointmentNo, - doctorID: '', - editedBy: ''); - - return BaseView( - onModelReady: (model) => model.getPatientVitalSign(widget.patient), - builder: (BuildContext context, model, Widget child) { - return BaseView( - onModelReady: (model2) => - model2.getPatientAllergy(generalGetReqForSOAP), - builder: (BuildContext context, model2, Widget child) { - return BaseView( - onModelReady: (model3) => model3.getDrugToDrug( - model.patientVitalSigns, model2.patientAllergiesList), - builder: (BuildContext context, - PrescriptionViewModel model3, Widget child) => - NetworkBaseView( - baseViewModel: model3, - child: Container( - height: SizeConfig.realScreenHeight * .45, - child: new ListView.builder( - itemCount: expandableList.length, - itemBuilder: (context, i) { - return new ExpansionTile( - title: new Text( - expandableList[i]['name'], - style: new TextStyle( - fontSize: 20.0, - fontWeight: FontWeight.bold, - fontStyle: FontStyle.italic), - ), - children: [Text('Hi')], - ); - })))); - }); - }); + return isLoaded == true + ? BaseView( + onModelReady: (model3) => model3.getDrugToDrug( + model.patientVitalSigns, + model2.listOfDiagnosisType, + model2.patientAllergiesList, + widget.patient, + widget.prescription), + builder: (BuildContext context, PrescriptionViewModel model3, + Widget child) => + NetworkBaseView( + baseViewModel: model3, + child: Container( + height: SizeConfig.realScreenHeight * .4, + child: new ListView.builder( + itemCount: expandableList.length, + itemBuilder: (context, i) { + return new ExpansionTile( + title: new Text( + expandableList[i]['name'], + style: new TextStyle( + fontSize: 20.0, + fontWeight: FontWeight.bold, + fontStyle: FontStyle.italic), + ), + children: [Text('Hi')], + ); + })))) + : Container( + height: SizeConfig.realScreenHeight * .45, + child: Center( + child: CircularProgressIndicator( + valueColor: AlwaysStoppedAnimation(Colors.black), + ))); } getTypeID() async { @@ -86,4 +96,15 @@ class _DrugToDrug extends State { typeID = type; }); } + + getRequestedData() async { + await model.getPatientVitalSign(widget.patient); + await model2.getPatientAllergy(generalGetReqForSOAP); + await model2.getMasterLookup(MasterKeysService.DiagnosisType); + if (model.state == ViewState.Idle && model2.state == ViewState.Idle) { + setState(() { + isLoaded = true; + }); + } + } } diff --git a/lib/screens/prescription/prescription_screen.dart b/lib/screens/prescription/prescription_screen.dart index 45e5173f..2330181b 100644 --- a/lib/screens/prescription/prescription_screen.dart +++ b/lib/screens/prescription/prescription_screen.dart @@ -128,7 +128,10 @@ class _NewPrescriptionScreenState extends State { InkWell( onTap: () { addPrescriptionForm( - context, model, patient); + context, + model, + patient, + model.prescriptionList); //model.postPrescription(); }, child: CircleAvatar( @@ -219,7 +222,10 @@ class _NewPrescriptionScreenState extends State { ), onTap: () { addPrescriptionForm( - context, model, patient); + context, + model, + patient, + model.prescriptionList); //model.postPrescription(); }, ), @@ -500,8 +506,8 @@ class _NewPrescriptionScreenState extends State { children: [ InkWell( onTap: () { - addPrescriptionForm( - context, model, patient); + addPrescriptionForm(context, model, + patient, model.prescriptionList); //model.postPrescription(); }, child: CircleAvatar( diff --git a/lib/widgets/auth/verification_methods.dart b/lib/widgets/auth/verification_methods.dart index caee190d..ff748a95 100644 --- a/lib/widgets/auth/verification_methods.dart +++ b/lib/widgets/auth/verification_methods.dart @@ -63,6 +63,10 @@ class _VerificationMethodsState extends State { bool authenticated; + var fingrePrintBefore; + + var selectedOption; + @override void initState() { super.initState(); @@ -105,7 +109,9 @@ class _VerificationMethodsState extends State { helpers.showErrorToast('Error: ${snapshot.error}'); return Text('Error: ${snapshot.error}'); } else { - return Container( + return SingleChildScrollView( + child: Container( + height: SizeConfig.realScreenHeight, width: SizeConfig.realScreenWidth, child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -155,18 +161,17 @@ class _VerificationMethodsState extends State { TextOverflow.ellipsis, ), subtitle: Text( - // user. != null - // ? formatDate(Helpers - // .convertStringToDate( - // user - // .)) - // : user != - // null - // ? formatDate(Helpers - // .convertStringToDate(user - // .createdOn)) - //: - '--', + user.editedOn != null + ? formatDate(Helpers + .convertStringToDate( + user + .editedOn)) + : user.createdOn != + null + ? formatDate(Helpers + .convertStringToDate(user + .createdOn)) + : '--', overflow: TextOverflow.ellipsis, textAlign: @@ -263,7 +268,7 @@ class _VerificationMethodsState extends State { 3, authProv)), Expanded( child: getButton( - 2, authProv)) + 4, authProv)) ], ) : SizedBox(), @@ -275,7 +280,7 @@ class _VerificationMethodsState extends State { child: getButton(1, authProv)), Expanded( - child: getButton(4, authProv)) + child: getButton(2, authProv)) ], ), ]), @@ -307,7 +312,7 @@ class _VerificationMethodsState extends State { )) ], ), - ); + )); } } }); @@ -342,14 +347,13 @@ class _VerificationMethodsState extends State { authProv .sendActivationCodeForDoctorApp(activationCodeModel) .then((res) { - widget.changeLoadingStata(false); - if (res['MessageStatus'] == 1) { print("VerificationCode : " + res["VerificationCode"]); sharedPref.setString(VIDA_AUTH_TOKEN_ID, res["VidaAuthTokenID"]); sharedPref.setString( VIDA_REFRESH_TOKEN_ID, res["VidaRefreshTokenID"]); sharedPref.setString(LOGIN_TOKEN_ID, res["LogInTokenID"]); + sharedPref.setString(PASSWORD, widget.password); this.startSMSService(oTPSendType, authProv); } else { print(res['ErrorEndUserMessage']); @@ -380,55 +384,50 @@ class _VerificationMethodsState extends State { sendActivationCodeVerificationScreen( oTPSendType, AuthViewModel authProv) async { // TODO : build enum for verfication method - if (oTPSendType == 1 || oTPSendType == 2) { - widget.changeLoadingStata(true); - ActivationCodeModel2 activationCodeModel = ActivationCodeModel2( - facilityId: user.projectID, - memberID: user.doctorID, - zipCode: user.outSA == true ? '971' : '966', - mobileNumber: user.mobile, - oTPSendType: oTPSendType, - isMobileFingerPrint: 1, - vidaAuthTokenID: user.vidaAuthTokenID, - vidaRefreshTokenID: user.vidaRefreshTokenID); + //if (oTPSendType == 1 || oTPSendType == 2) { + widget.changeLoadingStata(true); + ActivationCodeModel2 activationCodeModel = ActivationCodeModel2( + iMEI: user.iMEI, + facilityId: user.projectID, + memberID: user.doctorID, + zipCode: user.outSA == true ? '971' : '966', + mobileNumber: user.mobile, + oTPSendType: oTPSendType, + isMobileFingerPrint: 1, + vidaAuthTokenID: user.vidaAuthTokenID, + vidaRefreshTokenID: user.vidaRefreshTokenID); - try { - authProv - .sendActivationCodeVerificationScreen(activationCodeModel) - .then((res) { - widget.changeLoadingStata(false); - - if (res['MessageStatus'] == 1) { - print("VerificationCode : " + res["VerificationCode"]); - sharedPref.setString(VIDA_AUTH_TOKEN_ID, res["VidaAuthTokenID"]); - sharedPref.setString( - VIDA_REFRESH_TOKEN_ID, res["VidaRefreshTokenID"]); - sharedPref.setString(LOGIN_TOKEN_ID, res["LogInTokenID"]); + try { + authProv + .sendActivationCodeVerificationScreen(activationCodeModel) + .then((res) { + if (res['MessageStatus'] == 1) { + print("VerificationCode : " + res["VerificationCode"]); + sharedPref.setString(VIDA_AUTH_TOKEN_ID, res["VidaAuthTokenID"]); + sharedPref.setString( + VIDA_REFRESH_TOKEN_ID, res["VidaRefreshTokenID"]); + sharedPref.setString(LOGIN_TOKEN_ID, res["LogInTokenID"]); + if (oTPSendType == 1 || oTPSendType == 2) { + widget.changeLoadingStata(false); this.startSMSService(oTPSendType, authProv); } else { - print(res['ErrorEndUserMessage']); - helpers.showErrorToast(res['ErrorEndUserMessage']); + checkActivationCode(authProv); } - }).catchError((err) { - print('$err'); - widget.changeLoadingStata(false); - - helpers.showErrorToast(); - }); - } catch (e) {} - } else { - // TODO route to this page with parameters to inicate we should present 2 option - if (Platform.isAndroid && oTPSendType == 3) { - helpers.showErrorToast('Your device not support this feature'); - } else { - // Navigator.of(context).push(MaterialPageRoute( - // builder: (BuildContext context) => - // VerificationMethodsScreen(password: widget.password,))); + } else { + print(res['ErrorEndUserMessage']); + helpers.showErrorToast(res['ErrorEndUserMessage']); + } + }).catchError((err) { + print('$err'); + widget.changeLoadingStata(false); - // Navigator.of(context).pushNamed(VERIFICATION_METHODS, - // arguments: {'verificationMethod': oTPSendType}); - } - } + helpers.showErrorToast(); + }); + } catch (e) {} + // } + // else { + // checkActivationCode(authProv); + // } } Widget getButton(flag, authProv) { @@ -635,10 +634,10 @@ class _VerificationMethodsState extends State { authenticateUser(type, isActive, authProv) { //GifLoaderDialogUtils.showMyDialog(context); - // if (type == 2 || type == 3) { - // fingrePrintBefore = type; - // } - //this.selectedOption = fingrePrintBefore != null ? fingrePrintBefore : type; + if (type == 3 || type == 4) { + fingrePrintBefore = type; + } + this.selectedOption = fingrePrintBefore != null ? fingrePrintBefore : type; switch (type) { case 1: @@ -657,8 +656,8 @@ class _VerificationMethodsState extends State { default: break; } - // sharedPref.setInt(LAST_LOGIN, - // this.selectedOption); //this.cs.sharedService.setStorage(this.selectedOption, AuthenticationService.LAST_LOGIN); + sharedPref.setInt(OTP_TYPE, selectedOption); + // sharedPref.setInt(LAST_LOGIN), } loginWithSMS(type, isActive, authProv) { @@ -729,11 +728,10 @@ class _VerificationMethodsState extends State { } startSMSService(type, authProv) { - sharedPref.setInt(OTP_TYPE, type); new SMSOTP( context, type, - _loggedUser['MobileNumber'], + _loggedUser != null ? _loggedUser['MobileNumber'] : user.mobile, (value) { showDialog( context: context, @@ -759,10 +757,13 @@ class _VerificationMethodsState extends State { localizedReason: 'Scan your fingerprint to authenticate', useErrorDialogs: true, stickyAuth: true); - if (user.logInTypeID == 1 || user.logInTypeID == 2) { - this.onlySMSBox = true; + if (user != null && (user.logInTypeID == 3 || user.logInTypeID == 4)) { + this.sendActivationCode(type, authProv); + // this.checkActivationCode(authProv); } else { - this.checkActivationCode(authProv); + setState(() { + this.onlySMSBox = true; + }); } // if (authenticated == true) { @@ -779,11 +780,15 @@ class _VerificationMethodsState extends State { checkActivationCode(AuthViewModel authProv, {value}) async { CheckActivationCodeRequestModel checkActivationCodeForDoctorApp = new CheckActivationCodeRequestModel( - zipCode: _loggedUser['ZipCode'], - mobileNumber: _loggedUser['MobileNumber'], - projectID: await sharedPref.getInt(PROJECT_ID), + zipCode: + _loggedUser != null ? _loggedUser['ZipCode'] : user.zipCode, + mobileNumber: + _loggedUser != null ? _loggedUser['MobileNumber'] : user.mobile, + projectID: await sharedPref.getInt(PROJECT_ID) != null + ? await sharedPref.getInt(PROJECT_ID) + : user.projectID, logInTokenID: await sharedPref.getString(LOGIN_TOKEN_ID), - activationCode: value, + activationCode: value ?? '0000', oTPSendType: await sharedPref.getInt(OTP_TYPE), generalid: "Cs2020@2016\$2958");