From 9b063ba7649aec71e6060c9625fe0ac3c0607dde Mon Sep 17 00:00:00 2001 From: aamir-csol Date: Tue, 9 Sep 2025 15:08:34 +0300 Subject: [PATCH 1/4] fixes for signup --- lib/core/api_consts.dart | 1 + lib/core/app_state.dart | 11 ++ lib/core/utils/push_notification_handler.dart | 1 + .../authentication/authentication_repo.dart | 27 +++-- .../authentication_view_model.dart | 112 +++++++++--------- .../registration_payload_model.dart | 69 +++++++++++ .../authentication/register_step2.dart | 47 ++++---- lib/presentation/home/landing_page.dart | 1 + lib/routes/app_routes.dart | 7 +- .../dropdown/country_dropdown_widget.dart | 2 +- 10 files changed, 186 insertions(+), 92 deletions(-) create mode 100644 lib/features/authentication/models/request_models/registration_payload_model.dart diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart index 5b6c873..3b3ed28 100644 --- a/lib/core/api_consts.dart +++ b/lib/core/api_consts.dart @@ -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"; diff --git a/lib/core/app_state.dart b/lib/core/app_state.dart index e5537c6..4408844 100644 --- a/lib/core/app_state.dart +++ b/lib/core/app_state.dart @@ -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!; + + set setUserRegistrationPayload(RegistrationDataModelPayload value) { + _userRegistrationPayload = value; + } } diff --git a/lib/core/utils/push_notification_handler.dart b/lib/core/utils/push_notification_handler.dart index 1d2141e..4568a15 100644 --- a/lib/core/utils/push_notification_handler.dart +++ b/lib/core/utils/push_notification_handler.dart @@ -351,6 +351,7 @@ class PushNotificationHandler { } onToken(String token) async { + print("Push Notification Token: " + token); await Utils.saveStringFromPrefs(CacheConst.pushToken, token); } diff --git a/lib/features/authentication/authentication_repo.dart b/lib/features/authentication/authentication_repo.dart index 21061dc..7a4d1c1 100644 --- a/lib/features/authentication/authentication_repo.dart +++ b/lib/features/authentication/authentication_repo.dart @@ -52,7 +52,13 @@ class AuthenticationRepoImp implements AuthenticationRepo { try { final list = response['Patient_SELECTDeviceIMEIbyIMEIList']; if (list == null || list.isEmpty) { - throw Exception("Device list is empty"); + apiResponse = GenericApiModel( + messageStatus: messageStatus, + statusCode: statusCode, + errorMessage: errorMessage, + data: null, + ); + return; } final model = SelectDeviceByImeiRespModelElement.fromJson(list[0] as Map); @@ -160,12 +166,17 @@ 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 +186,7 @@ class AuthenticationRepoImp implements AuthenticationRepo { await apiClient.post( endpoint, - body: newRequest.toJson(), + body: isRegister ? newRequest : newRequest.toJson(), onFailure: (error, statusCode, {messageStatus, failureType}) { failure = failureType; }, diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index 6a2ea74..e3c8520 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -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'; @@ -49,7 +50,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(); CountryEnum selectedCountrySignup = CountryEnum.saudiArabia; MaritalStatusTypeEnum? maritalStatus; GenderTypeEnum? genderType; @@ -62,23 +63,8 @@ class AuthenticationViewModel extends ChangeNotifier { //================== - 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 onLoginPressed() async { @@ -134,8 +120,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 loadCountriesData() async { + final String response = await rootBundle.loadString('assets/json/countriesList.json'); final List data = json.decode(response); countriesList = data.map((e) => NationalityCountries.fromJson(e)).toList(); } @@ -164,6 +150,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 selectDeviceImei({required Function(dynamic data) onSuccess, Function(String)? onError}) async { // LoadingUtils.showFullScreenLoading(); // String firebaseToken = _appState.deviceToken; @@ -293,9 +291,9 @@ class AuthenticationViewModel extends ChangeNotifier { } Future 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, @@ -345,10 +343,9 @@ class AuthenticationViewModel extends ChangeNotifier { ); } - Future 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; @@ -370,18 +367,20 @@ class AuthenticationViewModel extends ChangeNotifier { countryCode: selectedCountrySignup.countryCode, ).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); - 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; } @@ -403,8 +402,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 { @@ -513,7 +512,6 @@ class AuthenticationViewModel extends ChangeNotifier { notifyListeners(); } }); - this.selectedOption = selectedOption; notifyListeners(); } @@ -569,16 +567,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 { @@ -587,23 +585,20 @@ class AuthenticationViewModel extends ChangeNotifier { } } - Future isPatientOutsideSA({required dynamic request}) { - try { - if (request is Map && 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 && 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 isPatientHasFile({required dynamic request}) async { + bool isPatientHasFile({required dynamic request}) { bool isFile = false; if (request != null && request["NationalID"] != null) { isFile = request["NationalID"].length < 10; @@ -615,13 +610,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); + 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); } }); @@ -661,6 +655,12 @@ class AuthenticationViewModel extends ChangeNotifier { // }); } + void setNHICData(dynamic data, dynamic request) { + _appState.setNHICUserData = CheckUserStatusResponseNHIC.fromJson(data as Map); + request["healthId"] = _appState.getNHICUserData.healthId; + _appState.setUserRegistrationPayload = RegistrationDataModelPayload.fromJson(request); + } + @override void dispose() { nationalIdController.dispose(); diff --git a/lib/features/authentication/models/request_models/registration_payload_model.dart b/lib/features/authentication/models/request_models/registration_payload_model.dart new file mode 100644 index 0000000..fa4f612 --- /dev/null +++ b/lib/features/authentication/models/request_models/registration_payload_model.dart @@ -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 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 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, + }; +} diff --git a/lib/presentation/authentication/register_step2.dart b/lib/presentation/authentication/register_step2.dart index 1e4c650..92faaee 100644 --- a/lib/presentation/authentication/register_step2.dart +++ b/lib/presentation/authentication/register_step2.dart @@ -19,31 +19,25 @@ 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 { - bool isFromDubai = true; AuthenticationViewModel? authVM; @override void initState() { super.initState(); authVM = context.read(); - authVM!.loadCountriesData(context: context); - // isFromDubai = widget.payload.zipCode!.contains("971") || widget.payload.zipCode!.contains("+971"); } @override void dispose() { super.dispose(); - authVM!.clearDefaultInputValues(); + // authVM!.clearDefaultInputValues(); } @override @@ -72,22 +66,23 @@ class _RegisterNew extends State { 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 +93,7 @@ class _RegisterNew extends State { leadingIcon: AppAssets.student_card) .paddingSymmetrical(0.h, 16.h), Divider(height: 1, color: AppColors.greyColor), - isFromDubai + authVM!.isUserFromUAE() ? Selector( selector: (_, authViewModel) => authViewModel.genderType, shouldRebuild: (previous, next) => previous != next, @@ -121,19 +116,19 @@ class _RegisterNew extends State { }) : 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( selector: (_, authViewModel) => authViewModel.maritalStatus, shouldRebuild: (previous, next) => previous != next, @@ -158,8 +153,8 @@ class _RegisterNew extends State { : 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 +165,7 @@ class _RegisterNew extends State { onChange: (value) {}) .paddingSymmetrical(0.h, 16.h), Divider(height: 1, color: AppColors.greyColor), - isFromDubai + authVM!.isUserFromUAE() ? Selector? countriesList, NationalityCountries? selectedCountry, bool isArabic})>( selector: (context, authViewModel) { final appState = getIt.get(); @@ -206,8 +201,8 @@ class _RegisterNew extends State { : 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 +218,7 @@ class _RegisterNew extends State { ), TextInputWidget( labelText: LocaleKeys.mobileNumber.tr(), - hintText: ("widget.payload.mobileNo" ?? ""), + hintText: (appState.getUserRegistrationPayload.patientMobileNumber.toString() ?? ""), controller: authVM!.phoneNumberController, isEnable: true, prefix: null, @@ -240,15 +235,15 @@ class _RegisterNew extends State { ), 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), ], ), diff --git a/lib/presentation/home/landing_page.dart b/lib/presentation/home/landing_page.dart index b33658f..29bed41 100644 --- a/lib/presentation/home/landing_page.dart +++ b/lib/presentation/home/landing_page.dart @@ -39,6 +39,7 @@ class _LandingPageState extends State { @override void initState() { authVM = context.read(); + authVM.savePushTokenToAppState(); if (mounted) { authVM.checkLastLoginStatus(() { // showQuickLogin(context, false); diff --git a/lib/routes/app_routes.dart b/lib/routes/app_routes.dart index 93146d6..67bf208 100644 --- a/lib/routes/app_routes.dart +++ b/lib/routes/app_routes.dart @@ -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 get routes => { initialRoute: (context) => SplashPage(), loginScreen: (context) => LoginScreen(), landingScreen: (context) => LandingNavigation(), + register: (context) => RegisterNew(), + registerStepTwo: (context) => RegisterNewStep2(), }; } diff --git a/lib/widgets/dropdown/country_dropdown_widget.dart b/lib/widgets/dropdown/country_dropdown_widget.dart index 3d28e23..4e41c31 100644 --- a/lib/widgets/dropdown/country_dropdown_widget.dart +++ b/lib/widgets/dropdown/country_dropdown_widget.dart @@ -105,7 +105,7 @@ class _CustomCountryDropdownState extends State { SizedBox(width: 4.h), if (widget.isEnableTextField) SizedBox( - height: 20, + height: 18, width: 200, child: TextField( focusNode: textFocusNode, From a199ca040b7c1c5e0daa30608159eebe26da6c00 Mon Sep 17 00:00:00 2001 From: Sultan khan Date: Tue, 9 Sep 2025 15:09:13 +0300 Subject: [PATCH 2/4] quick login inprogress --- lib/core/api_consts.dart | 4 + .../authentication/authentication_repo.dart | 55 +++++++- .../authentication_view_model.dart | 51 ++++++- .../insert_patient_mobile_deviceinfo.dart | 109 +++++++++++++++ .../patient_insert_device_imei_request.dart | 125 ++++++++++++++++++ lib/presentation/authentication/login.dart | 1 + .../authentication/saved_login_screen.dart | 14 +- lib/presentation/home/landing_page.dart | 4 +- lib/services/localauth_service.dart | 13 +- lib/widgets/buttons/custom_button.dart | 2 +- 10 files changed, 362 insertions(+), 16 deletions(-) create mode 100644 lib/features/authentication/models/request_models/insert_patient_mobile_deviceinfo.dart create mode 100644 lib/features/authentication/models/request_models/patient_insert_device_imei_request.dart diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart index 5b6c873..1bbbff8 100644 --- a/lib/core/api_consts.dart +++ b/lib/core/api_consts.dart @@ -799,6 +799,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; diff --git a/lib/features/authentication/authentication_repo.dart b/lib/features/authentication/authentication_repo.dart index 21061dc..d58ffeb 100644 --- a/lib/features/authentication/authentication_repo.dart +++ b/lib/features/authentication/authentication_repo.dart @@ -28,6 +28,11 @@ abstract class AuthenticationRepo { Future>> checkPatientForRegistration({required dynamic commonAuthanticatedRequest}); Future>> checkUserStatus({required dynamic commonAuthanticatedRequest}); + + Future>> insertPatientIMEIData({required dynamic patientIMEIDataRequest}); + + Future>> insertPatientDeviceData({required dynamic patientDeviceDataRequest}); + } class AuthenticationRepoImp implements AuthenticationRepo { @@ -52,7 +57,14 @@ class AuthenticationRepoImp implements AuthenticationRepo { try { final list = response['Patient_SELECTDeviceIMEIbyIMEIList']; if (list == null || list.isEmpty) { - throw Exception("Device list is empty"); + //throw Exception(response); + apiResponse = GenericApiModel( + messageStatus: messageStatus, + statusCode: statusCode, + errorMessage: errorMessage, + data: null, + ); + return; } final model = SelectDeviceByImeiRespModelElement.fromJson(list[0] as Map); @@ -337,4 +349,45 @@ class AuthenticationRepoImp implements AuthenticationRepo { return Left(UnknownFailure(e.toString())); } } + + @override + Future> insertPatientIMEIData({required patientIMEIDataRequest}) { + try { + GenericApiModel? 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( + 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> insertPatientDeviceData({required patientDeviceDataRequest}) { + + // TODO: implement insertPatientDeviceData + + throw UnimplementedError(); + } } diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index 6a2ea74..4866f61 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -26,6 +26,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; @@ -59,6 +62,7 @@ class AuthenticationViewModel extends ChangeNotifier { NationalityCountries? pickedCountryByUAEUser; CalenderEnum calenderType = CalenderEnum.gregorian; + LoginTypeEnum loginTypeEnum = LoginTypeEnum.sms; //================== @@ -239,6 +243,8 @@ class AuthenticationViewModel extends ChangeNotifier { Future 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 + loginTypeEnum = otpTypeEnum == OTPTypeEnum.sms ? LoginTypeEnum.sms : LoginTypeEnum.whatsapp; + if (phoneNumberController.text.isEmpty) { phoneNumberController.text = "504278212"; } @@ -500,12 +506,13 @@ class AuthenticationViewModel extends ChangeNotifier { await _dialogService.showErrorBottomSheet(message: message ?? "Something went wrong. ", onOkPressed: () {}); } - loginWithFingerPrintFace(int selectedOption) async { + loginWithFingerPrintFace() async { _localAuthService.authenticate().then((value) { if (value) { // we have to handle this if verification true; - checkActivationCode(otpTypeEnum: OTPTypeEnum.faceIDFingerprint, activationCode: 0000, onWrongActivationCode: (String? message) {}); + // checkActivationCode(otpTypeEnum: OTPTypeEnum.faceIDFingerprint, activationCode: 0000, onWrongActivationCode: (String? message) {}); // authenticated = true; + insertPatientIMEIData( OTPTypeEnum.faceIDFingerprint.toInt()); notifyListeners(); // navigateToHomeScreen(); } else { @@ -518,12 +525,22 @@ class AuthenticationViewModel extends ChangeNotifier { } 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 onRegisterPress({required OTPTypeEnum otpTypeEnum}) async { @@ -661,6 +678,32 @@ class AuthenticationViewModel extends ChangeNotifier { // }); } + Future 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()); + resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async { + if (apiResponse.messageStatus == 1) { + print("Insert IMEI Success"); + insertPatientDeviceData( loginType); + } else { + print("Insert IMEI Failed"); + } + }); + + } + Future 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()); + resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async { + if (apiResponse.messageStatus == 1) { + print("Insert Device Data Success"); + } else { + print("Insert IMEI Failed"); + } + }); + + } + @override void dispose() { nationalIdController.dispose(); diff --git a/lib/features/authentication/models/request_models/insert_patient_mobile_deviceinfo.dart b/lib/features/authentication/models/request_models/insert_patient_mobile_deviceinfo.dart new file mode 100644 index 0000000..dbfb0e1 --- /dev/null +++ b/lib/features/authentication/models/request_models/insert_patient_mobile_deviceinfo.dart @@ -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 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 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, + }; +} diff --git a/lib/features/authentication/models/request_models/patient_insert_device_imei_request.dart b/lib/features/authentication/models/request_models/patient_insert_device_imei_request.dart new file mode 100644 index 0000000..f54bb83 --- /dev/null +++ b/lib/features/authentication/models/request_models/patient_insert_device_imei_request.dart @@ -0,0 +1,125 @@ +import 'dart:convert'; + +class PatientInsertDeviceImei { + String? setupId; + int? patientType; + int? patientId; + String? firstName; + String? firstNameN; + String? lastNameN; + String? lastName; + 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; + + PatientInsertDeviceImei({ + this.setupId, + this.patientType, + this.patientId, + this.firstName, + this.firstNameN, + this.lastNameN, + this.lastName, + 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, + }); + + factory PatientInsertDeviceImei.fromRawJson(String str) => PatientInsertDeviceImei.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory PatientInsertDeviceImei.fromJson(Map json) => PatientInsertDeviceImei( + setupId: json["SetupID"], + patientType: json["PatientType"], + patientId: json["PatientID"], + firstName: json["FirstName"], + firstNameN: json["FirstNameN"], + lastNameN: json["LastNameN"], + lastName: json["LastName"], + 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"], + ); + + Map toJson() => { + "SetupID": setupId, + "PatientType": patientType, + "PatientID": patientId, + "FirstName": firstName, + "FirstNameN": firstNameN, + "LastNameN": lastNameN, + "LastName": lastName, + "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, + }; +} diff --git a/lib/presentation/authentication/login.dart b/lib/presentation/authentication/login.dart index f6e725a..0b463cc 100644 --- a/lib/presentation/authentication/login.dart +++ b/lib/presentation/authentication/login.dart @@ -203,6 +203,7 @@ class LoginScreenState extends State { borderColor: AppColors.borderOnlyColor, textColor: AppColors.textColor, icon: AppAssets.whatsapp, + iconColor: null, ), ), ], diff --git a/lib/presentation/authentication/saved_login_screen.dart b/lib/presentation/authentication/saved_login_screen.dart index 357daa6..3285163 100644 --- a/lib/presentation/authentication/saved_login_screen.dart +++ b/lib/presentation/authentication/saved_login_screen.dart @@ -81,7 +81,7 @@ class _SavedLogin extends State { ("${LocaleKeys.lastloginBy.tr()} ${LoginTypeExtension.fromValue(appState.getSelectDeviceByImeiRespModelElement!.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), @@ -95,7 +95,7 @@ class _SavedLogin extends State { 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 +108,7 @@ class _SavedLogin extends State { fontWeight: FontWeight.w500, borderRadius: 12, padding: EdgeInsets.fromLTRB(0, 10, 0, 10), - icon: AppAssets.apple_finder, + icon: AppAssets.sms, ), ), ], @@ -165,7 +165,7 @@ class _SavedLogin extends State { backgroundColor: AppColors.primaryRedColor, borderColor: AppColors.primaryRedBorderColor, textColor: AppColors.whiteColor, - icon: AppAssets.message, + icon: AppAssets.sms, ), ), Row( @@ -213,9 +213,11 @@ class _SavedLogin extends State { ) : 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; @@ -227,7 +229,7 @@ class _SavedLogin extends State { textColor: Color(0xFF2E3039), borderWidth: 2, padding: EdgeInsets.fromLTRB(0, 14, 0, 14), - icon: AppAssets.whatsapp, + ), const Spacer(flex: 2), // OR divider diff --git a/lib/presentation/home/landing_page.dart b/lib/presentation/home/landing_page.dart index b33658f..e569edb 100644 --- a/lib/presentation/home/landing_page.dart +++ b/lib/presentation/home/landing_page.dart @@ -41,7 +41,7 @@ class _LandingPageState extends State { authVM = context.read(); if (mounted) { authVM.checkLastLoginStatus(() { - // showQuickLogin(context, false); + showQuickLogin(context, false); }); } super.initState(); @@ -328,7 +328,7 @@ class _LandingPageState extends State { isDone: isDone, onPressed: () { // sharedPref.setBool(HAS_ENABLED_QUICK_LOGIN, true); - // loginWithFingerPrintFace(3, 1, user, deviceToken); + authVM.loginWithFingerPrintFace(); }, ), height: 400, diff --git a/lib/services/localauth_service.dart b/lib/services/localauth_service.dart index a01d1c1..2875a7f 100644 --- a/lib/services/localauth_service.dart +++ b/lib/services/localauth_service.dart @@ -6,22 +6,31 @@ class LocalAuthService { final LocalAuthentication localAuth; final LoggerService loggerService; LocalAuthService({required this.localAuth, required this.loggerService}); - Future 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 canCheckBiometrics() async { try { return await localAuth.canCheckBiometrics; diff --git a/lib/widgets/buttons/custom_button.dart b/lib/widgets/buttons/custom_button.dart index 5413cea..e1448dc 100644 --- a/lib/widgets/buttons/custom_button.dart +++ b/lib/widgets/buttons/custom_button.dart @@ -18,7 +18,7 @@ class CustomButton extends StatelessWidget { final String? fontFamily; final FontWeight fontWeight; final bool isDisabled; - final Color iconColor; + final Color? iconColor; final double height; final double iconSize; From ffb399c704ac155e152153fbda204e99aa573d88 Mon Sep 17 00:00:00 2001 From: aamir-csol Date: Tue, 9 Sep 2025 15:22:32 +0300 Subject: [PATCH 3/4] fixes for signup --- .../authentication_view_model.dart | 18 ++++++++++++++++-- lib/presentation/authentication/register.dart | 4 ++-- .../authentication/register_step2.dart | 14 +++----------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index e3c8520..07c8980 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -50,7 +50,7 @@ class AuthenticationViewModel extends ChangeNotifier { _authenticationRepo = authenticationRepo, _localAuthService = localAuthService; - final TextEditingController nationalIdController = TextEditingController(), phoneNumberController = TextEditingController(), dobController = TextEditingController(), nameController = TextEditingController(); + final TextEditingController nationalIdController = TextEditingController(), phoneNumberController = TextEditingController(), dobController = TextEditingController(), nameController = TextEditingController(), emailController = TextEditingController(); CountryEnum selectedCountrySignup = CountryEnum.saudiArabia; MaritalStatusTypeEnum? maritalStatus; GenderTypeEnum? genderType; @@ -524,7 +524,7 @@ class AuthenticationViewModel extends ChangeNotifier { } } - Future onRegisterPress({required OTPTypeEnum otpTypeEnum}) async { + Future onRegistrationStart({required OTPTypeEnum otpTypeEnum}) async { bool isOutSidePatient = selectedCountrySignup.countryCode == CountryEnum.unitedArabEmirates.countryCode ? true : false; final request = await RequestUtils.getPatientAuthenticationRequest( @@ -555,6 +555,20 @@ class AuthenticationViewModel extends ChangeNotifier { }); } + + Future onRegistrationComplete() async{ + + // if (emailAddress.text.isEmpty) { + // Utils.showErrorToast(TranslationBase.of(context).enterEmailAddress); + // return; + // } else { + // Navigator.of(context).pop(); + // registerNow(); + // } + //authVM!.clearDefaultInputValues(); + } + + Future checkUserStatusForRegistration({required dynamic response, required dynamic request}) async { if (response is Map) { _appState.setAppAuthToken = response["LogInTokenID"]; diff --git a/lib/presentation/authentication/register.dart b/lib/presentation/authentication/register.dart index 00f4808..f238582 100644 --- a/lib/presentation/authentication/register.dart +++ b/lib/presentation/authentication/register.dart @@ -222,7 +222,7 @@ class _RegisterNew extends State { 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 { 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, diff --git a/lib/presentation/authentication/register_step2.dart b/lib/presentation/authentication/register_step2.dart index 92faaee..bd23be1 100644 --- a/lib/presentation/authentication/register_step2.dart +++ b/lib/presentation/authentication/register_step2.dart @@ -37,7 +37,6 @@ class _RegisterNew extends State { @override void dispose() { super.dispose(); - // authVM!.clearDefaultInputValues(); } @override @@ -67,8 +66,7 @@ class _RegisterNew extends State { children: [ TextInputWidget( labelText: authVM!.isUserFromUAE() ? LocaleKeys.fullName.tr() : LocaleKeys.name.tr(), - hintText: - authVM!.isUserFromUAE() ? "" : ("${appState.getNHICUserData.firstNameEn!.toUpperCase()} ${appState.getNHICUserData.lastNameEn!.toUpperCase()}"), + hintText: authVM!.isUserFromUAE() ? "" : ("${appState.getNHICUserData.firstNameEn!.toUpperCase()} ${appState.getNHICUserData.lastNameEn!.toUpperCase()}"), controller: authVM!.isUserFromUAE() ? authVM!.nameController : null, isEnable: true, prefix: null, @@ -319,7 +317,7 @@ class _RegisterNew extends State { padding: EdgeInsets.only(bottom: MediaQuery.of(bottomSheetContext).viewInsets.bottom), child: SingleChildScrollView( child: GenericBottomSheet( - textController: TextEditingController(), + textController: authVM!.emailController, isForEmail: true, buttons: [ Padding( @@ -327,13 +325,7 @@ class _RegisterNew extends State { 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, From 2a081e30b5e2a7e4d17f99eb1e56fe0ae0f4eacb Mon Sep 17 00:00:00 2001 From: Sultan khan Date: Tue, 9 Sep 2025 18:50:40 +0300 Subject: [PATCH 4/4] saved login done. --- lib/core/api_consts.dart | 2 +- lib/core/app_state.dart | 2 +- lib/core/utils/request_utils.dart | 3 +- .../authentication/authentication_repo.dart | 33 +++++++++++++-- .../authentication_view_model.dart | 40 +++++++++++-------- .../patient_insert_device_imei_request.dart | 13 +++--- .../authentication/quick_login.dart | 6 ++- .../authentication/saved_login_screen.dart | 6 ++- lib/presentation/home/landing_page.dart | 11 +++-- lib/widgets/common_bottom_sheet.dart | 2 +- 10 files changed, 83 insertions(+), 35 deletions(-) diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart index a034570..f5c19e0 100644 --- a/lib/core/api_consts.dart +++ b/lib/core/api_consts.dart @@ -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 diff --git a/lib/core/app_state.dart b/lib/core/app_state.dart index 4408844..4ab98f6 100644 --- a/lib/core/app_state.dart +++ b/lib/core/app_state.dart @@ -109,7 +109,7 @@ class AppState { RegistrationDataModelPayload? _userRegistrationPayload; - RegistrationDataModelPayload get getUserRegistrationPayload => _userRegistrationPayload!; + RegistrationDataModelPayload get getUserRegistrationPayload => _userRegistrationPayload ?? RegistrationDataModelPayload(); set setUserRegistrationPayload(RegistrationDataModelPayload value) { _userRegistrationPayload = value; diff --git a/lib/core/utils/request_utils.dart b/lib/core/utils/request_utils.dart index 1045d9c..1bf1e06 100644 --- a/lib/core/utils/request_utils.dart +++ b/lib/core/utils/request_utils.dart @@ -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 ?? ""; diff --git a/lib/features/authentication/authentication_repo.dart b/lib/features/authentication/authentication_repo.dart index 222ac7c..989c667 100644 --- a/lib/features/authentication/authentication_repo.dart +++ b/lib/features/authentication/authentication_repo.dart @@ -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> insertPatientDeviceData({required patientDeviceDataRequest}) { - // TODO: implement insertPatientDeviceData - - throw UnimplementedError(); + try { + GenericApiModel? 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( + 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()))); + } } } diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index 097079a..eeccfc8 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -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 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 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 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"); } }); diff --git a/lib/features/authentication/models/request_models/patient_insert_device_imei_request.dart b/lib/features/authentication/models/request_models/patient_insert_device_imei_request.dart index f54bb83..0b2a99f 100644 --- a/lib/features/authentication/models/request_models/patient_insert_device_imei_request.dart +++ b/lib/features/authentication/models/request_models/patient_insert_device_imei_request.dart @@ -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 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, }; } diff --git a/lib/presentation/authentication/quick_login.dart b/lib/presentation/authentication/quick_login.dart index 9cf0431..c5f540b 100644 --- a/lib/presentation/authentication/quick_login.dart +++ b/lib/presentation/authentication/quick_login.dart @@ -19,6 +19,7 @@ class QuickLogin extends StatefulWidget { } class _QuickLogin extends State { + @override Widget build(BuildContext context) { return Container( @@ -70,7 +71,7 @@ class _QuickLogin extends State { 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 { text:LocaleKeys.enableQuickLogin.tr(), onPressed: () { widget.onPressed(); + setState(() { + + }); }, backgroundColor: Color(0xffED1C2B), borderColor: Color(0xffED1C2B), diff --git a/lib/presentation/authentication/saved_login_screen.dart b/lib/presentation/authentication/saved_login_screen.dart index bf97987..55cbadf 100644 --- a/lib/presentation/authentication/saved_login_screen.dart +++ b/lib/presentation/authentication/saved_login_screen.dart @@ -34,6 +34,8 @@ class _SavedLogin extends State { void initState() { authVm = context.read(); appState = getIt.get(); + 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 { 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 { 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, diff --git a/lib/presentation/home/landing_page.dart b/lib/presentation/home/landing_page.dart index a9ced9c..b55632b 100644 --- a/lib/presentation/home/landing_page.dart +++ b/lib/presentation/home/landing_page.dart @@ -326,15 +326,20 @@ class _LandingPageState extends State { 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(() { + + }); + }, ); } } diff --git a/lib/widgets/common_bottom_sheet.dart b/lib/widgets/common_bottom_sheet.dart index 11b7df8..583eab6 100644 --- a/lib/widgets/common_bottom_sheet.dart +++ b/lib/widgets/common_bottom_sheet.dart @@ -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,