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 {
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

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

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

@ -180,6 +180,7 @@ class AuthenticationRepoImp implements AuthenticationRepo {
newRequest.projectOutSA = newRequest.zipCode == '966' ? false : true;
newRequest.isDentalAllowedBackend = false;
newRequest.forRegisteration = newRequest.isRegister ?? false;
newRequest.isRegister = false;
}
@ -390,8 +391,34 @@ class AuthenticationRepoImp implements AuthenticationRepo {
@override
Future<Either<Failure, GenericApiModel>> insertPatientDeviceData({required patientDeviceDataRequest}) {
// TODO: implement insertPatientDeviceData
throw UnimplementedError();
try {
GenericApiModel<dynamic>? apiResponse;
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(
otpTypeEnum: otpTypeEnum,
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({
required int activationCode,
required String? activationCode,
required OTPTypeEnum otpTypeEnum,
required Function(String? message) onWrongActivationCode,
}) async {
@ -373,9 +373,10 @@ class AuthenticationViewModel extends ChangeNotifier {
registeredData: null,
nationIdText: nationalIdController.text,
countryCode: selectedCountrySignup.countryCode,
loginType: loginTypeEnum.toInt
).toJson();
bool isForRegister = _appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true;
bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true);
if (isForRegister) {
if (_appState.getUserRegistrationPayload.patientOutSa == true) request['DOB'] = _appState.getUserRegistrationPayload.dob;
request['HealthId'] = _appState.getUserRegistrationPayload.healthId;
@ -396,7 +397,7 @@ class AuthenticationViewModel extends ChangeNotifier {
} else {
final resultEither = await _authenticationRepo.checkActivationCodeRepo(
newRequest: CheckActivationCodeRegisterReq.fromJson(request),
activationCode: activationCode.toString(),
activationCode: activationCode,
isRegister: false,
);
@ -422,6 +423,7 @@ class AuthenticationViewModel extends ChangeNotifier {
_appState.setAppAuthToken = activation.authenticationTokenId;
final request = RequestUtils.getAuthanticatedCommonRequest().toJson();
bool isUserAgreedBefore = await checkIfUserAgreedBefore(request: request);
insertPatientIMEIData(loginTypeEnum.toInt);
clearDefaultInputValues();
if (isUserAgreedBefore) {
navigateToHomeScreen();
@ -491,7 +493,7 @@ class AuthenticationViewModel extends ChangeNotifier {
phoneNumber: phoneNumber,
checkActivationCode: (int activationCode) async {
await checkActivationCode(
activationCode: activationCode,
activationCode: activationCode.toString(),
otpTypeEnum: otpTypeEnum,
onWrongActivationCode: (String? value) {
onWrongActivationCode(message: value);
@ -508,12 +510,19 @@ class AuthenticationViewModel extends ChangeNotifier {
}
loginWithFingerPrintFace() async {
_localAuthService.authenticate().then((value) {
_localAuthService.authenticate().then((value) async {
if (value) {
// we have to handle this if verification true;
// checkActivationCode(otpTypeEnum: OTPTypeEnum.faceIDFingerprint, activationCode: 0000, onWrongActivationCode: (String? message) {});
// authenticated = true;
insertPatientIMEIData( OTPTypeEnum.faceIDFingerprint.toInt());
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;
insertPatientIMEIData((_appState.deviceTypeID == 1 ? LoginTypeEnum.face.toInt : LoginTypeEnum.fingerprint.toInt));
}
notifyListeners();
// navigateToHomeScreen();
} else {
@ -521,7 +530,6 @@ class AuthenticationViewModel extends ChangeNotifier {
notifyListeners();
}
});
notifyListeners();
}
checkLastLoginStatus(Function() onSuccess) async {
@ -696,25 +704,25 @@ class AuthenticationViewModel extends ChangeNotifier {
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 {
if (apiResponse.messageStatus == 1) {
print("Insert IMEI Success");
log("Insert IMEI Success");
insertPatientDeviceData( loginType);
} else {
print("Insert IMEI Failed");
log("Insert IMEI Failed");
}
});
}
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 {
if (apiResponse.messageStatus == 1) {
print("Insert Device Data Success");
log("Insert Device Data Success");
} else {
print("Insert IMEI Failed");
log("Insert IMEI Failed");
}
});

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

@ -19,6 +19,7 @@ class QuickLogin extends StatefulWidget {
}
class _QuickLogin extends State<QuickLogin> {
@override
Widget build(BuildContext context) {
return Container(
@ -70,7 +71,7 @@ class _QuickLogin extends State<QuickLogin> {
height: 101,
),
const SizedBox(height: 10),
LocaleKeys.enableQuickLogin.tr().toText26(isBold: true),
LocaleKeys.enableQuickLogin.tr().toText26(isBold: true),
// Text(
// ' TranslationBase.of(context).enableQuickLogin',
// style: context.dynamicTextStyle(
@ -100,6 +101,9 @@ class _QuickLogin extends State<QuickLogin> {
text:LocaleKeys.enableQuickLogin.tr(),
onPressed: () {
widget.onPressed();
setState(() {
});
},
backgroundColor: Color(0xffED1C2B),
borderColor: Color(0xffED1C2B),

@ -34,6 +34,8 @@ class _SavedLogin extends State<SavedLogin> {
void initState() {
authVm = context.read<AuthenticationViewModel>();
appState = getIt.get<AppState>();
loginType = LoginTypeExtension.fromValue(appState.getSelectDeviceByImeiRespModelElement!.logInType!)!;
authVm.phoneNumberController.text = appState.getSelectDeviceByImeiRespModelElement!.mobile!.startsWith("0")
? appState.getSelectDeviceByImeiRespModelElement!.mobile!.replaceFirst("0", "")
: appState.getSelectDeviceByImeiRespModelElement!.mobile!;
@ -78,7 +80,7 @@ class _SavedLogin extends State<SavedLogin> {
children: [
// Last login info
("${LocaleKeys.lastloginBy.tr()} ${LoginTypeExtension.fromValue(appState.getSelectDeviceByImeiRespModelElement!.logInType ?? 0)!.displayName}")
("${LocaleKeys.lastloginBy.tr()} ${loginType.displayName}")
.toText14(isBold: true, color: AppColors.greyTextColor),
(appState.getSelectDeviceByImeiRespModelElement!.createdOn != null
? DateUtil.getFormattedDate(DateUtil.convertStringToDate(appState.getSelectDeviceByImeiRespModelElement!.createdOn!), "d MMMM, y 'at' HH:mm")
@ -87,7 +89,7 @@ class _SavedLogin extends State<SavedLogin> {
Container(
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
SizedBox(
height: 45,

@ -326,15 +326,20 @@ class _LandingPageState extends State<LandingPage> {
context,
title: "",
child: QuickLogin(
isDone: isDone,
isDone: isDone,
onPressed: () {
// sharedPref.setBool(HAS_ENABLED_QUICK_LOGIN, true);
authVM.loginWithFingerPrintFace();
},
),
height: 400,
height:isDone == false ? ResponsiveExtension.screenHeight * 0.5 : ResponsiveExtension.screenHeight * 0.3,
isFullScreen: false,
callBackFunc: (str) {},
callBackFunc: (str) {
isDone = true;
setState(() {
});
},
);
}
}

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

Loading…
Cancel
Save