diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index d80c668e..c06dd473 100644 --- a/lib/pages/login/confirm-login.dart +++ b/lib/pages/login/confirm-login.dart @@ -361,7 +361,6 @@ class _ConfirmLogin extends State { this.getMobileInfo(request); } } - var asd = ""; } getMobileInfo(request) { @@ -408,7 +407,6 @@ class _ConfirmLogin extends State { print(err); }).showProgressBar( text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)); - ; } setUser() async {} diff --git a/lib/pages/login/forgot-password.dart b/lib/pages/login/forgot-password.dart index 7e2f19fa..3bdf5358 100644 --- a/lib/pages/login/forgot-password.dart +++ b/lib/pages/login/forgot-password.dart @@ -1,4 +1,7 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/mobile-no/mobile_no.dart'; @@ -15,7 +18,7 @@ class ForgotPassword extends StatefulWidget { class _ForgotPassword extends State { String selectedType = 'Saudi Arabia'; final TextEditingController nationalIDorFile = null; - final TextEditingController mobileNo = null; + final TextEditingController mobileNo = TextEditingController(); @override Widget build(BuildContext context) { @@ -84,7 +87,10 @@ class _ForgotPassword extends State { Expanded( child: DefaultButton( TranslationBase.of(context).submit, - () => {}, + () { + sendPatientIDBySMS(); +// print(mobileNo.text); + }, )), ], ), @@ -93,4 +99,21 @@ class _ForgotPassword extends State { ]), ))); } + + sendPatientIDBySMS() { + GifLoaderDialogUtils.showMyDialog(context); + final authService = new AuthProvider(); + authService.sendPatientIDSMS(mobileNo.text, context).then((res) { + GifLoaderDialogUtils.hideDialog(context); + if (res['MessageStatus'] == 1) { + setState(() {}); + } else { + AppToast.showErrorToast(message: res['ErrorEndUserMessage']); + } + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + AppToast.showErrorToast(message: err); + print(err); + }); + } } diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index eb189e96..ed769b81 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -11,6 +11,8 @@ import 'package:diplomaticquarterapp/pages/rateAppointment/rate_appointment_doct import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; @@ -18,12 +20,10 @@ import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/input/text_field.dart'; import 'package:diplomaticquarterapp/widgets/mobile-no/mobile_no.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:smart_progress_bar/smart_progress_bar.dart'; class Login extends StatefulWidget { @override @@ -154,6 +154,7 @@ class _Login extends State { checkUserAuthentication() { // showLoader(true); + GifLoaderDialogUtils.showMyDialog(context); var request = CheckPatientAuthenticationReq(); request.isRegister = false; request.patientMobileNumber = int.parse(mobileNo); @@ -172,7 +173,7 @@ class _Login extends State { authService .checkPatientAuthentication(request) .then((value) => { - //showLoader(false), + //showLoader(false),GifLoaderDialogUtils.hideDialog(context), if (value['isSMSSent']) { sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']), @@ -184,12 +185,16 @@ class _Login extends State { { if (value['IsAuthenticated']) {this.checkActivationCode()} } - }) + }) + .catchError((err) { + GifLoaderDialogUtils.hideDialog(context); print(err); GifLoaderDialogUtils.hideDialog(context); }); // SMSOTP.showLoadingDialog(context, false), + AppToast.showErrorToast(message: err); + }); } checkActivationCode({code}) async { @@ -249,9 +254,9 @@ class _Login extends State { }); } -// showLoader(bool isTrue) { -// setState(() { -// isLoading = isTrue; -// }); -// } + // showLoader(bool isTrue) { + // setState(() { + // isLoading = isTrue; + // }); + // } } diff --git a/lib/pages/login/register-info.dart b/lib/pages/login/register-info.dart index e94c1af6..542b0c95 100644 --- a/lib/pages/login/register-info.dart +++ b/lib/pages/login/register-info.dart @@ -1,17 +1,11 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/models/Authentication/register_info_response.dart'; -import 'package:diplomaticquarterapp/pages/login/login-type.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; -import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/uitl/utils.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; -import 'package:diplomaticquarterapp/widgets/card/rounded_container.dart'; import 'package:diplomaticquarterapp/widgets/input/text_field.dart'; -import 'package:diplomaticquarterapp/widgets/mobile-no/mobile_no.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:flutter/cupertino.dart'; @@ -28,9 +22,12 @@ class _RegisterInfo extends State { RegisterInfoResponse registerInfo; bool isLoading; int page = 1; + @override void initState() { - getRegisterInfo(); + WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + getRegisterInfo(); + }); super.initState(); } @@ -146,10 +143,15 @@ class _RegisterInfo extends State { } registerNow() {} + getRegisterInfo() async { + RegisterInfoResponse registerInfo; registerInfo = RegisterInfoResponse.fromJson(await sharedPref.getObject(NHIC_DATA)); + setState(() { + this.registerInfo = registerInfo; + }); - print(await sharedPref.getObject(NHIC_DATA)); + print(this.registerInfo); } } diff --git a/lib/pages/medical/medical_profile_page.dart b/lib/pages/medical/medical_profile_page.dart index d5df2215..5a41a18a 100644 --- a/lib/pages/medical/medical_profile_page.dart +++ b/lib/pages/medical/medical_profile_page.dart @@ -1,43 +1,29 @@ -import 'dart:math'; - import 'package:badges/badges.dart'; -import 'package:diplomaticquarterapp/core/service/medical/vital_sign_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/medical_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/pages/MyAppointments/MyAppointments.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/insurance/insurance_approval_screen.dart'; +import 'package:diplomaticquarterapp/pages/insurance/insurance_card_screen.dart'; import 'package:diplomaticquarterapp/pages/medical/patient_sick_leave_page.dart'; -import 'package:diplomaticquarterapp/pages/medical/reports/monthly_reports.dart'; -import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/smart_watch_instructions.dart'; -import 'package:diplomaticquarterapp/pages/vaccine/my_vaccines_screen.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; import 'package:diplomaticquarterapp/pages/medical/radiology/radiology_home_page.dart'; -import 'package:diplomaticquarterapp/pages/medical/vital_sign/vital_sign_details_screen.dart'; import 'package:diplomaticquarterapp/pages/medical/reports/report_home_page.dart'; +import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/medical_profile_item.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/time_line_widget.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:diplomaticquarterapp/widgets/others/sliver_app_bar_delegate.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:diplomaticquarterapp/pages/insurance/insurance_card_screen.dart'; import 'package:provider/provider.dart'; -import '../../locator.dart'; -import 'active_medications/ActiveMedicationsPage.dart'; + import 'allergies_page.dart'; -import 'ask_doctor/ask_doctor_home_page.dart'; -import 'balance/my_balance_page.dart'; import 'doctor/doctor_home_page.dart'; -import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dart'; -import 'package:diplomaticquarterapp/pages/insurance/insurance_approval_screen.dart'; -import 'eye/EyeHomePage.dart'; -import 'eye/EyeMeasurementsPage.dart'; import 'labs/labs_home_page.dart'; -import 'my_trackers/my_trackers.dart'; class MedicalProfilePage extends StatefulWidget { @override @@ -45,6 +31,8 @@ class MedicalProfilePage extends StatefulWidget { } class _MedicalProfilePageState extends State { + var authProvider = new AuthProvider(); + @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); @@ -73,18 +61,19 @@ class _MedicalProfilePageState extends State { width: double.infinity, // color: Colors.black.withOpacity(0.0) ), - if(model.authenticatedUserObject.isLogin) - ListView.builder( - itemBuilder: (context, index) => TimeLineWidget( - isUp: index % 2 == 1, - appoitmentAllHistoryResul: model - .appoitmentAllHistoryResultList[index], + if (model.authenticatedUserObject.isLogin) + ListView.builder( + itemBuilder: (context, index) => + TimeLineWidget( + isUp: index % 2 == 1, + appoitmentAllHistoryResul: model + .appoitmentAllHistoryResultList[index], + ), + itemCount: model + .appoitmentAllHistoryResultList.length, + scrollDirection: Axis.horizontal, + reverse: !projectViewModel.isArabic, ), - itemCount: - model.appoitmentAllHistoryResultList.length, - scrollDirection: Axis.horizontal, - reverse: !projectViewModel.isArabic, - ), ], ), ), @@ -109,34 +98,53 @@ class _MedicalProfilePageState extends State { ), ); }, - child: Stack( - children: [ - MedicalProfileItem( - title: TranslationBase.of(context) - .myAppointments, - imagePath: 'my_appointment_icon.png', - subTitle: TranslationBase.of(context) - .myAppointmentsList, - hasBadge: true, - ), - Positioned( - right: 0.0, - child: Badge( - toAnimate: false, - position: BadgePosition.topEnd(), - shape: BadgeShape.circle, - badgeColor: Color(0xFF40ACC9).withOpacity(1.0), - borderRadius: BorderRadius.circular(8), - badgeContent: Container( - padding: EdgeInsets.all(2.0), - child: Text(appoCountProvider.count.toString(), - style: TextStyle( - color: Colors.white, fontSize: 16.0)), + child: authProvider.isLogin + ? Stack(children: [ + MedicalProfileItem( + title: + TranslationBase.of(context) + .myAppointments, + imagePath: + 'my_appointment_icon.png', + subTitle: + TranslationBase.of(context) + .myAppointmentsList, + hasBadge: true, ), + Positioned( + right: 0.0, + child: Badge( + toAnimate: false, + position: + BadgePosition.topEnd(), + shape: BadgeShape.circle, + badgeColor: Color(0xFF40ACC9) + .withOpacity(1.0), + borderRadius: + BorderRadius.circular(8), + badgeContent: Container( + padding: + EdgeInsets.all(2.0), + child: Text( + appoCountProvider.count + .toString(), + style: TextStyle( + color: Colors.white, + fontSize: 16.0)), + ), + ), + ), + ]) + : MedicalProfileItem( + title: TranslationBase.of(context) + .myAppointments, + imagePath: + 'my_appointment_icon.png', + subTitle: + TranslationBase.of(context) + .myAppointmentsList, + hasBadge: true, ), - ), - ] - ), ), ), Expanded( @@ -233,9 +241,11 @@ class _MedicalProfilePageState extends State { Expanded( flex: 1, child: InkWell( - onTap:()=> Navigator.push(context, FadePage(page: AllergiesPage())) , + onTap: () => Navigator.push(context, + FadePage(page: AllergiesPage())), child: MedicalProfileItem( - title: TranslationBase.of(context).allergies, + title: TranslationBase.of(context) + .allergies, imagePath: 'my_allergies_icon.png', subTitle: TranslationBase.of(context) .allergiesSubtitle, @@ -263,13 +273,16 @@ class _MedicalProfilePageState extends State { flex: 1, child: InkWell( onTap: () { - Navigator.push(context, - FadePage(page: InsuranceApproval())); + Navigator.push( + context, + FadePage( + page: InsuranceApproval())); }, child: MedicalProfileItem( title: TranslationBase.of(context) .insuranceApproval, - imagePath: 'insurance_approvals_icon.png', + imagePath: + 'insurance_approvals_icon.png', subTitle: TranslationBase.of(context) .insuranceApprovalSubtitle, ), @@ -287,18 +300,24 @@ class _MedicalProfilePageState extends State { }, child: MedicalProfileItem( title: - TranslationBase.of(context).medical, + TranslationBase.of(context).medical, imagePath: 'medical_reports_icon.png', subTitle: TranslationBase.of(context) .medicalSubtitle, ), ), ), - Expanded(child: Container(),), - Expanded(child: Container(),), + Expanded( + child: Container(), + ), + Expanded( + child: Container(), + ), ]), - - SizedBox(height: MediaQuery.of(context).size.height * 0.12,) + SizedBox( + height: + MediaQuery.of(context).size.height * 0.12, + ) ], ), ) @@ -337,7 +356,6 @@ class _MedicalProfilePageState extends State { color: Colors.white, bold: true, ), - Texts( '${model.user.patientID}', color: Colors.white, diff --git a/lib/services/authentication/auth_provider.dart b/lib/services/authentication/auth_provider.dart index 28b5e73b..2142bc53 100644 --- a/lib/services/authentication/auth_provider.dart +++ b/lib/services/authentication/auth_provider.dart @@ -1,17 +1,18 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; -import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_request.dart'; +import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; +import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_request.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_user_status_req.dart'; import 'package:diplomaticquarterapp/models/Authentication/checkpatient_for_registration.dart'; import 'package:diplomaticquarterapp/models/Authentication/insert_device_imei_request.dart'; import 'package:diplomaticquarterapp/models/Authentication/register_user_requet.dart'; -import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart'; import 'package:diplomaticquarterapp/models/Authentication/registered_authenticated_user_req.dart'; -import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart'; +import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart'; +import 'package:diplomaticquarterapp/models/Request.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:flutter/cupertino.dart'; @@ -19,7 +20,9 @@ import '../../locator.dart'; // SharedPreferences sharedPref = new SharedPreferences(); enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED } + AppSharedPreferences sharedPref = new AppSharedPreferences(); +AppGlobal appGlobal = new AppGlobal(); const String INSERT_DEVICE_IMEI = 'Services/Patients.svc/REST/Patient_INSERTDeviceIMEI'; @@ -40,11 +43,15 @@ const REGISTER_USER = 'Services/Authentication.svc/REST/PatientRegistration'; const LOGGED_IN_USER_URL = 'Services/MobileNotifications.svc/REST/Insert_PatientMobileDeviceInfo'; +const FORGOT_PATIENT_ID = + 'Services/Authentication.svc/REST/SendPatientIDSMSByMobileNumber'; + class AuthProvider with ChangeNotifier { bool isLogin = false; bool isLoading = true; dynamic authenticatedUser; - AuthenticatedUserObject authenticatedUserObject = locator(); + AuthenticatedUserObject authenticatedUserObject = + locator(); AuthProvider() { getUserAuthentication(); @@ -355,4 +362,36 @@ class AuthProvider with ChangeNotifier { throw error; } } + + Future sendPatientIDSMS(mobileNo, context) async { + Map request; + var languageID = await sharedPref.getString(APP_LANGUAGE); + Request req = appGlobal.getPublicRequest(); + request = { + "LanguageID": languageID == 'ar' ? 1 : 2, + "IPAdress": "10.20.10.20", + "VersionID": req.VersionID, + "Channel": req.Channel, + "generalid": 'Cs2020@2016\$2958', + "PatientOutSA": 0, + "PatientID": 0, + "TokenID": "", + "PatientMobileNumber": mobileNo, + "SearchType": 2, + "ZipCode": "966", + "PatientIdentificationID": "", + "DeviceTypeID": req.DeviceTypeID, + "SessionID": null + }; + + dynamic localRes; + + await new BaseAppClient().post(FORGOT_PATIENT_ID, + onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); + } } diff --git a/lib/widgets/bottom_navigation/bottom_navigation_item.dart b/lib/widgets/bottom_navigation/bottom_navigation_item.dart index 6bc8560a..f491917c 100644 --- a/lib/widgets/bottom_navigation/bottom_navigation_item.dart +++ b/lib/widgets/bottom_navigation/bottom_navigation_item.dart @@ -1,5 +1,6 @@ import 'package:badges/badges.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; +import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -13,6 +14,8 @@ class BottomNavigationItem extends StatelessWidget { final int currentIndex; final String name; + var authProvider = new AuthProvider(); + BottomNavigationItem( {this.icon, this.activeIcon, @@ -61,27 +64,58 @@ class BottomNavigationItem extends StatelessWidget { ), ], ) - : Stack( - alignment: AlignmentDirectional.center, - children: [ - Positioned( - right: 18.0, - bottom: 28.0, - child: Badge( - toAnimate: false, - position: BadgePosition.topEnd(), - shape: BadgeShape.circle, - badgeColor: Color(0xFF40ACC9).withOpacity(1.0), - borderRadius: BorderRadius.circular(8), - badgeContent: Container( - padding: EdgeInsets.all(2.0), - child: Text(model.count.toString(), - style: TextStyle( - color: Colors.white, fontSize: 14.0)), + : authProvider.isLogin + ? Stack( + alignment: AlignmentDirectional.center, + children: [ + Positioned( + right: 18.0, + bottom: 28.0, + child: Badge( + toAnimate: false, + position: BadgePosition.topEnd(), + shape: BadgeShape.circle, + badgeColor: Color(0xFF40ACC9).withOpacity(1.0), + borderRadius: BorderRadius.circular(8), + badgeContent: Container( + padding: EdgeInsets.all(2.0), + child: Text(model.count.toString(), + style: TextStyle( + color: Colors.white, fontSize: 14.0)), + ), + ), ), - ), - ), - Column( + Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + height: 15, + ), + Container( + child: Icon( + currentIndex == index ? activeIcon : icon, + color: currentIndex == index + ? Theme.of(context).primaryColor + : Theme.of(context).dividerColor, + size: 22.0), + ), + SizedBox( + height: 5, + ), + Texts( + name, + textAlign: TextAlign.center, + color: currentIndex == index + ? Theme.of(context).primaryColor + : Theme.of(context).dividerColor, + fontSize: 11, + ), + ], + ), + ], + ) + : Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -109,8 +143,6 @@ class BottomNavigationItem extends StatelessWidget { ), ], ), - ], - ), ), ), ),