saved login done.

pull/20/head
Sultan khan 2 months ago
parent 9f0fb27baf
commit 2a081e30b5

@ -726,7 +726,7 @@ const DEACTIVATE_ACCOUNT = 'Services/Patients.svc/REST/PatientAppleActivation_In
class ApiConsts { class ApiConsts {
static const maxSmallScreen = 660; static const maxSmallScreen = 660;
static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.uat; static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.prod;
// static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT // static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT

@ -109,7 +109,7 @@ class AppState {
RegistrationDataModelPayload? _userRegistrationPayload; RegistrationDataModelPayload? _userRegistrationPayload;
RegistrationDataModelPayload get getUserRegistrationPayload => _userRegistrationPayload!; RegistrationDataModelPayload get getUserRegistrationPayload => _userRegistrationPayload ?? RegistrationDataModelPayload();
set setUserRegistrationPayload(RegistrationDataModelPayload value) { set setUserRegistrationPayload(RegistrationDataModelPayload value) {
_userRegistrationPayload = value; _userRegistrationPayload = value;

@ -61,6 +61,7 @@ class RequestUtils {
int? patientId, int? patientId,
required String nationIdText, required String nationIdText,
required String countryCode, required String countryCode,
required int loginType
}) { }) {
bool fileNo = false; bool fileNo = false;
if (nationIdText.isNotEmpty) { if (nationIdText.isNotEmpty) {
@ -71,7 +72,7 @@ class RequestUtils {
request.mobileNo = '0$phoneNumber'; request.mobileNo = '0$phoneNumber';
request.deviceToken = deviceToken; request.deviceToken = deviceToken;
request.projectOutSA = patientOutSA; request.projectOutSA = patientOutSA;
request.loginType = otpTypeEnum.toInt(); request.loginType = loginType;
request.oTPSendType = otpTypeEnum.toInt(); // could map OTPTypeEnum if needed request.oTPSendType = otpTypeEnum.toInt(); // could map OTPTypeEnum if needed
request.zipCode = countryCode; // or countryCode if defined elsewhere request.zipCode = countryCode; // or countryCode if defined elsewhere
request.logInTokenID = loginTokenID ?? ""; request.logInTokenID = loginTokenID ?? "";

@ -180,6 +180,7 @@ class AuthenticationRepoImp implements AuthenticationRepo {
newRequest.projectOutSA = newRequest.zipCode == '966' ? false : true; newRequest.projectOutSA = newRequest.zipCode == '966' ? false : true;
newRequest.isDentalAllowedBackend = false; newRequest.isDentalAllowedBackend = false;
newRequest.forRegisteration = newRequest.isRegister ?? false; newRequest.forRegisteration = newRequest.isRegister ?? false;
newRequest.isRegister = false; newRequest.isRegister = false;
} }
@ -390,8 +391,34 @@ class AuthenticationRepoImp implements AuthenticationRepo {
@override @override
Future<Either<Failure, GenericApiModel>> insertPatientDeviceData({required patientDeviceDataRequest}) { Future<Either<Failure, GenericApiModel>> insertPatientDeviceData({required patientDeviceDataRequest}) {
// TODO: implement insertPatientDeviceData try {
GenericApiModel<dynamic>? apiResponse;
throw UnimplementedError(); Failure? failure;
return apiClient.post(
ApiConsts.insertPatientMobileData,
body: patientDeviceDataRequest,
onFailure: (error, statusCode, {messageStatus, failureType}) {
failure = failureType;
},
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
apiResponse = GenericApiModel<dynamic>(
messageStatus: messageStatus,
statusCode: statusCode,
errorMessage: errorMessage,
data: response,
);
} catch (e) {
failure = DataParsingFailure(e.toString());
}
},
).then((_) {
if (failure != null) return Left(failure!);
if (apiResponse == null) return Left(ServerFailure("Unknown error"));
return Right(apiResponse!);
});
} catch (e) {
return Future.value(Left(UnknownFailure(e.toString())));
}
} }
} }

@ -289,7 +289,7 @@ class AuthenticationViewModel extends ChangeNotifier {
await checkActivationCode( await checkActivationCode(
otpTypeEnum: otpTypeEnum, otpTypeEnum: otpTypeEnum,
onWrongActivationCode: (String? message) {}, onWrongActivationCode: (String? message) {},
activationCode: 0000, activationCode: null, //todo silent login case halded on the repo itself..
); );
} }
} }
@ -360,7 +360,7 @@ class AuthenticationViewModel extends ChangeNotifier {
} }
Future<void> checkActivationCode({ Future<void> checkActivationCode({
required int activationCode, required String? activationCode,
required OTPTypeEnum otpTypeEnum, required OTPTypeEnum otpTypeEnum,
required Function(String? message) onWrongActivationCode, required Function(String? message) onWrongActivationCode,
}) async { }) async {
@ -373,9 +373,10 @@ class AuthenticationViewModel extends ChangeNotifier {
registeredData: null, registeredData: null,
nationIdText: nationalIdController.text, nationIdText: nationalIdController.text,
countryCode: selectedCountrySignup.countryCode, countryCode: selectedCountrySignup.countryCode,
loginType: loginTypeEnum.toInt
).toJson(); ).toJson();
bool isForRegister = _appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true; bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true);
if (isForRegister) { if (isForRegister) {
if (_appState.getUserRegistrationPayload.patientOutSa == true) request['DOB'] = _appState.getUserRegistrationPayload.dob; if (_appState.getUserRegistrationPayload.patientOutSa == true) request['DOB'] = _appState.getUserRegistrationPayload.dob;
request['HealthId'] = _appState.getUserRegistrationPayload.healthId; request['HealthId'] = _appState.getUserRegistrationPayload.healthId;
@ -396,7 +397,7 @@ class AuthenticationViewModel extends ChangeNotifier {
} else { } else {
final resultEither = await _authenticationRepo.checkActivationCodeRepo( final resultEither = await _authenticationRepo.checkActivationCodeRepo(
newRequest: CheckActivationCodeRegisterReq.fromJson(request), newRequest: CheckActivationCodeRegisterReq.fromJson(request),
activationCode: activationCode.toString(), activationCode: activationCode,
isRegister: false, isRegister: false,
); );
@ -422,6 +423,7 @@ class AuthenticationViewModel extends ChangeNotifier {
_appState.setAppAuthToken = activation.authenticationTokenId; _appState.setAppAuthToken = activation.authenticationTokenId;
final request = RequestUtils.getAuthanticatedCommonRequest().toJson(); final request = RequestUtils.getAuthanticatedCommonRequest().toJson();
bool isUserAgreedBefore = await checkIfUserAgreedBefore(request: request); bool isUserAgreedBefore = await checkIfUserAgreedBefore(request: request);
insertPatientIMEIData(loginTypeEnum.toInt);
clearDefaultInputValues(); clearDefaultInputValues();
if (isUserAgreedBefore) { if (isUserAgreedBefore) {
navigateToHomeScreen(); navigateToHomeScreen();
@ -491,7 +493,7 @@ class AuthenticationViewModel extends ChangeNotifier {
phoneNumber: phoneNumber, phoneNumber: phoneNumber,
checkActivationCode: (int activationCode) async { checkActivationCode: (int activationCode) async {
await checkActivationCode( await checkActivationCode(
activationCode: activationCode, activationCode: activationCode.toString(),
otpTypeEnum: otpTypeEnum, otpTypeEnum: otpTypeEnum,
onWrongActivationCode: (String? value) { onWrongActivationCode: (String? value) {
onWrongActivationCode(message: value); onWrongActivationCode(message: value);
@ -508,12 +510,19 @@ class AuthenticationViewModel extends ChangeNotifier {
} }
loginWithFingerPrintFace() async { loginWithFingerPrintFace() async {
_localAuthService.authenticate().then((value) { _localAuthService.authenticate().then((value) async {
if (value) { if (value) {
// we have to handle this if verification true; // we have to handle this if verification true;
// checkActivationCode(otpTypeEnum: OTPTypeEnum.faceIDFingerprint, activationCode: 0000, onWrongActivationCode: (String? message) {}); if(!_appState.isAuthenticated) {
loginTypeEnum = (_appState.deviceTypeID == 1 ? LoginTypeEnum.face : LoginTypeEnum.fingerprint);
print(loginTypeEnum);
checkActivationCode(otpTypeEnum:OTPTypeEnum.faceIDFingerprint , activationCode: null, onWrongActivationCode: (String? message) {});
insertPatientIMEIData((_appState.deviceTypeID == 1 ? LoginTypeEnum.face.toInt : LoginTypeEnum.fingerprint.toInt));
}else {
// authenticated = true; // authenticated = true;
insertPatientIMEIData( OTPTypeEnum.faceIDFingerprint.toInt()); insertPatientIMEIData((_appState.deviceTypeID == 1 ? LoginTypeEnum.face.toInt : LoginTypeEnum.fingerprint.toInt));
}
notifyListeners(); notifyListeners();
// navigateToHomeScreen(); // navigateToHomeScreen();
} else { } else {
@ -521,7 +530,6 @@ class AuthenticationViewModel extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
}); });
notifyListeners();
} }
checkLastLoginStatus(Function() onSuccess) async { checkLastLoginStatus(Function() onSuccess) async {
@ -696,25 +704,25 @@ class AuthenticationViewModel extends ChangeNotifier {
Future<void> insertPatientIMEIData(int loginType) async{ Future<void> insertPatientIMEIData(int loginType) async{
final resultEither = await _authenticationRepo.insertPatientIMEIData(patientIMEIDataRequest: PatientInsertDeviceImei(imei: _appState.deviceToken, deviceTypeId: _appState.getDeviceTypeID(), patientId: _appState.getAuthenticatedUser()!.patientId!, patientIdentificationNo:_appState.getAuthenticatedUser()!.nationalityId!, firstName: _appState.getAuthenticatedUser()!.firstName!, lastName: _appState.getAuthenticatedUser()!.lastName!, patientTypeId: _appState.getAuthenticatedUser()!.patientType, mobileNo:_appState.getAuthenticatedUser()!.mobileNumber!, logInTypeId: loginType, patientOutSa:_appState.getAuthenticatedUser()!.outSa! ).toJson()); final resultEither = await _authenticationRepo.insertPatientIMEIData(patientIMEIDataRequest: PatientInsertDeviceImei(imei: _appState.deviceToken, deviceTypeId: _appState.getDeviceTypeID(), patientId: _appState.getAuthenticatedUser()!.patientId!, patientIdentificationNo:_appState.getAuthenticatedUser()!.nationalityId!, firstName: _appState.getAuthenticatedUser()!.firstName!, lastName: _appState.getAuthenticatedUser()!.lastName!, patientTypeId: _appState.getAuthenticatedUser()!.patientType, mobileNo:_appState.getAuthenticatedUser()!.mobileNumber!, logInTypeId: loginType, patientOutSa:_appState.getAuthenticatedUser()!.outSa!, outSa: _appState.getAuthenticatedUser()!.outSa == 1 ? true :false, biometricEnabled: loginType == 1 || loginType ==2 ? false :true, firstNameN:_appState.getAuthenticatedUser()!.firstNameN , lastNameN:_appState.getAuthenticatedUser()!.lastNameN ).toJson());
resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async { resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async {
if (apiResponse.messageStatus == 1) { if (apiResponse.messageStatus == 1) {
print("Insert IMEI Success"); log("Insert IMEI Success");
insertPatientDeviceData( loginType); insertPatientDeviceData( loginType);
} else { } else {
print("Insert IMEI Failed"); log("Insert IMEI Failed");
} }
}); });
} }
Future<void> insertPatientDeviceData(int loginType) async{ Future<void> insertPatientDeviceData(int loginType) async{
final resultEither = await _authenticationRepo.insertPatientDeviceData(patientDeviceDataRequest: InsertPatientMobileDeviceInfo(deviceToken: _appState.deviceToken, deviceTypeId: _appState.getDeviceTypeID(), patientId: _appState.getAuthenticatedUser()!.patientId!, patientTypeId: _appState.getAuthenticatedUser()!.patientType, patientOutSa:_appState.getAuthenticatedUser()!.outSa!, loginType: loginType, languageId: _appState.getLanguageID(), latitude: _appState.userLat, longitude:_appState.userLong ).toJson()); final resultEither = await _authenticationRepo.insertPatientDeviceData(patientDeviceDataRequest: InsertPatientMobileDeviceInfo(deviceToken: _appState.deviceToken, deviceTypeId: _appState.getDeviceTypeID(), patientId: _appState.getAuthenticatedUser()!.patientId!, patientTypeId: _appState.getAuthenticatedUser()!.patientType, patientOutSa:_appState.getAuthenticatedUser()!.outSa!, loginType: loginType, languageId: _appState.getLanguageID(), latitude: _appState.userLat, longitude:_appState.userLong, voipToken: "", deviceType: _appState.deviceTypeID, patientMobileNumber:_appState.getAuthenticatedUser()!.mobileNumber, nationalId: _appState.getAuthenticatedUser()!.patientIdentificationNo, gender: _appState.getAuthenticatedUser()!.gender ).toJson());
resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async { resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async {
if (apiResponse.messageStatus == 1) { if (apiResponse.messageStatus == 1) {
print("Insert Device Data Success"); log("Insert Device Data Success");
} else { } else {
print("Insert IMEI Failed"); log("Insert IMEI Failed");
} }
}); });

@ -7,7 +7,6 @@ class PatientInsertDeviceImei {
String? firstName; String? firstName;
String? firstNameN; String? firstNameN;
String? lastNameN; String? lastNameN;
String? lastName;
int? preferredLanguage; int? preferredLanguage;
String? patientIdentificationNo; String? patientIdentificationNo;
bool? outSa; bool? outSa;
@ -28,6 +27,7 @@ class PatientInsertDeviceImei {
int? patientTypeId; int? patientTypeId;
int? patientOutSa; int? patientOutSa;
String? sessionId; String? sessionId;
String? lastName;
PatientInsertDeviceImei({ PatientInsertDeviceImei({
this.setupId, this.setupId,
@ -36,7 +36,6 @@ class PatientInsertDeviceImei {
this.firstName, this.firstName,
this.firstNameN, this.firstNameN,
this.lastNameN, this.lastNameN,
this.lastName,
this.preferredLanguage, this.preferredLanguage,
this.patientIdentificationNo, this.patientIdentificationNo,
this.outSa, this.outSa,
@ -57,6 +56,7 @@ class PatientInsertDeviceImei {
this.patientTypeId, this.patientTypeId,
this.patientOutSa, this.patientOutSa,
this.sessionId, this.sessionId,
this.lastName
}); });
factory PatientInsertDeviceImei.fromRawJson(String str) => PatientInsertDeviceImei.fromJson(json.decode(str)); factory PatientInsertDeviceImei.fromRawJson(String str) => PatientInsertDeviceImei.fromJson(json.decode(str));
@ -70,7 +70,6 @@ class PatientInsertDeviceImei {
firstName: json["FirstName"], firstName: json["FirstName"],
firstNameN: json["FirstNameN"], firstNameN: json["FirstNameN"],
lastNameN: json["LastNameN"], lastNameN: json["LastNameN"],
lastName: json["LastName"],
preferredLanguage: json["PreferredLanguage"], preferredLanguage: json["PreferredLanguage"],
patientIdentificationNo: json["PatientIdentificationNo"], patientIdentificationNo: json["PatientIdentificationNo"],
outSa: json["OutSA"], outSa: json["OutSA"],
@ -91,6 +90,8 @@ class PatientInsertDeviceImei {
patientTypeId: json["PatientTypeID"], patientTypeId: json["PatientTypeID"],
patientOutSa: json["PatientOutSA"], patientOutSa: json["PatientOutSA"],
sessionId: json["SessionID"], sessionId: json["SessionID"],
lastName: json["LastName"],
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
@ -100,7 +101,6 @@ class PatientInsertDeviceImei {
"FirstName": firstName, "FirstName": firstName,
"FirstNameN": firstNameN, "FirstNameN": firstNameN,
"LastNameN": lastNameN, "LastNameN": lastNameN,
"LastName": lastName,
"PreferredLanguage": preferredLanguage, "PreferredLanguage": preferredLanguage,
"PatientIdentificationNo": patientIdentificationNo, "PatientIdentificationNo": patientIdentificationNo,
"OutSA": outSa, "OutSA": outSa,
@ -121,5 +121,6 @@ class PatientInsertDeviceImei {
"PatientTypeID": patientTypeId, "PatientTypeID": patientTypeId,
"PatientOutSA": patientOutSa, "PatientOutSA": patientOutSa,
"SessionID": sessionId, "SessionID": sessionId,
"LastName": lastName,
}; };
} }

@ -19,6 +19,7 @@ class QuickLogin extends StatefulWidget {
} }
class _QuickLogin extends State<QuickLogin> { class _QuickLogin extends State<QuickLogin> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
@ -100,6 +101,9 @@ class _QuickLogin extends State<QuickLogin> {
text:LocaleKeys.enableQuickLogin.tr(), text:LocaleKeys.enableQuickLogin.tr(),
onPressed: () { onPressed: () {
widget.onPressed(); widget.onPressed();
setState(() {
});
}, },
backgroundColor: Color(0xffED1C2B), backgroundColor: Color(0xffED1C2B),
borderColor: Color(0xffED1C2B), borderColor: Color(0xffED1C2B),

@ -34,6 +34,8 @@ class _SavedLogin extends State<SavedLogin> {
void initState() { void initState() {
authVm = context.read<AuthenticationViewModel>(); authVm = context.read<AuthenticationViewModel>();
appState = getIt.get<AppState>(); appState = getIt.get<AppState>();
loginType = LoginTypeExtension.fromValue(appState.getSelectDeviceByImeiRespModelElement!.logInType!)!;
authVm.phoneNumberController.text = appState.getSelectDeviceByImeiRespModelElement!.mobile!.startsWith("0") authVm.phoneNumberController.text = appState.getSelectDeviceByImeiRespModelElement!.mobile!.startsWith("0")
? appState.getSelectDeviceByImeiRespModelElement!.mobile!.replaceFirst("0", "") ? appState.getSelectDeviceByImeiRespModelElement!.mobile!.replaceFirst("0", "")
: appState.getSelectDeviceByImeiRespModelElement!.mobile!; : appState.getSelectDeviceByImeiRespModelElement!.mobile!;
@ -78,7 +80,7 @@ class _SavedLogin extends State<SavedLogin> {
children: [ children: [
// Last login info // Last login info
("${LocaleKeys.lastloginBy.tr()} ${LoginTypeExtension.fromValue(appState.getSelectDeviceByImeiRespModelElement!.logInType ?? 0)!.displayName}") ("${LocaleKeys.lastloginBy.tr()} ${loginType.displayName}")
.toText14(isBold: true, color: AppColors.greyTextColor), .toText14(isBold: true, color: AppColors.greyTextColor),
(appState.getSelectDeviceByImeiRespModelElement!.createdOn != null (appState.getSelectDeviceByImeiRespModelElement!.createdOn != null
? DateUtil.getFormattedDate(DateUtil.convertStringToDate(appState.getSelectDeviceByImeiRespModelElement!.createdOn!), "d MMMM, y 'at' HH:mm") ? DateUtil.getFormattedDate(DateUtil.convertStringToDate(appState.getSelectDeviceByImeiRespModelElement!.createdOn!), "d MMMM, y 'at' HH:mm")
@ -87,7 +89,7 @@ class _SavedLogin extends State<SavedLogin> {
Container( Container(
margin: EdgeInsets.all(16.h), margin: EdgeInsets.all(16.h),
child: Utils.buildSvgWithAssets(icon: getTypeIcons(loginType.toInt), height: 54, width: 54, iconColor: loginType.toInt == 4 ? null : AppColors.primaryRedColor)), child: Utils.buildSvgWithAssets(icon: getTypeIcons(appState.getSelectDeviceByImeiRespModelElement!.logInType!), height: 54, width: 54, iconColor: loginType.toInt == 4 ? null : AppColors.primaryRedColor)),
// Face ID login button // Face ID login button
SizedBox( SizedBox(
height: 45, height: 45,

@ -332,9 +332,14 @@ class _LandingPageState extends State<LandingPage> {
authVM.loginWithFingerPrintFace(); authVM.loginWithFingerPrintFace();
}, },
), ),
height: 400, height:isDone == false ? ResponsiveExtension.screenHeight * 0.5 : ResponsiveExtension.screenHeight * 0.3,
isFullScreen: false, isFullScreen: false,
callBackFunc: (str) {}, callBackFunc: (str) {
isDone = true;
setState(() {
});
},
); );
} }
} }

@ -54,7 +54,7 @@ class ButtonSheetContent extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
// SizedBox( // SizedBox(
// height: 20.h, // height: 20.h,

Loading…
Cancel
Save