Merge branch 'master' into haroon_dev

# Conflicts:
#	lib/features/authentication/authentication_view_model.dart
pull/21/head
Haroon Amjad 2 months ago
commit 255b3c1565

@ -766,6 +766,7 @@ class ApiConsts {
SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx';
break;
case AppEnvironmentTypeEnum.preProd:
baseUrl = "https://webservices.hmg.com/";
payFortEnvironment = FortEnvironment.production;
applePayMerchantId = "merchant.com.hmgwebservices";
@ -799,6 +800,10 @@ class ApiConsts {
static final String checkPatientForRegistration = 'Services/Authentication.svc/REST/CheckPatientForRegisteration';
static final String checkUserStatus= 'Services/NHIC.svc/REST/GetPatientInfo';
static final String insertPatientDeviceIMEIData = 'Services/Patients.svc/REST/Patient_INSERTDeviceIMEI';
static final String insertPatientMobileData = 'Services/MobileNotifications.svc/REST/Insert_PatientMobileDeviceInfo';
// static values for Api
static final double appVersionID = 18.7;
static final int appChannelId = 3;

@ -7,6 +7,8 @@ import 'package:hmg_patient_app_new/features/authentication/models/resp_models/c
import 'package:hmg_patient_app_new/features/authentication/models/resp_models/select_device_by_imei.dart';
import 'package:hmg_patient_app_new/services/navigation_service.dart';
import '../features/authentication/models/request_models/registration_payload_model.dart';
class AppState {
NavigationService navigationService;
@ -103,4 +105,13 @@ class AppState {
set setNHICUserData(CheckUserStatusResponseNHIC value) {
_nHICUserData = value;
}
RegistrationDataModelPayload? _userRegistrationPayload;
RegistrationDataModelPayload get getUserRegistrationPayload => _userRegistrationPayload ?? RegistrationDataModelPayload();
set setUserRegistrationPayload(RegistrationDataModelPayload value) {
_userRegistrationPayload = value;
}
}

@ -351,6 +351,7 @@ class PushNotificationHandler {
}
onToken(String token) async {
print("Push Notification Token: " + token);
await Utils.saveStringFromPrefs(CacheConst.pushToken, token);
}

@ -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 ?? "";

@ -28,6 +28,11 @@ abstract class AuthenticationRepo {
Future<Either<Failure, GenericApiModel<dynamic>>> checkPatientForRegistration({required dynamic commonAuthanticatedRequest});
Future<Either<Failure, GenericApiModel<dynamic>>> checkUserStatus({required dynamic commonAuthanticatedRequest});
Future<Either<Failure, GenericApiModel<dynamic>>> insertPatientIMEIData({required dynamic patientIMEIDataRequest});
Future<Either<Failure, GenericApiModel<dynamic>>> insertPatientDeviceData({required dynamic patientDeviceDataRequest});
}
class AuthenticationRepoImp implements AuthenticationRepo {
@ -52,7 +57,13 @@ class AuthenticationRepoImp implements AuthenticationRepo {
try {
final list = response['Patient_SELECTDeviceIMEIbyIMEIList'];
if (list == null || list.isEmpty) {
throw Exception("Device list is empty");
apiResponse = GenericApiModel<SelectDeviceByImeiRespModelElement>(
messageStatus: messageStatus,
statusCode: statusCode,
errorMessage: errorMessage,
data: null,
);
return;
}
final model = SelectDeviceByImeiRespModelElement.fromJson(list[0] as Map<String, dynamic>);
@ -160,12 +171,18 @@ class AuthenticationRepoImp implements AuthenticationRepo {
required String? activationCode,
required bool isRegister,
}) async {
newRequest.activationCode = activationCode ?? "0000";
newRequest.isSilentLogin = activationCode != null ? false : true;
newRequest.projectOutSA = newRequest.zipCode == '966' ? false : true;
newRequest.isDentalAllowedBackend = false;
newRequest.forRegisteration = newRequest.isRegister ?? false;
newRequest.isRegister = false;
if (isRegister) {
newRequest["activationCode"] = activationCode ?? "0000";
newRequest["isSilentLogin"] = activationCode != null ? false : true;
} else {
newRequest.activationCode = activationCode ?? "0000";
newRequest.isSilentLogin = activationCode != null ? false : true;
newRequest.projectOutSA = newRequest.zipCode == '966' ? false : true;
newRequest.isDentalAllowedBackend = false;
newRequest.forRegisteration = newRequest.isRegister ?? false;
newRequest.isRegister = false;
}
final endpoint = isRegister ? ApiConsts.checkActivationCodeRegister : ApiConsts.checkActivationCode;
@ -175,7 +192,7 @@ class AuthenticationRepoImp implements AuthenticationRepo {
await apiClient.post(
endpoint,
body: newRequest.toJson(),
body: isRegister ? newRequest : newRequest.toJson(),
onFailure: (error, statusCode, {messageStatus, failureType}) {
failure = failureType;
},
@ -337,4 +354,71 @@ class AuthenticationRepoImp implements AuthenticationRepo {
return Left(UnknownFailure(e.toString()));
}
}
@override
Future<Either<Failure, GenericApiModel>> insertPatientIMEIData({required patientIMEIDataRequest}) {
try {
GenericApiModel<dynamic>? apiResponse;
Failure? failure;
return apiClient.post(
ApiConsts.insertPatientDeviceIMEIData,
body: patientIMEIDataRequest,
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())));
}
}
@override
Future<Either<Failure, GenericApiModel>> insertPatientDeviceData({required patientDeviceDataRequest}) {
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())));
}
}
}

@ -1,6 +1,6 @@
import 'dart:convert';
import 'dart:developer';
import 'package:flutter/services.dart' show rootBundle;
import 'package:flutter/material.dart';
import 'package:hijri_gregorian_calendar/hijri_gregorian_calendar.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
@ -14,6 +14,7 @@ import 'package:hmg_patient_app_new/core/utils/validation_utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/features/authentication/authentication_repo.dart';
import 'package:hmg_patient_app_new/features/authentication/models/request_models/check_activation_code_register_request_model.dart';
import 'package:hmg_patient_app_new/features/authentication/models/request_models/registration_payload_model.dart';
import 'package:hmg_patient_app_new/features/authentication/models/resp_models/check_activation_code_resp_model.dart';
import 'package:hmg_patient_app_new/features/authentication/models/resp_models/check_user_staus_nhic_response_model.dart';
import 'package:hmg_patient_app_new/features/authentication/models/resp_models/select_device_by_imei.dart';
@ -26,6 +27,9 @@ import 'package:hmg_patient_app_new/services/error_handler_service.dart';
import 'package:hmg_patient_app_new/services/localauth_service.dart';
import 'package:hmg_patient_app_new/services/navigation_service.dart';
import 'models/request_models/insert_patient_mobile_deviceinfo.dart';
import 'models/request_models/patient_insert_device_imei_request.dart';
class AuthenticationViewModel extends ChangeNotifier {
final AuthenticationRepo _authenticationRepo;
final AppState _appState;
@ -49,7 +53,7 @@ class AuthenticationViewModel extends ChangeNotifier {
_authenticationRepo = authenticationRepo,
_localAuthService = localAuthService;
final TextEditingController nationalIdController = TextEditingController(), phoneNumberController = TextEditingController(), dobController = TextEditingController();
final TextEditingController nationalIdController = TextEditingController(), phoneNumberController = TextEditingController(), dobController = TextEditingController(), nameController = TextEditingController(), emailController = TextEditingController();
CountryEnum selectedCountrySignup = CountryEnum.saudiArabia;
MaritalStatusTypeEnum? maritalStatus;
GenderTypeEnum? genderType;
@ -59,26 +63,12 @@ class AuthenticationViewModel extends ChangeNotifier {
NationalityCountries? pickedCountryByUAEUser;
CalenderEnum calenderType = CalenderEnum.gregorian;
LoginTypeEnum loginTypeEnum = LoginTypeEnum.sms;
//==================
bool isDubai = false;
bool authenticated = false;
late int mobileNumber;
String errorMsg = '';
var registerd_data;
bool isMoreOption = false;
var zipCode;
var patientOutSA;
var loginTokenID;
var loginType;
var deviceToken;
var lastLogin;
final FocusNode myFocusNode = FocusNode();
late int selectedOption = 1;
bool onlySMSBox = false;
int fingrePrintBefore = 0;
var healthId;
Future<void> onLoginPressed() async {
@ -134,8 +124,8 @@ class AuthenticationViewModel extends ChangeNotifier {
notifyListeners();
}
void loadCountriesData({required BuildContext context}) async {
final String response = await DefaultAssetBundle.of(context).loadString('assets/json/countriesList.json');
Future<void> loadCountriesData() async {
final String response = await rootBundle.loadString('assets/json/countriesList.json');
final List<dynamic> data = json.decode(response);
countriesList = data.map((e) => NationalityCountries.fromJson(e)).toList();
}
@ -164,6 +154,18 @@ class AuthenticationViewModel extends ChangeNotifier {
notifyListeners();
}
bool isUserFromUAE() {
bool isFromUAE = false;
if (_appState.getUserRegistrationPayload.patientOutSa != 0) {
isFromUAE = true;
}
return isFromUAE;
}
void savePushTokenToAppState() async {
_appState.deviceToken = await Utils.getStringFromPrefs(CacheConst.pushToken);
}
Future<void> selectDeviceImei({required Function(dynamic data) onSuccess, Function(String)? onError}) async {
// LoadingUtils.showFullScreenLoading();
// String firebaseToken = _appState.deviceToken;
@ -242,9 +244,11 @@ class AuthenticationViewModel extends ChangeNotifier {
Future<void> checkUserAuthentication({required OTPTypeEnum otpTypeEnum, Function(dynamic)? onSuccess, Function(String)? onError}) async {
// TODO: THIS SHOULD BE REMOVED LATER ON AND PASSED FROM APP STATE DIRECTLY INTO API CLIENT. BECAUSE THIS API ONLY NEEDS FEW PARAMS FROM USER
// if (phoneNumberController.text.isEmpty) {
// phoneNumberController.text = "504278212";
// }
loginTypeEnum = otpTypeEnum == OTPTypeEnum.sms ? LoginTypeEnum.sms : LoginTypeEnum.whatsapp;
if (phoneNumberController.text.isEmpty) {
phoneNumberController.text = "504278212";
}
bool isValidated = ValidationUtils.isValidatePhoneAndId(
phoneNumber: phoneNumberController.text,
nationalId: nationalIdController.text,
@ -286,7 +290,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..
);
}
}
@ -296,9 +300,9 @@ class AuthenticationViewModel extends ChangeNotifier {
}
Future<void> sendActivationCode({required OTPTypeEnum otpTypeEnum, required String nationalIdOrFileNumber, required String phoneNumber, dynamic payload}) async {
bool isForRegister = await checkIsUserComingForRegister(request: payload);
bool isPatientOutSA = await isPatientOutsideSA(request: payload);
bool isFileNo = await isPatientHasFile(request: payload);
bool isForRegister = checkIsUserComingForRegister(request: payload);
bool isPatientOutSA = isPatientOutsideSA(request: payload);
bool isFileNo = isPatientHasFile(request: payload);
var request = RequestUtils.getCommonRequestSendActivationCode(
otpTypeEnum: otpTypeEnum,
@ -348,17 +352,16 @@ class AuthenticationViewModel extends ChangeNotifier {
);
}
Future<bool> checkIsUserComingForRegister({required dynamic request}) async {
bool checkIsUserComingForRegister({required dynamic request}) {
bool isUserComingForRegister = false;
print(request);
if (request != null && request['isRegister']) {
if (request != null && request['isRegister'] == true) {
isUserComingForRegister = true;
}
return isUserComingForRegister;
}
Future<void> checkActivationCode({
required int activationCode,
required String? activationCode,
required OTPTypeEnum otpTypeEnum,
required Function(String? message) onWrongActivationCode,
}) async {
@ -371,20 +374,23 @@ class AuthenticationViewModel extends ChangeNotifier {
registeredData: null,
nationIdText: nationalIdController.text,
countryCode: selectedCountrySignup.countryCode,
loginType: loginTypeEnum.toInt
).toJson();
bool isForRegister = healthId != null || isDubai;
bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true);
if (isForRegister) {
if (isDubai) request['DOB'] = dob;
request['HealthId'] = healthId;
request['IsHijri'] = calenderType.toInt;
if (_appState.getUserRegistrationPayload.patientOutSa == true) request['DOB'] = _appState.getUserRegistrationPayload.dob;
request['HealthId'] = _appState.getUserRegistrationPayload.healthId;
request['IsHijri'] = _appState.getUserRegistrationPayload.isHijri;
final resultEither = await _authenticationRepo.checkActivationCodeRepo(newRequest: request, activationCode: activationCode.toString(), isRegister: true);
resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) {
final activation = CheckActivationCode.fromJson(apiResponse.data as Map<String, dynamic>);
if (registerd_data?.isRegister == true) {
_navigationService.popUntilNamed(AppRoutes.registerNewScreen);
if (_appState.getUserRegistrationPayload.isRegister == true) {
//TODO: KSA Version Came Hre
loadCountriesData();
_navigationService.pushAndReplace(AppRoutes.registerStepTwo);
// Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew));
return;
}
@ -392,7 +398,7 @@ class AuthenticationViewModel extends ChangeNotifier {
} else {
final resultEither = await _authenticationRepo.checkActivationCodeRepo(
newRequest: CheckActivationCodeRegisterReq.fromJson(request),
activationCode: activationCode.toString(),
activationCode: activationCode,
isRegister: false,
);
@ -406,8 +412,8 @@ class AuthenticationViewModel extends ChangeNotifier {
} else if (activation.messageStatus == 2) {
onWrongActivationCode(activation.errorEndUserMessage);
return;
} else if (registerd_data?.isRegister == true) {
_navigationService.popUntilNamed(AppRoutes.registerNewScreen);
} else if (_appState.getUserRegistrationPayload.isRegister == true) {
_navigationService.pushAndReplace(AppRoutes.registerStepTwo);
// Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew));
return;
} else {
@ -418,6 +424,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();
@ -487,7 +494,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);
@ -503,12 +510,20 @@ class AuthenticationViewModel extends ChangeNotifier {
await _dialogService.showErrorBottomSheet(message: message ?? "Something went wrong. ", onOkPressed: () {});
}
loginWithFingerPrintFace(int selectedOption) async {
_localAuthService.authenticate().then((value) {
loginWithFingerPrintFace() async {
_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;
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 {
@ -516,20 +531,28 @@ class AuthenticationViewModel extends ChangeNotifier {
notifyListeners();
}
});
this.selectedOption = selectedOption;
notifyListeners();
}
checkLastLoginStatus(Function() onSuccess) async {
Future.delayed(Duration(seconds: 1), () {
if (_appState.getSelectDeviceByImeiRespModelElement != null &&
(_appState.getSelectDeviceByImeiRespModelElement!.logInType == 1 || _appState.getSelectDeviceByImeiRespModelElement!.logInType == 4)) {
Future.delayed(Duration(seconds: 1), () {
phoneNumberController.text = (_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0")
? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "")
: _appState.getAuthenticatedUser()!.mobileNumber)!;
nationalIdController.text = _appState.getAuthenticatedUser()!.nationalityId!;
onSuccess();
});
} else if((loginTypeEnum == LoginTypeEnum.sms || loginTypeEnum == LoginTypeEnum.whatsapp && _appState.getSelectDeviceByImeiRespModelElement == null) && _appState.getAuthenticatedUser() != null){
phoneNumberController.text = (_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0")
? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "")
: _appState.getAuthenticatedUser()!.mobileNumber)!;
nationalIdController.text = _appState.getAuthenticatedUser()!.nationalityId!;
onSuccess();
}
});
}
Future<void> onRegisterPress({required OTPTypeEnum otpTypeEnum}) async {
Future<void> onRegistrationStart({required OTPTypeEnum otpTypeEnum}) async {
bool isOutSidePatient = selectedCountrySignup.countryCode == CountryEnum.unitedArabEmirates.countryCode ? true : false;
final request = await RequestUtils.getPatientAuthenticationRequest(
@ -560,6 +583,20 @@ class AuthenticationViewModel extends ChangeNotifier {
});
}
Future<void> onRegistrationComplete() async{
// if (emailAddress.text.isEmpty) {
// Utils.showErrorToast(TranslationBase.of(context).enterEmailAddress);
// return;
// } else {
// Navigator.of(context).pop();
// registerNow();
// }
//authVM!.clearDefaultInputValues();
}
Future<void> checkUserStatusForRegistration({required dynamic response, required dynamic request}) async {
if (response is Map) {
_appState.setAppAuthToken = response["LogInTokenID"];
@ -572,16 +609,16 @@ class AuthenticationViewModel extends ChangeNotifier {
} else {
request['forRegister'] = true;
request['isRegister'] = true;
if (await isPatientOutsideSA(request: response)) {
print("=======IN SA=======");
chekUserNHICData(request: request);
} else {
if (isPatientOutsideSA(request: response)) {
print("=======OUT SA=======");
_appState.setAppAuthToken = response['LogInTokenID'];
sendActivationCode(
otpTypeEnum: OTPTypeEnumExtension.fromInt(request["OTP_SendType"]),
nationalIdOrFileNumber: request["PatientIdentificationID"].toString(),
phoneNumber: request["PatientMobileNumber"].toString());
} else {
print("=======IN SA=======");
chekUserNHICData(request: request);
}
}
} else {
@ -590,23 +627,20 @@ class AuthenticationViewModel extends ChangeNotifier {
}
}
Future<bool> isPatientOutsideSA({required dynamic request}) {
try {
if (request is Map<String, dynamic> && request.containsKey("PatientOutSA")) {
if (!request["PatientOutSA"]) {
return Future.value(true);
} else {
return Future.value(false);
}
bool isPatientOutsideSA({required dynamic request}) {
bool isOutSideSa = false;
if (request is Map<String, dynamic> && request.containsKey("PatientOutSA")) {
if (request["PatientOutSA"] == true) {
isOutSideSa = true;
} else {
return Future.value(false);
isOutSideSa = false;
}
} catch (e) {
return Future.value(false);
}
print(isOutSideSa);
return isOutSideSa;
}
Future<bool> isPatientHasFile({required dynamic request}) async {
bool isPatientHasFile({required dynamic request}) {
bool isFile = false;
if (request != null && request["NationalID"] != null) {
isFile = request["NationalID"].length < 10;
@ -618,13 +652,12 @@ class AuthenticationViewModel extends ChangeNotifier {
final resultEither = await _authenticationRepo.checkUserStatus(commonAuthanticatedRequest: request);
resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async {
if (apiResponse.data is Map) {
_appState.setNHICUserData = CheckUserStatusResponseNHIC.fromJson(apiResponse.data as Map<String, dynamic>);
setNHICData(apiResponse.data, request);
sendActivationCode(
otpTypeEnum: OTPTypeEnumExtension.fromInt(request["OTP_SendType"]),
nationalIdOrFileNumber: request["PatientIdentificationID"].toString(),
phoneNumber: request["PatientMobileNumber"].toString(),
payload: request,
);
otpTypeEnum: OTPTypeEnumExtension.fromInt(request["OTP_SendType"]),
nationalIdOrFileNumber: request["PatientIdentificationID"].toString(),
phoneNumber: request["PatientMobileNumber"].toString(),
payload: request);
}
});
@ -664,6 +697,38 @@ class AuthenticationViewModel extends ChangeNotifier {
// });
}
void setNHICData(dynamic data, dynamic request) {
_appState.setNHICUserData = CheckUserStatusResponseNHIC.fromJson(data as Map<String, dynamic>);
request["healthId"] = _appState.getNHICUserData.healthId;
_appState.setUserRegistrationPayload = RegistrationDataModelPayload.fromJson(request);
}
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!, 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) {
log("Insert IMEI Success");
insertPatientDeviceData( loginType);
} else {
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, 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) {
log("Insert Device Data Success");
} else {
log("Insert IMEI Failed");
}
});
}
@override
void dispose() {
nationalIdController.dispose();

@ -0,0 +1,109 @@
import 'dart:convert';
class InsertPatientMobileDeviceInfo {
double? versionId;
int? channel;
int? languageId;
String? ipAdress;
String? generalid;
int? patientOutSa;
bool? isDentalAllowedBackend;
int? deviceTypeId;
int? patientId;
String? tokenId;
String? voipToken;
int? patientTypeId;
int? patientType;
String? deviceToken;
String? deviceType;
String? patientMobileNumber;
String? nationalId;
int? gender;
int? loginType;
String? macAddress;
double? latitude;
double? longitude;
String? sessionId;
InsertPatientMobileDeviceInfo({
this.versionId,
this.channel,
this.languageId,
this.ipAdress,
this.generalid,
this.patientOutSa,
this.isDentalAllowedBackend,
this.deviceTypeId,
this.patientId,
this.tokenId,
this.voipToken,
this.patientTypeId,
this.patientType,
this.deviceToken,
this.deviceType,
this.patientMobileNumber,
this.nationalId,
this.gender,
this.loginType,
this.macAddress,
this.latitude,
this.longitude,
this.sessionId,
});
factory InsertPatientMobileDeviceInfo.fromRawJson(String str) => InsertPatientMobileDeviceInfo.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory InsertPatientMobileDeviceInfo.fromJson(Map<String, dynamic> json) => InsertPatientMobileDeviceInfo(
versionId: json["VersionID"]?.toDouble(),
channel: json["Channel"],
languageId: json["LanguageID"],
ipAdress: json["IPAdress"],
generalid: json["generalid"],
patientOutSa: json["PatientOutSA"],
isDentalAllowedBackend: json["isDentalAllowedBackend"],
deviceTypeId: json["DeviceTypeID"],
patientId: json["PatientID"],
tokenId: json["TokenID"],
voipToken: json["VoipToken"],
patientTypeId: json["PatientTypeID"],
patientType: json["PatientType"],
deviceToken: json["DeviceToken"],
deviceType: json["DeviceType"],
patientMobileNumber: json["PatientMobileNumber"],
nationalId: json["NationalID"],
gender: json["Gender"],
loginType: json["LoginType"],
macAddress: json["MACAddress"],
latitude: json["Latitude"],
longitude: json["Longitude"],
sessionId: json[" SessionID"],
);
Map<String, dynamic> toJson() => {
"VersionID": versionId,
"Channel": channel,
"LanguageID": languageId,
"IPAdress": ipAdress,
"generalid": generalid,
"PatientOutSA": patientOutSa,
"isDentalAllowedBackend": isDentalAllowedBackend,
"DeviceTypeID": deviceTypeId,
"PatientID": patientId,
"TokenID": tokenId,
"VoipToken": voipToken,
"PatientTypeID": patientTypeId,
"PatientType": patientType,
"DeviceToken": deviceToken,
"DeviceType": deviceType,
"PatientMobileNumber": patientMobileNumber,
"NationalID": nationalId,
"Gender": gender,
"LoginType": loginType,
"MACAddress": macAddress,
"Latitude": latitude,
"Longitude": longitude,
" SessionID": sessionId,
};
}

@ -0,0 +1,126 @@
import 'dart:convert';
class PatientInsertDeviceImei {
String? setupId;
int? patientType;
int? patientId;
String? firstName;
String? firstNameN;
String? lastNameN;
int? preferredLanguage;
String? patientIdentificationNo;
bool? outSa;
String? identificationNo;
String? mobileNo;
String? tokenId;
String? imei;
bool? biometricEnabled;
int? logInTypeId;
double? versionId;
int? channel;
int? languageId;
String? ipAdress;
String? generalid;
int? latitude;
int? longitude;
int? deviceTypeId;
int? patientTypeId;
int? patientOutSa;
String? sessionId;
String? lastName;
PatientInsertDeviceImei({
this.setupId,
this.patientType,
this.patientId,
this.firstName,
this.firstNameN,
this.lastNameN,
this.preferredLanguage,
this.patientIdentificationNo,
this.outSa,
this.identificationNo,
this.mobileNo,
this.tokenId,
this.imei,
this.biometricEnabled,
this.logInTypeId,
this.versionId,
this.channel,
this.languageId,
this.ipAdress,
this.generalid,
this.latitude,
this.longitude,
this.deviceTypeId,
this.patientTypeId,
this.patientOutSa,
this.sessionId,
this.lastName
});
factory PatientInsertDeviceImei.fromRawJson(String str) => PatientInsertDeviceImei.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory PatientInsertDeviceImei.fromJson(Map<String, dynamic> json) => PatientInsertDeviceImei(
setupId: json["SetupID"],
patientType: json["PatientType"],
patientId: json["PatientID"],
firstName: json["FirstName"],
firstNameN: json["FirstNameN"],
lastNameN: json["LastNameN"],
preferredLanguage: json["PreferredLanguage"],
patientIdentificationNo: json["PatientIdentificationNo"],
outSa: json["OutSA"],
identificationNo: json["IdentificationNo"],
mobileNo: json["MobileNo"],
tokenId: json["TokenID"],
imei: json["IMEI"],
biometricEnabled: json["BiometricEnabled"],
logInTypeId: json["LogInTypeID"],
versionId: json["VersionID"]?.toDouble(),
channel: json["Channel"],
languageId: json["LanguageID"],
ipAdress: json["IPAdress"],
generalid: json["generalid"],
latitude: json["Latitude"],
longitude: json["Longitude"],
deviceTypeId: json["DeviceTypeID"],
patientTypeId: json["PatientTypeID"],
patientOutSa: json["PatientOutSA"],
sessionId: json["SessionID"],
lastName: json["LastName"],
);
Map<String, dynamic> toJson() => {
"SetupID": setupId,
"PatientType": patientType,
"PatientID": patientId,
"FirstName": firstName,
"FirstNameN": firstNameN,
"LastNameN": lastNameN,
"PreferredLanguage": preferredLanguage,
"PatientIdentificationNo": patientIdentificationNo,
"OutSA": outSa,
"IdentificationNo": identificationNo,
"MobileNo": mobileNo,
"TokenID": tokenId,
"IMEI": imei,
"BiometricEnabled": biometricEnabled,
"LogInTypeID": logInTypeId,
"VersionID": versionId,
"Channel": channel,
"LanguageID": languageId,
"IPAdress": ipAdress,
"generalid": generalid,
"Latitude": latitude,
"Longitude": longitude,
"DeviceTypeID": deviceTypeId,
"PatientTypeID": patientTypeId,
"PatientOutSA": patientOutSa,
"SessionID": sessionId,
"LastName": lastName,
};
}

@ -0,0 +1,69 @@
import 'dart:convert';
class RegistrationDataModelPayload {
int? patientMobileNumber;
String? zipCode;
int? searchType;
int? patientId;
int? patientIdentificationId;
int? otpSendType;
int? patientOutSa;
bool? isDentalAllowedBackend;
String? dob;
int? isHijri;
bool? forRegister;
bool? isRegister;
String? healthId;
RegistrationDataModelPayload({
this.patientMobileNumber,
this.zipCode,
this.searchType,
this.patientId,
this.patientIdentificationId,
this.otpSendType,
this.patientOutSa,
this.isDentalAllowedBackend,
this.dob,
this.isHijri,
this.forRegister,
this.isRegister,
this.healthId,
});
factory RegistrationDataModelPayload.fromRawJson(String str) => RegistrationDataModelPayload.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory RegistrationDataModelPayload.fromJson(Map<String, dynamic> json) => RegistrationDataModelPayload(
patientMobileNumber: json["PatientMobileNumber"],
zipCode: json["ZipCode"],
searchType: json["SearchType"],
patientId: json["PatientID"],
patientIdentificationId: json["PatientIdentificationID"],
otpSendType: json["OTP_SendType"],
patientOutSa: json["PatientOutSA"],
isDentalAllowedBackend: json["isDentalAllowedBackend"],
dob: json["DOB"],
isHijri: json["IsHijri"],
forRegister: json["forRegister"],
isRegister: json["isRegister"],
healthId: json["healthId"],
);
Map<String, dynamic> toJson() => {
"PatientMobileNumber": patientMobileNumber,
"ZipCode": zipCode,
"SearchType": searchType,
"PatientID": patientId,
"PatientIdentificationID": patientIdentificationId,
"OTP_SendType": otpSendType,
"PatientOutSA": patientOutSa,
"isDentalAllowedBackend": isDentalAllowedBackend,
"DOB": dob,
"IsHijri": isHijri,
"forRegister": forRegister,
"isRegister": isRegister,
"healthId": healthId,
};
}

@ -203,6 +203,7 @@ class LoginScreenState extends State<LoginScreen> {
borderColor: AppColors.borderOnlyColor,
textColor: AppColors.textColor,
icon: AppAssets.whatsapp,
iconColor: null,
),
),
],

@ -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),

@ -222,7 +222,7 @@ class _RegisterNew extends State<RegisterNew> {
child: CustomButton(
text: LocaleKeys.sendOTPSMS.tr(),
onPressed: () async {
await authVM.onRegisterPress(otpTypeEnum: OTPTypeEnum.sms);
await authVM.onRegistrationStart(otpTypeEnum: OTPTypeEnum.sms);
},
backgroundColor: AppColors.primaryRedColor,
borderColor: AppColors.primaryRedBorderColor,
@ -245,7 +245,7 @@ class _RegisterNew extends State<RegisterNew> {
child: CustomButton(
text: LocaleKeys.sendOTPWHATSAPP.tr(),
onPressed: () async {
await authVM.onRegisterPress(otpTypeEnum: OTPTypeEnum.whatsapp);
await authVM.onRegistrationStart(otpTypeEnum: OTPTypeEnum.whatsapp);
},
backgroundColor: AppColors.whiteColor,
borderColor: AppColors.borderOnlyColor,

@ -19,31 +19,24 @@ import 'package:hmg_patient_app_new/widgets/input_widget.dart';
import 'package:provider/provider.dart';
class RegisterNewStep2 extends StatefulWidget {
var nHICData;
var payload;
RegisterNewStep2(this.nHICData, this.payload, {Key? key}) : super(key: key);
RegisterNewStep2({Key? key}) : super(key: key);
@override
_RegisterNew createState() => _RegisterNew();
}
class _RegisterNew extends State<RegisterNewStep2> {
bool isFromDubai = true;
AuthenticationViewModel? authVM;
@override
void initState() {
super.initState();
authVM = context.read<AuthenticationViewModel>();
authVM!.loadCountriesData(context: context);
// isFromDubai = widget.payload.zipCode!.contains("971") || widget.payload.zipCode!.contains("+971");
}
@override
void dispose() {
super.dispose();
authVM!.clearDefaultInputValues();
}
@override
@ -72,22 +65,22 @@ class _RegisterNew extends State<RegisterNewStep2> {
child: Column(
children: [
TextInputWidget(
labelText: isFromDubai ? LocaleKeys.fullName.tr() : LocaleKeys.name.tr(),
hintText: isFromDubai ? "name" ?? "" : (widget.nHICData!.firstNameEn!.toUpperCase() + " " + widget.nHICData!.lastNameEn!.toUpperCase()),
controller: null,
labelText: authVM!.isUserFromUAE() ? LocaleKeys.fullName.tr() : LocaleKeys.name.tr(),
hintText: authVM!.isUserFromUAE() ? "" : ("${appState.getNHICUserData.firstNameEn!.toUpperCase()} ${appState.getNHICUserData.lastNameEn!.toUpperCase()}"),
controller: authVM!.isUserFromUAE() ? authVM!.nameController : null,
isEnable: true,
prefix: null,
isAllowRadius: false,
isBorderAllowed: false,
keyboardType: TextInputType.text,
isAllowLeadingIcon: true,
isReadOnly: isFromDubai ? false : true,
isReadOnly: authVM!.isUserFromUAE() ? false : true,
leadingIcon: AppAssets.user_circle)
.paddingSymmetrical(0.h, 16.h),
Divider(height: 1, color: AppColors.greyColor),
TextInputWidget(
labelText: LocaleKeys.nationalIdNumber.tr(),
hintText: isFromDubai ? "widget.payload.nationalID!" : (widget.nHICData!.idNumber ?? ""),
hintText: authVM!.isUserFromUAE() ? appState.getUserRegistrationPayload.patientIdentificationId.toString() : (appState.getNHICUserData.idNumber ?? ""),
controller: null,
isEnable: true,
prefix: null,
@ -98,7 +91,7 @@ class _RegisterNew extends State<RegisterNewStep2> {
leadingIcon: AppAssets.student_card)
.paddingSymmetrical(0.h, 16.h),
Divider(height: 1, color: AppColors.greyColor),
isFromDubai
authVM!.isUserFromUAE()
? Selector<AuthenticationViewModel, GenderTypeEnum?>(
selector: (_, authViewModel) => authViewModel.genderType,
shouldRebuild: (previous, next) => previous != next,
@ -121,19 +114,19 @@ class _RegisterNew extends State<RegisterNewStep2> {
})
: TextInputWidget(
labelText: LocaleKeys.gender.tr(),
hintText: (widget.nHICData!.gender ?? ""),
hintText: (appState.getNHICUserData.gender ?? ""),
controller: null,
isEnable: true,
prefix: null,
isAllowRadius: false,
isBorderAllowed: false,
isAllowLeadingIcon: true,
isReadOnly: isFromDubai ? false : true,
isReadOnly: authVM!.isUserFromUAE() ? false : true,
leadingIcon: AppAssets.user_full,
onChange: (value) {})
.paddingSymmetrical(0.h, 16.h),
Divider(height: 1, color: AppColors.greyColor),
isFromDubai
authVM!.isUserFromUAE()
? Selector<AuthenticationViewModel, MaritalStatusTypeEnum?>(
selector: (_, authViewModel) => authViewModel.maritalStatus,
shouldRebuild: (previous, next) => previous != next,
@ -158,8 +151,8 @@ class _RegisterNew extends State<RegisterNewStep2> {
: TextInputWidget(
labelText: LocaleKeys.maritalStatus.tr(),
hintText: appState.isArabic()
? (MaritalStatusTypeExtension.fromValue(widget.nHICData!.maritalStatusCode)!.typeAr)
: (MaritalStatusTypeExtension.fromValue(widget.nHICData!.maritalStatusCode)!.type),
? (MaritalStatusTypeExtension.fromValue(appState.getNHICUserData.maritalStatusCode)!.typeAr)
: (MaritalStatusTypeExtension.fromValue(appState.getNHICUserData.maritalStatusCode)!.type),
isEnable: true,
prefix: null,
isAllowRadius: false,
@ -170,7 +163,7 @@ class _RegisterNew extends State<RegisterNewStep2> {
onChange: (value) {})
.paddingSymmetrical(0.h, 16.h),
Divider(height: 1, color: AppColors.greyColor),
isFromDubai
authVM!.isUserFromUAE()
? Selector<AuthenticationViewModel, ({List<NationalityCountries>? countriesList, NationalityCountries? selectedCountry, bool isArabic})>(
selector: (context, authViewModel) {
final appState = getIt.get<AppState>();
@ -206,8 +199,8 @@ class _RegisterNew extends State<RegisterNewStep2> {
: TextInputWidget(
labelText: LocaleKeys.nationality.tr(),
hintText: appState.isArabic()
? (authVM!.countriesList!.firstWhere((e) => e.id == (widget.nHICData!.nationalityCode ?? ""), orElse: () => NationalityCountries()).nameN ?? "")
: (authVM!.countriesList!.firstWhere((e) => e.id == (widget.nHICData!.nationalityCode ?? ""), orElse: () => NationalityCountries()).name ?? ""),
? (authVM!.countriesList!.firstWhere((e) => e.id == (appState.getNHICUserData.nationalityCode ?? ""), orElse: () => NationalityCountries()).nameN ?? "")
: (authVM!.countriesList!.firstWhere((e) => e.id == (appState.getNHICUserData.nationalityCode ?? ""), orElse: () => NationalityCountries()).name ?? ""),
isEnable: true,
prefix: null,
isAllowRadius: false,
@ -223,7 +216,7 @@ class _RegisterNew extends State<RegisterNewStep2> {
),
TextInputWidget(
labelText: LocaleKeys.mobileNumber.tr(),
hintText: ("widget.payload.mobileNo" ?? ""),
hintText: (appState.getUserRegistrationPayload.patientMobileNumber.toString() ?? ""),
controller: authVM!.phoneNumberController,
isEnable: true,
prefix: null,
@ -240,15 +233,15 @@ class _RegisterNew extends State<RegisterNewStep2> {
),
TextInputWidget(
labelText: LocaleKeys.dob.tr(),
hintText: isFromDubai ? "widget.payload.dob!" : (widget.nHICData!.dateOfBirth ?? ""),
hintText: authVM!.isUserFromUAE() ? appState.getUserRegistrationPayload.dob! : (appState.getNHICUserData.dateOfBirth ?? ""),
controller: authVM!.dobController,
isEnable: true,
isEnable: authVM!.isUserFromUAE() ? true : false,
prefix: null,
isBorderAllowed: false,
isAllowLeadingIcon: true,
isReadOnly: true,
leadingIcon: AppAssets.birthday_cake,
selectionType: SelectionTypeEnum.calendar,
selectionType: authVM!.isUserFromUAE() ? SelectionTypeEnum.calendar : null,
).paddingSymmetrical(0.h, 16.h),
],
),
@ -324,7 +317,7 @@ class _RegisterNew extends State<RegisterNewStep2> {
padding: EdgeInsets.only(bottom: MediaQuery.of(bottomSheetContext).viewInsets.bottom),
child: SingleChildScrollView(
child: GenericBottomSheet(
textController: TextEditingController(),
textController: authVM!.emailController,
isForEmail: true,
buttons: [
Padding(
@ -332,13 +325,7 @@ class _RegisterNew extends State<RegisterNewStep2> {
child: CustomButton(
text: LocaleKeys.submit,
onPressed: () {
// if (emailAddress.text.isEmpty) {
// Utils.showErrorToast(TranslationBase.of(context).enterEmailAddress);
// return;
// } else {
// Navigator.of(context).pop();
// registerNow();
// }
authVM!.onRegistrationComplete();
},
backgroundColor: AppColors.bgGreenColor,
borderColor: AppColors.bgGreenColor,

@ -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,16 +80,16 @@ 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")
? DateUtil.getFormattedDate(DateUtil.convertStringToDate(appState.getSelectDeviceByImeiRespModelElement!.createdOn!), "d MMMM, y 'at' HH:mm")
: '--')
.toText16(isBold: true, color: AppColors.textColor),
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,
@ -95,7 +97,7 @@ class _SavedLogin extends State<SavedLogin> {
text: "${LocaleKeys.loginBy.tr()} ${loginType.displayName}",
onPressed: () {
if (loginType == LoginTypeEnum.fingerprint || loginType == LoginTypeEnum.face) {
authVm.loginWithFingerPrintFace(loginType.toInt);
authVm.loginWithFingerPrintFace();
} else {
// int? val = loginType.toInt;
authVm.checkUserAuthentication(otpTypeEnum: loginType == LoginTypeEnum.sms ? OTPTypeEnum.sms : OTPTypeEnum.whatsapp);
@ -108,7 +110,7 @@ class _SavedLogin extends State<SavedLogin> {
fontWeight: FontWeight.w500,
borderRadius: 12,
padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
icon: AppAssets.apple_finder,
icon: AppAssets.sms,
),
),
],
@ -165,7 +167,7 @@ class _SavedLogin extends State<SavedLogin> {
backgroundColor: AppColors.primaryRedColor,
borderColor: AppColors.primaryRedBorderColor,
textColor: AppColors.whiteColor,
icon: AppAssets.message,
icon: AppAssets.sms,
),
),
Row(
@ -214,9 +216,11 @@ class _SavedLogin extends State<SavedLogin> {
)
: CustomButton(
text: "${LocaleKeys.loginBy.tr()} ${LoginTypeEnum.whatsapp.displayName}",
icon: AppAssets.whatsapp,
iconColor: null,
onPressed: () {
if (loginType == LoginTypeEnum.fingerprint || loginType == LoginTypeEnum.face) {
authVm.loginWithFingerPrintFace(loginType.toInt);
authVm.loginWithFingerPrintFace();
} else {
loginType = LoginTypeEnum.whatsapp;
int? val = loginType.toInt;
@ -228,7 +232,7 @@ class _SavedLogin extends State<SavedLogin> {
textColor: Color(0xFF2E3039),
borderWidth: 2,
padding: EdgeInsets.fromLTRB(0, 14, 0, 14),
icon: AppAssets.whatsapp,
),
const Spacer(flex: 2),
// OR divider

@ -39,9 +39,10 @@ class _LandingPageState extends State<LandingPage> {
@override
void initState() {
authVM = context.read<AuthenticationViewModel>();
authVM.savePushTokenToAppState();
if (mounted) {
authVM.checkLastLoginStatus(() {
// showQuickLogin(context, false);
showQuickLogin(context, false);
});
}
super.initState();
@ -325,15 +326,20 @@ class _LandingPageState extends State<LandingPage> {
context,
title: "",
child: QuickLogin(
isDone: isDone,
isDone: isDone,
onPressed: () {
// sharedPref.setBool(HAS_ENABLED_QUICK_LOGIN, true);
// loginWithFingerPrintFace(3, 1, user, deviceToken);
authVM.loginWithFingerPrintFace();
},
),
height: 400,
height:isDone == false ? ResponsiveExtension.screenHeight * 0.5 : ResponsiveExtension.screenHeight * 0.3,
isFullScreen: false,
callBackFunc: (str) {},
callBackFunc: (str) {
isDone = true;
setState(() {
});
},
);
}
}

@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/presentation/authentication/login.dart';
import 'package:hmg_patient_app_new/presentation/authentication/register.dart';
import 'package:hmg_patient_app_new/presentation/authentication/register_step2.dart';
import 'package:hmg_patient_app_new/presentation/home/landing_page.dart';
import 'package:hmg_patient_app_new/presentation/home/navigation_screen.dart';
import 'package:hmg_patient_app_new/splashPage.dart';
@ -7,12 +9,15 @@ import 'package:hmg_patient_app_new/splashPage.dart';
class AppRoutes {
static const String initialRoute = '/initialRoute';
static const String loginScreen = '/loginScreen';
static const String registerNewScreen = '/registerNewScreen';
static const String register = '/register';
static const String registerStepTwo = '/registerStepTwo';
static const String landingScreen = '/landingScreen';
static Map<String, WidgetBuilder> get routes => {
initialRoute: (context) => SplashPage(),
loginScreen: (context) => LoginScreen(),
landingScreen: (context) => LandingNavigation(),
register: (context) => RegisterNew(),
registerStepTwo: (context) => RegisterNewStep2(),
};
}

@ -6,22 +6,31 @@ class LocalAuthService {
final LocalAuthentication localAuth;
final LoggerService loggerService;
LocalAuthService({required this.localAuth, required this.loggerService});
Future<bool> authenticate() async {
try {
bool isAuthenticated = await localAuth.authenticate(
final canCheck = await localAuth.canCheckBiometrics;
final isDeviceSupported = await localAuth.isDeviceSupported();
if (!canCheck || !isDeviceSupported) {
return false;
}
final isAuthenticated = await localAuth.authenticate(
localizedReason: 'Please authenticate to proceed',
options: const AuthenticationOptions(
biometricOnly: true,
stickyAuth: true,
),
);
return isAuthenticated;
} catch (e) {
print(e);
return false;
}
}
Future<bool> canCheckBiometrics() async {
try {
return await localAuth.canCheckBiometrics;

@ -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,

@ -105,7 +105,7 @@ class _CustomCountryDropdownState extends State<CustomCountryDropdown> {
SizedBox(width: 4.h),
if (widget.isEnableTextField)
SizedBox(
height: 20,
height: 18,
width: 200,
child: TextField(
focusNode: textFocusNode,

Loading…
Cancel
Save