From d0ed776ff646b055e611c42012e46a5699cf18d7 Mon Sep 17 00:00:00 2001 From: Mohammad Aljmma Date: Mon, 26 Oct 2020 10:50:59 +0300 Subject: [PATCH] new home health service --- lib/config/config.dart | 2 +- lib/core/enum/OrderService.dart | 15 +- ...nt_er_insert_pres_order_request_model.dart | 3 +- .../AlHabibMedicalService/cmc_service.dart | 13 + .../home_health_care_service.dart | 15 +- .../AlHabibMedicalService/cmc_view_model.dart | 26 +- .../home_health_care_view_model.dart | 18 +- .../NewCMC/new_cmc_page.dart | 406 ++++++++++-------- .../NewCMC/new_cmc_step_one_page.dart | 332 +++++++------- .../NewCMC/new_cmc_step_three_page.dart | 165 +++++++ .../NewCMC/new_cmc_step_tow_page.dart | 113 +++++ .../new_Home_health_care_step_one_page.dart | 232 +++++----- .../new_Home_health_care_step_three_page.dart | 172 ++++++++ .../new_Home_health_care_step_tow_page.dart | 112 +++++ .../new_home_health_care_page.dart | 30 +- .../HomeHealthCare/StepsWidget.dart | 2 +- .../PickupLocation.dart | 2 - lib/pages/landing/landing_page.dart | 36 +- .../pickupLocation/PickupLocationFromMap.dart | 3 +- pubspec.yaml | 2 + 20 files changed, 1214 insertions(+), 485 deletions(-) create mode 100644 lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_three_page.dart create mode 100644 lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart create mode 100644 lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_three_page.dart create mode 100644 lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_tow_page.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 40ffc502..f53d5a75 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -6,7 +6,7 @@ import 'package:diplomaticquarterapp/widgets/mobile-no/mobile_no.dart'; const MAX_SMALL_SCREEN = 660; -const BASE_URL = 'https://uat.hmgwebservices.com/'; +const BASE_URL = 'https://hmgwebservices.com/'; const GET_PROJECT = 'Services/Lists.svc/REST/GetProject'; diff --git a/lib/core/enum/OrderService.dart b/lib/core/enum/OrderService.dart index e6ce24eb..833e0919 100644 --- a/lib/core/enum/OrderService.dart +++ b/lib/core/enum/OrderService.dart @@ -1,4 +1,4 @@ -enum OrderService { AMBULANCE } +enum OrderService { AMBULANCE,HOME_HEALTH_CARE,Comprehensive_Medical_Checkup } extension SelectedOrderService on OrderService { int getIdOrderService() { @@ -6,6 +6,13 @@ extension SelectedOrderService on OrderService { case OrderService.AMBULANCE: return 4; break; + case OrderService.Comprehensive_Medical_Checkup: + return 3; + break; + case OrderService.HOME_HEALTH_CARE: + return 2; + break; + } return 4; } @@ -15,6 +22,12 @@ extension SelectedOrderService on OrderService { case 4: return OrderService.AMBULANCE; break; + case 2: + return OrderService.HOME_HEALTH_CARE; + break; + case 3: + return OrderService.Comprehensive_Medical_Checkup; + break; } return OrderService.AMBULANCE; diff --git a/lib/core/model/AlHabibMedicalService/HomeHealthCare/patient_er_insert_pres_order_request_model.dart b/lib/core/model/AlHabibMedicalService/HomeHealthCare/patient_er_insert_pres_order_request_model.dart index 198ae285..6987ee44 100644 --- a/lib/core/model/AlHabibMedicalService/HomeHealthCare/patient_er_insert_pres_order_request_model.dart +++ b/lib/core/model/AlHabibMedicalService/HomeHealthCare/patient_er_insert_pres_order_request_model.dart @@ -18,7 +18,7 @@ class PatientERInsertPresOrderRequestModel { double longitude; int createdBy; int orderServiceID; - List patientERHHCInsertServicesList =List(); + List patientERHHCInsertServicesList = List(); PatientERInsertPresOrderRequestModel( {this.versionID, @@ -38,6 +38,7 @@ class PatientERInsertPresOrderRequestModel { this.longitude, this.createdBy, this.orderServiceID, + this.patientERHHCInsertServicesList }); PatientERInsertPresOrderRequestModel.fromJson(Map json) { diff --git a/lib/core/service/AlHabibMedicalService/cmc_service.dart b/lib/core/service/AlHabibMedicalService/cmc_service.dart index b87f54fb..dffa6683 100644 --- a/lib/core/service/AlHabibMedicalService/cmc_service.dart +++ b/lib/core/service/AlHabibMedicalService/cmc_service.dart @@ -1,6 +1,7 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_get_items_request_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_get_items_response_model.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_insert_pres_order_request_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/get_cmc_service_request_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/get_cmc_service_response_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_hHC_all_pres_orders_request_model.dart'; @@ -99,4 +100,16 @@ class CMCService extends BaseService { super.error = error; }, body: updatePresOrderRequestModel.toJson()); } + + Future insertPresPresOrder({CMCInsertPresOrderRequestModel order}) async { + + hasError = false; + await baseAppClient.post(PATIENT_ER_UPDATE_PRES_ORDER, + onSuccess: (dynamic response, int statusCode) { + isOrderUpdated = true; + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: order.toJson()); + } } diff --git a/lib/core/service/AlHabibMedicalService/home_health_care_service.dart b/lib/core/service/AlHabibMedicalService/home_health_care_service.dart index 45a871cd..e636321b 100644 --- a/lib/core/service/AlHabibMedicalService/home_health_care_service.dart +++ b/lib/core/service/AlHabibMedicalService/home_health_care_service.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealth import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_hhc_all_pres_orders_response_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_order_detail_by_order_iD_request_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_order_detail_by_order_iD_response_model.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/patient_er_insert_pres_order_request_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/update_pres_oreder_request_model.dart'; import '../base_service.dart'; @@ -68,8 +69,7 @@ class HomeHealthCareService extends BaseService { }, body: body); } - Future updateHHCPresOrder( - UpdatePresOrderRequestModel updatePresOrderRequestModel) async { + Future updateHHCPresOrder(UpdatePresOrderRequestModel updatePresOrderRequestModel) async { hasError = false; await baseAppClient.post(PATIENT_ER_UPDATE_PRES_ORDER, onSuccess: (dynamic response, int statusCode) { @@ -79,4 +79,15 @@ class HomeHealthCareService extends BaseService { super.error = error; }, body: updatePresOrderRequestModel.toJson()); } + + Future insertPresPresOrder({PatientERInsertPresOrderRequestModel order}) async { + hasError = false; + await baseAppClient.post(INSERT_ER_INERT_PRES_ORDER, + onSuccess: (dynamic response, int statusCode) { + + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: order.toJson()); + } } diff --git a/lib/core/viewModels/AlHabibMedicalService/cmc_view_model.dart b/lib/core/viewModels/AlHabibMedicalService/cmc_view_model.dart index b4c805b7..bf3404a9 100644 --- a/lib/core/viewModels/AlHabibMedicalService/cmc_view_model.dart +++ b/lib/core/viewModels/AlHabibMedicalService/cmc_view_model.dart @@ -1,6 +1,8 @@ +import 'package:diplomaticquarterapp/core/enum/OrderService.dart'; import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_get_items_request_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_get_items_response_model.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_insert_pres_order_request_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/get_cmc_service_response_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_hhc_all_pres_orders_response_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_order_detail_by_order_iD_request_model.dart'; @@ -34,7 +36,7 @@ class CMCViewModel extends BaseViewModel { .getCMCAllServices(); CMCGetItemsRequestModel cMCGetItemsRequestModel = new CMCGetItemsRequestModel(checkupType: cmcAllServicesList[0].iD); - await getCheckupItems(cMCGetItemsRequestModel); + await getCheckupItems(cMCGetItemsRequestModel: cMCGetItemsRequestModel,isFirst: true); if (_cMCService.hasError) { error = _cMCService.error; setState(ViewState.Error); @@ -42,13 +44,16 @@ class CMCViewModel extends BaseViewModel { setState(ViewState.Idle); } } - Future getCheckupItems(CMCGetItemsRequestModel cMCGetItemsRequestModel) async { - await _cMCService - .getCheckupItems(cMCGetItemsRequestModel); + Future getCheckupItems({CMCGetItemsRequestModel cMCGetItemsRequestModel, bool isFirst = false}) async { + if(!isFirst) + setState(ViewState.Busy); + await _cMCService.getCheckupItems(cMCGetItemsRequestModel); if (_cMCService.hasError) { error = _cMCService.error; setState(ViewState.Error); } + if(!isFirst) + setState(ViewState.Idle); } Future getCmcAllPresOrders() async { @@ -89,4 +94,17 @@ class CMCViewModel extends BaseViewModel { await _cMCService .getOrderDetailByOrderID(getOrderDetailByOrderIDRequestModel); } + //TODO check it in uat + Future insertPresPresOrder({CMCInsertPresOrderRequestModel order}) async { + setState(ViewState.Busy); + order.createdBy = user.patientID; + order.orderServiceID = OrderService.Comprehensive_Medical_Checkup.getIdOrderService(); + await _cMCService.insertPresPresOrder(order: order); + if (_cMCService.hasError) { + error = _cMCService.error; + setState(ViewState.ErrorLocal); + } else { + getCmcAllPresOrders(); + } + } } \ No newline at end of file diff --git a/lib/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart b/lib/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart index 8a4acd2b..031d0a0c 100644 --- a/lib/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart +++ b/lib/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/core/enum/OrderService.dart'; import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/HHC_get_all_services_request_modle.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/HHC_get_all_services_response_model.dart'; @@ -5,6 +6,7 @@ import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealth import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_hhc_all_pres_orders_response_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_order_detail_by_order_iD_request_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_order_detail_by_order_iD_response_model.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/patient_er_insert_pres_order_request_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/update_pres_oreder_request_model.dart'; import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/home_health_care_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; @@ -65,8 +67,7 @@ class HomeHealthCareViewModel extends BaseViewModel { } } - Future updateHHCPresOrder( - UpdatePresOrderRequestModel updatePresOrderRequestModel) async { + Future updateHHCPresOrder(UpdatePresOrderRequestModel updatePresOrderRequestModel) async { setState(ViewState.Busy); await _homeHealthCareService.updateHHCPresOrder( updatePresOrderRequestModel); @@ -78,6 +79,19 @@ class HomeHealthCareViewModel extends BaseViewModel { } } + Future insertPresPresOrder({PatientERInsertPresOrderRequestModel order}) async { + setState(ViewState.Busy); + order.createdBy = user.patientID; + order.orderServiceID = OrderService.HOME_HEALTH_CARE.getIdOrderService(); + await _homeHealthCareService.insertPresPresOrder(order: order); + if (_homeHealthCareService.hasError) { + error = _homeHealthCareService.error; + setState(ViewState.ErrorLocal); + } else { + getHHCAllPresOrders(); + } + } + } \ No newline at end of file diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_page.dart index 494b0920..532396cc 100644 --- a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_page.dart +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_page.dart @@ -4,14 +4,18 @@ import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealth import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/update_pres_oreder_request_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/Dialog/confirm_cancel_order_dialog.dart'; +import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/StepsWidget.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/material.dart'; +import 'package:geolocator/geolocator.dart'; import 'new_cmc_step_one_page.dart'; +import 'new_cmc_step_three_page.dart'; +import 'new_cmc_step_tow_page.dart'; class NewCMCPage extends StatefulWidget { NewCMCPage({this.model}); @@ -27,7 +31,9 @@ class _NewCMCPageState extends State with TickerProviderStateMixin { PageController _controller; int _currentIndex = 1; - int pageSelected = 2; + + double _latitude; + double _longitude; CMCInsertPresOrderRequestModel cMCInsertPresOrderRequestModel; @@ -54,6 +60,18 @@ class _NewCMCPageState extends State : []); _controller = new PageController(); + + _getCurrentLocation(); + } + + _getCurrentLocation() async { + await getLastKnownPosition().then((value) { + _latitude = value.latitude; + _longitude = value.longitude; + }).catchError((e) { + _longitude = 0; + _latitude = 0; + }); } @override @@ -94,216 +112,230 @@ class _NewCMCPageState extends State child: SingleChildScrollView( child: Container( height: MediaQuery.of(context).size.height * 0.8, - child: PageView( - physics: NeverScrollableScrollPhysics(), - controller: _controller, - onPageChanged: (index) { - setState(() { - _currentIndex = index; - }); - }, - scrollDirection: Axis.horizontal, - children: [ - widget.model.cmcAllOrderDetail.length != 0 - ? FractionallySizedBox( - heightFactor: 0.8, - widthFactor: 0.9, - child: Container( - width: double.infinity, - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - border: - Border.all(color: Colors.grey, width: 1), - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 12, - ), - Container( + child: Column( + children: [ + Container( + margin: EdgeInsets.only(left: MediaQuery.of(context).size.width*0.05, right: MediaQuery.of(context).size.width*0.05), + child: StepsWidget( + index: _currentIndex, + changeCurrentTab: changePageViewIndex, + ), + ), + Expanded( + child: PageView( + physics: NeverScrollableScrollPhysics(), + controller: _controller, + onPageChanged: (index) { + setState(() { + _currentIndex = index; + }); + }, + scrollDirection: Axis.horizontal, + children: [ + widget.model.cmcAllOrderDetail.length != 0 + ? FractionallySizedBox( + heightFactor: 0.8, + widthFactor: 0.9, + child: Container( width: double.infinity, - padding: EdgeInsets.only( - left: 15, bottom: 15, top: 15), + margin: EdgeInsets.only(top: 15), decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: Colors.grey, - width: 1.0, - ), - ), - // borderRadius: BorderRadius.circular(12), + border: + Border.all(color: Colors.grey, width: 1), + borderRadius: BorderRadius.circular(12), color: Colors.white), child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts( - "Request ID", - bold: false, - fontSize: 13, - ), SizedBox( - height: 4, - ), - Texts( - widget.model.cmcAllOrderDetail[0].iD.toString(), - fontSize: 22, + height: 12, ), - ], - ), - ), - Container( - width: double.infinity, - padding: EdgeInsets.only( - left: 15, bottom: 15, top: 15), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: Colors.grey, - width: 1.0, + Container( + width: double.infinity, + padding: EdgeInsets.only( + left: 15, bottom: 15, top: 15), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Colors.grey, + width: 1.0, + ), + ), + // borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Texts( + "Request ID", + bold: false, + fontSize: 13, + ), + SizedBox( + height: 4, + ), + Texts( + widget.model.cmcAllOrderDetail[0].iD.toString(), + fontSize: 22, + ), + ], ), ), - // borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Texts( - "Status", - bold: false, - fontSize: 13, - ), - SizedBox( - height: 4, - ), - Texts( - "Pending", - fontSize: 22, + Container( + width: double.infinity, + padding: EdgeInsets.only( + left: 15, bottom: 15, top: 15), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Colors.grey, + width: 1.0, + ), + ), + // borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Texts( + "Status", + bold: false, + fontSize: 13, + ), + SizedBox( + height: 4, + ), + Texts( + "Pending", + fontSize: 22, + ), + ], + ), ), - ], - ), - ), - Container( - width: double.infinity, - padding: EdgeInsets.only( - left: 15, bottom: 15, top: 15), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: Colors.grey, - width: 1.0, + Container( + width: double.infinity, + padding: EdgeInsets.only( + left: 15, bottom: 15, top: 15), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Colors.grey, + width: 1.0, + ), + ), + // borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Texts( + "Pickup Date", + bold: false, + fontSize: 13, + ), + SizedBox( + height: 4, + ), + Texts( + DateUtil.getDayMonthYearDateFormatted( + DateUtil.convertStringToDate( + widget.model.cmcAllOrderDetail[0] + .createdOn)), + fontSize: 22, + ), + ], ), ), - // borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Texts( - "Pickup Date", - bold: false, - fontSize: 13, + Container( + width: double.infinity, + padding: EdgeInsets.only( + left: 15, bottom: 15, top: 15), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Colors.grey, + width: 1.0, + ), + ), + // borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Texts( + "Service Name", + bold: false, + fontSize: 13, + ), + SizedBox( + height: 4, + ), + Texts( + widget.model.cmcAllOrderDetail[0].description + .toString() ?? + widget.model.cmcAllOrderDetail[0] + .descriptionN + .toString(), + fontSize: 22, + ), + ], + ), ), SizedBox( - height: 4, - ), - Texts( - DateUtil.getDayMonthYearDateFormatted( - DateUtil.convertStringToDate( - widget.model.cmcAllOrderDetail[0] - .createdOn)), - fontSize: 22, + height: 12, ), - ], - ), - ), - Container( - width: double.infinity, - padding: EdgeInsets.only( - left: 15, bottom: 15, top: 15), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: Colors.grey, - width: 1.0, + Center( + child: Container( + width: MediaQuery + .of(context) + .size + .width * + 0.85, + child: SecondaryButton( + label: "Cancel".toUpperCase(), + onTap: () { + showConfirmMessage(widget.model, + widget.model.cmcAllOrderDetail[0]); + } + , + color: Colors.red[800], + disabled: false, + textColor: Theme + .of(context) + .backgroundColor), ), ), - // borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Texts( - "Service Name", - bold: false, - fontSize: 13, - ), SizedBox( - height: 4, - ), - Texts( - widget.model.cmcAllOrderDetail[0].description - .toString() ?? - widget.model.cmcAllOrderDetail[0] - .descriptionN - .toString(), - fontSize: 22, + height: 12, ), ], ), ), - SizedBox( - height: 12, - ), - Center( - child: Container( - width: MediaQuery - .of(context) - .size - .width * - 0.85, - child: SecondaryButton( - label: "Cancel".toUpperCase(), - onTap: () { - showConfirmMessage(widget.model, - widget.model.cmcAllOrderDetail[0]); - } - , - color: Colors.red[800], - disabled: false, - textColor: Theme - .of(context) - .backgroundColor), - ), - ), - SizedBox( - height: 12, - ), - ], - ), + ) + : NewCMCStepOnePage( + changePageViewIndex: changePageViewIndex, + cMCInsertPresOrderRequestModel: + cMCInsertPresOrderRequestModel, + model: widget.model, + ), + NewCMCStepTowPage( + longitude: _longitude, + latitude: _latitude, + changePageViewIndex: changePageViewIndex, + cmcInsertPresOrderRequestModel: cMCInsertPresOrderRequestModel, + model: widget.model, + ), NewCMCStepThreePage( + changePageViewIndex: changePageViewIndex, + cmcInsertPresOrderRequestModel: cMCInsertPresOrderRequestModel, + model: widget.model, + ), + ], ), - ) - : NewCMCStepOnePage( - changePageViewIndex: changePageViewIndex, - cMCInsertPresOrderRequestModel: - cMCInsertPresOrderRequestModel, - model: widget.model, ), - // NewEReferralStepTowPage( - // changePageViewIndex: changePageViewIndex, - // patientERInsertPresOrderRequestModel: patientERInsertPresOrderRequestModel, - // - // ), - // NewEReferralStepThreePage( - // changePageViewIndex: changePageViewIndex, - // patientERInsertPresOrderRequestModel: patientERInsertPresOrderRequestModel, - // - // ), ], ), ), diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_one_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_one_page.dart index 52a64a50..02d099b4 100644 --- a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_one_page.dart +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_one_page.dart @@ -20,12 +20,10 @@ class NewCMCStepOnePage extends StatefulWidget { : super(key: key); @override - _NewCMCStepOnePageState createState() => - _NewCMCStepOnePageState(); + _NewCMCStepOnePageState createState() => _NewCMCStepOnePageState(); } -class _NewCMCStepOnePageState - extends State { +class _NewCMCStepOnePageState extends State { @override void initState() { super.initState(); @@ -34,176 +32,200 @@ class _NewCMCStepOnePageState @override Widget build(BuildContext context) { return AppScaffold( - isShowAppBar: false, - baseViewModel: widget.model, - body: SingleChildScrollView( - physics: ScrollPhysics(), - child: Container( - margin: EdgeInsets.all(12), - child: Center( - child: Column( - children: [ - FractionallySizedBox( - widthFactor: 0.94, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 20, - ), - Texts( -// TranslationBase.of(context).advancePaymentLabel, - "Select Home Health Care Services", - textAlign: TextAlign.center, - ), - Column( - children: widget.model.cmcAllServicesList.map(( - service) { - return Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - border: - Border.all(color: Colors.grey, width: 1), - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: Column( - children: [ - Row( - children: [ - Radio( + isShowAppBar: false, + baseViewModel: widget.model, + body: SingleChildScrollView( + physics: ScrollPhysics(), + child: Container( + margin: EdgeInsets.all(12), + child: Center( + child: Column( + children: [ + FractionallySizedBox( + widthFactor: 0.94, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 20, + ), + Texts( + "Select Home Health Care Services", + textAlign: TextAlign.center, + ), + Column( + children: + widget.model.cmcAllServicesList.map((service) { + return Container( + margin: EdgeInsets.only(top: 15), + decoration: BoxDecoration( + border: + Border.all(color: Colors.grey, width: 1), + borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: Column( + children: [ + Row( + children: [ + Radio( value: service.serviceID, activeColor: Colors.red[800], onChanged: (newValue) async { - PatientERCMCInsertServicesList patientERCMCInsertServicesList = - new PatientERCMCInsertServicesList( - price: service.price, - serviceID: service.serviceID - .toString(), - selectedServiceName: service - .description, - selectedServiceNameAR: - service.description, - recordID: 1, - totalPrice: service.totalPrice, - vAT: service.vAT); + PatientERCMCInsertServicesList + patientERCMCInsertServicesList = + new PatientERCMCInsertServicesList( + price: service.price, + serviceID: service.serviceID + .toString(), + selectedServiceName: + service.description, + selectedServiceNameAR: + service.description, + recordID: 1, + totalPrice: + service.totalPrice, + vAT: service.vAT); setState(() { widget .cMCInsertPresOrderRequestModel - .patientERCMCInsertServicesList = - [patientERCMCInsertServicesList]; + .patientERCMCInsertServicesList = [ + patientERCMCInsertServicesList + ]; }); - CMCGetItemsRequestModel cMCGetItemsRequestModel = new CMCGetItemsRequestModel (checkupType:newValue ); - await widget.model.getCheckupItems(cMCGetItemsRequestModel); + CMCGetItemsRequestModel + cMCGetItemsRequestModel = + new CMCGetItemsRequestModel( + checkupType: newValue); + await widget.model.getCheckupItems( + cMCGetItemsRequestModel: + cMCGetItemsRequestModel); }, groupValue: widget - .cMCInsertPresOrderRequestModel - .patientERCMCInsertServicesList.length >0?int.parse(widget - .cMCInsertPresOrderRequestModel - .patientERCMCInsertServicesList[0] - .serviceID):1), - Expanded( - child: Padding( - padding: const EdgeInsets.all(20.0), - child: Texts( - service.description, - fontSize: 15, - ), + .cMCInsertPresOrderRequestModel + .patientERCMCInsertServicesList + .length > + 0 + ? int.parse(widget + .cMCInsertPresOrderRequestModel + .patientERCMCInsertServicesList[ + 0] + .serviceID) + : 1), + Expanded( + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Texts( + service.description, + fontSize: 15, ), ), - ], - ), - ], - ), - ); - }).toList(), - ), - ], - ), - ), - SizedBox(height: 30,), - Container( - color: Colors.white, - width: double.infinity, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: widget.model.checkupItems.map((item) { - return Center( - child: FractionallySizedBox( - widthFactor: 0.8, - child: Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - border: - Border.all(color: Colors.grey, width: 1), - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 12, - ), - Container( - width: double.infinity, - padding: EdgeInsets.only( - left: 15, bottom: 5, top: 5), - decoration: BoxDecoration( - // border: Border( - // bottom: BorderSide( - // color: Colors.grey, - // width: 1.0, - // ), - // ), - // borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Texts( - item.itemName, - fontSize: 15, - ), - ], - ), - ), - - SizedBox( - height: 12, ), ], ), - ), + ], ), ); - }).toList()), - ) - ], - ), + }).toList(), + ), + ], + ), + ), + SizedBox( + height: 30, + ), + Container( + color: Colors.white, + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: widget.model.checkupItems.map((item) { + return Center( + child: FractionallySizedBox( + widthFactor: 1, + child: Container( + margin: EdgeInsets.only(top: 15), + decoration: BoxDecoration(color: Colors.white), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 12, + ), + Container( + width: double.infinity, + padding: EdgeInsets.only( + left: 15, bottom: 5, top: 5), + decoration: BoxDecoration( + border: BorderDirectional( + bottom: BorderSide( + style: BorderStyle.solid, + width: 0.5, + color: Colors.grey)), + //borderRadius: , + color: Colors.white), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Texts( + item.itemName, + fontSize: 15, + ), + ], + ), + ), + SizedBox( + height: 12, + ), + ], + ), + ), + ), + ); + }).toList()), + ) + ], ), ), ), - bottomSheet:Container( - height: MediaQuery.of(context).size.height * 0.10, - width: double.infinity, - child: Column( - children: [ - Container( - width: MediaQuery - .of(context) - .size - .width * 0.9, - child: SecondaryButton( - label: "Next", - // disabled: this.widget.patientERInsertPresOrderRequestModel.patientERHHCInsertServicesList.length ==0, - textColor: Theme - .of(context) - .backgroundColor), - ), - ], - ), - )); - } + ), + bottomSheet: Container( + height: MediaQuery.of(context).size.height * 0.10, + width: double.infinity, + child: Column( + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.9, + child: SecondaryButton( + label: "Next", + textColor: Theme.of(context).backgroundColor, + onTap: () { + if (widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList.length = null) { + int index = widget.model.cmcAllServicesList.length; + PatientERCMCInsertServicesList + patientERCMCInsertServicesList = + new PatientERCMCInsertServicesList( + price: widget.model.cmcAllServicesList[index-1].price, + serviceID: widget.model.cmcAllServicesList[index-1].serviceID.toString(), + selectedServiceName: widget.model.cmcAllServicesList[index-1].description, + selectedServiceNameAR: widget.model.cmcAllServicesList[index-1].description, + recordID: 1, + totalPrice: widget.model.cmcAllServicesList[index-1].totalPrice, + vAT: widget.model.cmcAllServicesList[index-1].vAT); + widget.cMCInsertPresOrderRequestModel + .patientERCMCInsertServicesList = [ + patientERCMCInsertServicesList + ]; + widget.changePageViewIndex(1); + } + }, + ), + ), + ], + ), + ), + ); + } } diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_three_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_three_page.dart new file mode 100644 index 00000000..e48bb5d5 --- /dev/null +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_three_page.dart @@ -0,0 +1,165 @@ +import 'dart:async'; + +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_insert_pres_order_request_model.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/patient_er_insert_pres_order_request_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; + +class NewCMCStepThreePage extends StatefulWidget { + final CMCInsertPresOrderRequestModel cmcInsertPresOrderRequestModel; + final Function changePageViewIndex; + final CMCViewModel model; + + NewCMCStepThreePage( + {Key key, + this.changePageViewIndex, + this.model, + this.cmcInsertPresOrderRequestModel}); + + @override + _NewCMCStepThreePageState createState() => + _NewCMCStepThreePageState(); +} + +class _NewCMCStepThreePageState + extends State { + Completer _controller = Completer(); + + static CameraPosition _kGooglePlex = CameraPosition( + target: LatLng(37.42796133580664, -122.085749655962), + zoom: 14.4746, + ); + final Set markers = new Set(); + + @override + void initState() { + if (widget.cmcInsertPresOrderRequestModel.latitude != null) { + markers.clear(); + markers.add( + Marker( + markerId: MarkerId( + widget.cmcInsertPresOrderRequestModel.latitude.hashCode + .toString(), + ), + position: LatLng( + widget.cmcInsertPresOrderRequestModel.latitude, + widget.cmcInsertPresOrderRequestModel.longitude)), + ); + _kGooglePlex = CameraPosition( + target: LatLng(widget.cmcInsertPresOrderRequestModel.latitude, + widget.cmcInsertPresOrderRequestModel.longitude), + zoom: 14.4746, + ); + } + super.initState(); + } + + @override + Widget build(BuildContext context) { + return AppScaffold( + isShowDecPage: false, + baseViewModel: widget.model, + body: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Container( + height: 400, + width: double.maxFinite, + margin: EdgeInsets.only(left: 12, right: 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts('Order Details'), + SizedBox( + height: 12, + ), + Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12)), + padding: EdgeInsets.all(8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts('Location :'), + SizedBox( + height: 12, + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + height: 200, + child: GoogleMap( + mapType: MapType.normal, + markers: markers, + initialCameraPosition: _kGooglePlex, + onMapCreated: (GoogleMapController controller) { + _controller.complete(controller); + }, + ), + ), + ), + SizedBox( + height: 12, + ), + Texts('Selected Service :'), + ...List.generate( + widget.cmcInsertPresOrderRequestModel.patientERCMCInsertServicesList.length, + (index) => Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + 'Service Name :', + fontSize: 12, + ), + SizedBox( + height: 5, + ), + Texts( + widget + .cmcInsertPresOrderRequestModel.patientERCMCInsertServicesList[index] + .selectedServiceName, + fontSize: 15, + bold: true, + ), + ], + ), + ), + ) + ], + ), + ) + ], + ), + ), + ), + bottomSheet: Container( + height: MediaQuery.of(context).size.height * 0.10, + width: double.infinity, + child: Column( + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.9, + child: SecondaryButton( + label: "Confirm", + onTap: () async { + await widget.model.insertPresPresOrder(order: widget.cmcInsertPresOrderRequestModel); + if (widget.model.state != ViewState.ErrorLocal) { + widget.changePageViewIndex(0); + } + }, + textColor: Theme.of(context).backgroundColor), + ), + ], + ), + ), + ); + } +} diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart new file mode 100644 index 00000000..27cddfe3 --- /dev/null +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart @@ -0,0 +1,113 @@ +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_insert_pres_order_request_model.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/patient_er_insert_pres_order_request_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/close_back.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:google_maps_place_picker/google_maps_place_picker.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:provider/provider.dart'; + +class NewCMCStepTowPage extends StatefulWidget { + final Function(PickResult) onPick; + final double latitude; + final double longitude; + final CMCInsertPresOrderRequestModel cmcInsertPresOrderRequestModel; + final Function changePageViewIndex; + final CMCViewModel model; + + const NewCMCStepTowPage( + {Key key, + this.onPick, + this.latitude, + this.longitude, + this.cmcInsertPresOrderRequestModel, + this.changePageViewIndex, + this.model}) + : super(key: key); + + @override + _NewCMCStepTowPageState createState() => + _NewCMCStepTowPageState(); +} + +class _NewCMCStepTowPageState + extends State { + double latitude = 0; + double longitude = 0; + + @override + void initState() { + if (widget.cmcInsertPresOrderRequestModel.latitude == null) { + latitude = widget.latitude; + longitude = widget.longitude; + } else { + latitude = widget.cmcInsertPresOrderRequestModel.latitude; + longitude = widget.cmcInsertPresOrderRequestModel.longitude; + } + super.initState(); + } + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return AppScaffold( + isShowDecPage: false, + body: PlacePicker( + apiKey: GOOGLE_API_KEY, + enableMyLocationButton: true, + automaticallyImplyAppBarLeading: false, + autocompleteOnTrailingWhitespace: true, + selectInitialPosition: true, + autocompleteLanguage: projectViewModel.currentLanguage, + enableMapTypeButton: true, + onPlacePicked: (PickResult result) { + print(result.adrAddress); + widget.changePageViewIndex(3); + }, + selectedPlaceWidgetBuilder: + (_, selectedPlace, state, isSearchBarFocused) { + print("state: $state, isSearchBarFocused: $isSearchBarFocused"); + return isSearchBarFocused + ? Container() + : FloatingCard( + bottomPosition: 0.0, + leftPosition: 0.0, + rightPosition: 0.0, + width: 500, + borderRadius: BorderRadius.circular(12.0), + child: state == SearchingState.Searching + ? Center(child: CircularProgressIndicator()) + : Container( + margin: EdgeInsets.all(12), + child: SecondaryButton( + color: Colors.grey[800], + textColor: Colors.white, + onTap: () { + setState(() { + widget.cmcInsertPresOrderRequestModel + .latitude = + selectedPlace.geometry.location.lat; + widget.cmcInsertPresOrderRequestModel + .longitude = + selectedPlace.geometry.location.lng; + }); + widget.changePageViewIndex(3); + }, + label: TranslationBase.of(context).next, + ), + ), + ); + }, + initialPosition: LatLng(latitude, longitude), + useCurrentLocation: true, + ), + ); + } +} diff --git a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_one_page.dart b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_one_page.dart index 2dd64605..1dbee1b5 100644 --- a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_one_page.dart +++ b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_one_page.dart @@ -6,8 +6,11 @@ import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/pickupLocation/PickupLocationFromMap.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:geolocator/geolocator.dart'; +import 'package:google_maps_place_picker/google_maps_place_picker.dart'; class NewHomeHealthCareStepOnePage extends StatefulWidget { final PatientERInsertPresOrderRequestModel @@ -27,135 +30,148 @@ class NewHomeHealthCareStepOnePage extends StatefulWidget { _NewHomeHealthCareStepOnePageState(); } -class _NewHomeHealthCareStepOnePageState - extends State { - @override - void initState() { - if(widget.patientERInsertPresOrderRequestModel.patientERHHCInsertServicesList==null) - widget.patientERInsertPresOrderRequestModel.patientERHHCInsertServicesList = []; +class _NewHomeHealthCareStepOnePageState extends State { + PickResult _result; + + @override + void initState() { + if (widget.patientERInsertPresOrderRequestModel.patientERHHCInsertServicesList == null) + widget.patientERInsertPresOrderRequestModel.patientERHHCInsertServicesList = []; super.initState(); } + @override Widget build(BuildContext context) { return AppScaffold( - isShowAppBar: false, - baseViewModel: widget.model, - body: SingleChildScrollView( - physics: ScrollPhysics(), - child: Container( - margin: EdgeInsets.only( - left: MediaQuery.of(context).size.width * 0.05, - right: MediaQuery.of(context).size.width * 0.05), - child: Center( - child: FractionallySizedBox( - widthFactor: 1, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 12, - ), - Texts( - "Select Home Health Care Services", - textAlign: TextAlign.center, - ), - Column( - children: widget.model.hhcAllServicesList.map((service) { - return Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - border: Border.all(color: Colors.grey, width: 1), - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: Column( - children: [ - Row( - children: [ - Checkbox( - value: isServiceSelected( - service.serviceID), - activeColor: Colors.black38, - onChanged: (bool newValue) { - setState(() { - if(!isServiceSelected(service.serviceID)) - widget.patientERInsertPresOrderRequestModel.patientERHHCInsertServicesList.add( PatientERHHCInsertServicesList( - recordID:widget.patientERInsertPresOrderRequestModel.patientERHHCInsertServicesList.length, - serviceID: service.serviceID, - serviceName: service.description)); - else - removeSelected(service.serviceID); - // widget.patientERInsertPresOrderRequestModel - // isPatientInsured = newValue; - }); - }), - Expanded( - child: Padding( - padding: const EdgeInsets.all(20.0), - child: Texts( - service.description, - fontSize: 15, - ), + isShowAppBar: false, + baseViewModel: widget.model, + body: SingleChildScrollView( + physics: ScrollPhysics(), + child: Container( + margin: EdgeInsets.only( + left: MediaQuery.of(context).size.width * 0.05, + right: MediaQuery.of(context).size.width * 0.05), + child: Center( + child: FractionallySizedBox( + widthFactor: 1, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 12, + ), + Texts( + "Select Home Health Care Services", + textAlign: TextAlign.center, + ), + Column( + children: widget.model.hhcAllServicesList.map((service) { + return Container( + margin: EdgeInsets.only(top: 15), + decoration: BoxDecoration( + border: Border.all(color: Colors.grey, width: 1), + borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: Column( + children: [ + Row( + children: [ + Checkbox( + value: isServiceSelected(service.serviceID), + activeColor: Colors.red[800], + onChanged: (bool newValue) { + setState(() { + if (!isServiceSelected( + service.serviceID)) + widget + .patientERInsertPresOrderRequestModel + .patientERHHCInsertServicesList + .add(PatientERHHCInsertServicesList( + recordID: widget + .patientERInsertPresOrderRequestModel + .patientERHHCInsertServicesList + .length, + serviceID: service.serviceID, + serviceName: + service.description)); + else + removeSelected(service.serviceID); + // widget.patientERInsertPresOrderRequestModel + // isPatientInsured = newValue; + }); + }), + Expanded( + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Texts( + service.description, + fontSize: 15, ), ), - ], - ), - ], - ), - ); - }).toList(), - ) - ], - ), + ), + ], + ), + ], + ), + ); + }).toList(), + ) + ], ), ), ), ), - bottomSheet: Container( - height: MediaQuery.of(context).size.height * 0.10, - width: double.infinity, - child: Column( - children: [ - Container( - width: MediaQuery.of(context).size.width * 0.9, - child: SecondaryButton( - label: "Next", - disabled: this - .widget - .patientERInsertPresOrderRequestModel - .patientERHHCInsertServicesList - .length == - 0, - textColor: Theme.of(context).backgroundColor), - ), - ], - ), - )); + ), + bottomSheet: Container( + height: MediaQuery.of(context).size.height * 0.10, + width: double.infinity, + child: Column( + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.9, + child: SecondaryButton( + label: "Next", + disabled: this + .widget + .patientERInsertPresOrderRequestModel + .patientERHHCInsertServicesList + .length == 0, + onTap: (){ + widget.changePageViewIndex(1); + }, + textColor: Theme.of(context).backgroundColor), + ), + ], + ), + ), + ); } isServiceSelected(int serviceId) { - Iterable patientERHHCInsertServicesList = widget - .patientERInsertPresOrderRequestModel.patientERHHCInsertServicesList - .where((element) => serviceId == element.serviceID); - if(patientERHHCInsertServicesList.length > 0) { - return true; - } - return false; + Iterable patientERHHCInsertServicesList = + widget + .patientERInsertPresOrderRequestModel.patientERHHCInsertServicesList + .where((element) => serviceId == element.serviceID); + if (patientERHHCInsertServicesList.length > 0) { + return true; + } + return false; } - removeSelected(int serviceId){ - Iterable patientERHHCInsertServicesList = widget - .patientERInsertPresOrderRequestModel.patientERHHCInsertServicesList - .where((element) => serviceId == element.serviceID); + removeSelected(int serviceId) { + Iterable patientERHHCInsertServicesList = + widget + .patientERInsertPresOrderRequestModel.patientERHHCInsertServicesList + .where((element) => serviceId == element.serviceID); - if(patientERHHCInsertServicesList.length > 0) + if (patientERHHCInsertServicesList.length > 0) setState(() { - widget.patientERInsertPresOrderRequestModel.patientERHHCInsertServicesList.remove(patientERHHCInsertServicesList); + widget + .patientERInsertPresOrderRequestModel.patientERHHCInsertServicesList + .remove(patientERHHCInsertServicesList.first); }); - - - } } diff --git a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_three_page.dart b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_three_page.dart new file mode 100644 index 00000000..aca2f3c2 --- /dev/null +++ b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_three_page.dart @@ -0,0 +1,172 @@ +import 'dart:async'; + +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/patient_er_insert_pres_order_request_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; + +class NewHomeHealthCareStepThreePage extends StatefulWidget { + final PatientERInsertPresOrderRequestModel + patientERInsertPresOrderRequestModel; + final Function changePageViewIndex; + final HomeHealthCareViewModel model; + + NewHomeHealthCareStepThreePage( + {Key key, + this.patientERInsertPresOrderRequestModel, + this.changePageViewIndex, + this.model}); + + @override + _NewHomeHealthCareStepThreePageState createState() => + _NewHomeHealthCareStepThreePageState(); +} + +class _NewHomeHealthCareStepThreePageState + extends State { + Completer _controller = Completer(); + + static CameraPosition _kGooglePlex = CameraPosition( + target: LatLng(37.42796133580664, -122.085749655962), + zoom: 14.4746, + ); + final Set markers = new Set(); + + @override + void initState() { + if (widget.patientERInsertPresOrderRequestModel.latitude != null) { + markers.clear(); + markers.add( + Marker( + markerId: MarkerId( + widget.patientERInsertPresOrderRequestModel.latitude.hashCode + .toString(), + ), + position: LatLng( + widget.patientERInsertPresOrderRequestModel.latitude, + widget.patientERInsertPresOrderRequestModel.longitude)), + ); + _kGooglePlex = CameraPosition( + target: LatLng(widget.patientERInsertPresOrderRequestModel.latitude, + widget.patientERInsertPresOrderRequestModel.longitude), + zoom: 14.4746, + ); + } + super.initState(); + } + + @override + Widget build(BuildContext context) { + return AppScaffold( + isShowDecPage: false, + baseViewModel: widget.model, + body: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Container( + width: double.maxFinite, + margin: EdgeInsets.only(left: 12, right: 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts('Order Details'), + SizedBox( + height: 12, + ), + Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12)), + padding: EdgeInsets.all(8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts('Location :'), + SizedBox( + height: 12, + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + height: 200, + child: GoogleMap( + mapType: MapType.normal, + markers: markers, + initialCameraPosition: _kGooglePlex, + onMapCreated: (GoogleMapController controller) { + _controller.complete(controller); + }, + ), + ), + ), + SizedBox( + height: 12, + ), + Texts('Selected Service :'), + ...List.generate( + widget.patientERInsertPresOrderRequestModel + .patientERHHCInsertServicesList.length, + (index) => Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + 'Service Name :', + fontSize: 12, + ), + SizedBox( + height: 5, + ), + Texts( + widget + .patientERInsertPresOrderRequestModel + .patientERHHCInsertServicesList[index] + .serviceName, + fontSize: 15, + bold: true, + ), + ], + ), + ), + ) + ], + ), + ), + SizedBox( + height: 57, + ), + ], + ), + ), + ), + bottomSheet: Container( + height: MediaQuery.of(context).size.height * 0.10, + width: double.infinity, + child: Column( + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.9, + child: SecondaryButton( + label: "Confirm", + disabled: widget.patientERInsertPresOrderRequestModel + .patientERHHCInsertServicesList.length == + 0, + onTap: () async { + await widget.model.insertPresPresOrder( + order: widget.patientERInsertPresOrderRequestModel); + if (widget.model.state != ViewState.ErrorLocal) { + widget.changePageViewIndex(0); + } + }, + textColor: Theme.of(context).backgroundColor), + ), + ], + ), + ), + ); + } +} diff --git a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_tow_page.dart b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_tow_page.dart new file mode 100644 index 00000000..3f522a1f --- /dev/null +++ b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_tow_page.dart @@ -0,0 +1,112 @@ +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/patient_er_insert_pres_order_request_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/close_back.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:google_maps_place_picker/google_maps_place_picker.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:provider/provider.dart'; + +class NewHomeHealthCareStepTowPage extends StatefulWidget { + final Function(PickResult) onPick; + final double latitude; + final double longitude; + final PatientERInsertPresOrderRequestModel + patientERInsertPresOrderRequestModel; + final Function changePageViewIndex; + final HomeHealthCareViewModel model; + + const NewHomeHealthCareStepTowPage( + {Key key, + this.onPick, + this.latitude, + this.longitude, + this.patientERInsertPresOrderRequestModel, + this.changePageViewIndex, + this.model}) + : super(key: key); + + @override + _NewHomeHealthCareStepTowPageState createState() => + _NewHomeHealthCareStepTowPageState(); +} + +class _NewHomeHealthCareStepTowPageState + extends State { + double latitude = 0; + double longitude = 0; + + @override + void initState() { + if (widget.patientERInsertPresOrderRequestModel.latitude == null) { + latitude = widget.latitude; + longitude = widget.longitude; + } else { + latitude = widget.patientERInsertPresOrderRequestModel.latitude; + longitude = widget.patientERInsertPresOrderRequestModel.longitude; + } + super.initState(); + } + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return AppScaffold( + isShowDecPage: false, + body: PlacePicker( + apiKey: GOOGLE_API_KEY, + enableMyLocationButton: true, + automaticallyImplyAppBarLeading: false, + autocompleteOnTrailingWhitespace: true, + selectInitialPosition: true, + autocompleteLanguage: projectViewModel.currentLanguage, + enableMapTypeButton: true, + onPlacePicked: (PickResult result) { + print(result.adrAddress); + widget.changePageViewIndex(3); + }, + selectedPlaceWidgetBuilder: + (_, selectedPlace, state, isSearchBarFocused) { + print("state: $state, isSearchBarFocused: $isSearchBarFocused"); + return isSearchBarFocused + ? Container() + : FloatingCard( + bottomPosition: 0.0, + leftPosition: 0.0, + rightPosition: 0.0, + width: 500, + borderRadius: BorderRadius.circular(12.0), + child: state == SearchingState.Searching + ? Center(child: CircularProgressIndicator()) + : Container( + margin: EdgeInsets.all(12), + child: SecondaryButton( + color: Colors.grey[800], + textColor: Colors.white, + onTap: () { + setState(() { + widget.patientERInsertPresOrderRequestModel + .latitude = + selectedPlace.geometry.location.lat; + widget.patientERInsertPresOrderRequestModel + .longitude = + selectedPlace.geometry.location.lng; + }); + widget.changePageViewIndex(3); + }, + label: TranslationBase.of(context).next, + ), + ), + ); + }, + initialPosition: LatLng(latitude, longitude), + useCurrentLocation: true, + ), + ); + } +} diff --git a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_home_health_care_page.dart b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_home_health_care_page.dart index 40fb6125..87a33c6d 100644 --- a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_home_health_care_page.dart +++ b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_home_health_care_page.dart @@ -4,12 +4,15 @@ import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealth import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/update_pres_oreder_request_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/Dialog/confirm_cancel_order_dialog.dart'; +import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_three_page.dart'; +import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_tow_page.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/material.dart'; +import 'package:geolocator/geolocator.dart'; import '../StepsWidget.dart'; import 'new_Home_health_care_step_one_page.dart'; @@ -18,7 +21,6 @@ class NewHomeHealthCarePage extends StatefulWidget { NewHomeHealthCarePage({this.model}); final HomeHealthCareViewModel model; - @override _NewHomeHealthCarePageState createState() => _NewHomeHealthCarePageState(); } @@ -27,7 +29,8 @@ class _NewHomeHealthCarePageState extends State with TickerProviderStateMixin { PageController _controller; int _currentIndex = 1; - int pageSelected = 2; + double _latitude; + double _longitude; PatientERInsertPresOrderRequestModel patientERInsertPresOrderRequestModel = new PatientERInsertPresOrderRequestModel(); @@ -36,8 +39,19 @@ class _NewHomeHealthCarePageState extends State void initState() { super.initState(); _controller = new PageController(); + _getCurrentLocation(); } + _getCurrentLocation() async { + await getLastKnownPosition().then((value) { + _latitude = value.latitude; + _longitude = value.longitude; + }).catchError((e) { + _longitude = 0; + _latitude = 0; + }); + } + @override void dispose() { super.dispose(); @@ -285,6 +299,18 @@ class _NewHomeHealthCarePageState extends State patientERInsertPresOrderRequestModel: patientERInsertPresOrderRequestModel, model: widget.model, ), + NewHomeHealthCareStepTowPage( + latitude: _latitude, + longitude: _longitude, + changePageViewIndex: _changeCurrentTab, + patientERInsertPresOrderRequestModel: patientERInsertPresOrderRequestModel, + model: widget.model, + ), + NewHomeHealthCareStepThreePage( + changePageViewIndex: _changeCurrentTab, + patientERInsertPresOrderRequestModel: patientERInsertPresOrderRequestModel, + model: widget.model, + ) ], ), diff --git a/lib/pages/AlHabibMedicalService/HomeHealthCare/StepsWidget.dart b/lib/pages/AlHabibMedicalService/HomeHealthCare/StepsWidget.dart index ec3020c5..370544d0 100644 --- a/lib/pages/AlHabibMedicalService/HomeHealthCare/StepsWidget.dart +++ b/lib/pages/AlHabibMedicalService/HomeHealthCare/StepsWidget.dart @@ -13,7 +13,7 @@ class StepsWidget extends StatelessWidget { @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); - return projectViewModel.isArabic? Stack( + return !projectViewModel.isArabic? Stack( children: [ Container( height: 50, diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart index ee7ed8fa..b99596c8 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart @@ -63,7 +63,6 @@ class _PickupLocationState extends State { _longitude = 0; _latitude = 0; }); - // currentLocation = LatLng(position.latitude, position.longitude); } @override @@ -364,7 +363,6 @@ class _PickupLocationState extends State { ), ], ), - //TODO show dialog projects SizedBox( height: 45, diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index ff21d73e..1ca6c2eb 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -123,25 +123,25 @@ class _LandingPageState extends State with WidgetsBindingObserver { AppGlobal.context = context; }); _requestIOSPermissions(); - pageController = PageController(keepPage: true); - _firebaseMessaging.setAutoInitEnabled(true); - - if (Platform.isIOS) { - _firebaseMessaging.requestNotificationPermissions(); - } - - _firebaseMessaging.getToken().then((String token) { - sharedPref.setString(PUSH_TOKEN, token); - if (token != null) { - checkUserStatus(token); - } - requestPermissions(); - }).catchError((err) { - print(err); - }); + pageController = PageController(keepPage: true); + // _firebaseMessaging.setAutoInitEnabled(true); + // + // if (Platform.isIOS) { + // _firebaseMessaging.requestNotificationPermissions(); + // } + // + // _firebaseMessaging.getToken().then((String token) { + // sharedPref.setString(PUSH_TOKEN, token); + // if (token != null) { + // checkUserStatus(token); + // } + // requestPermissions(); + // }).catchError((err) { + // print(err); + // }); //_firebase Background message handler - _firebaseMessaging.configure( + // _firebaseMessaging.configure( // onMessage: (Map message) async { // showDialog("onMessage: $message"); // print("onMessage: $message"); @@ -254,7 +254,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { // print("Is Call Not Found iOS"); // } // }, - ); + // ); } showDialogs(String message) { diff --git a/lib/widgets/pickupLocation/PickupLocationFromMap.dart b/lib/widgets/pickupLocation/PickupLocationFromMap.dart index 2e34ad3e..d8c93441 100644 --- a/lib/widgets/pickupLocation/PickupLocationFromMap.dart +++ b/lib/widgets/pickupLocation/PickupLocationFromMap.dart @@ -34,9 +34,10 @@ class PickupLocationFromMap extends StatelessWidget { body: PlacePicker( apiKey: GOOGLE_API_KEY, enableMyLocationButton: true, - + automaticallyImplyAppBarLeading: false, autocompleteLanguage: projectViewModel.currentLanguage, enableMapTypeButton: true, + selectInitialPosition: true, onPlacePicked: (PickResult result) { print(result.adrAddress); onPick(result); diff --git a/pubspec.yaml b/pubspec.yaml index 24dc3a23..a383192d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -75,6 +75,8 @@ dependencies: # charts charts_flutter: ^0.9.0 + google_maps_flutter: ^1.0.3 + # Qr code Scanner TODO fix it #barcode_scan: ^3.0.1