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 39650f3b..5ad9edaa 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 @@ -23,6 +23,7 @@ class NewCMCStepOnePage extends StatefulWidget { final double latitude; final double longitude; + const NewCMCStepOnePage({Key key, this.cMCInsertPresOrderRequestModel, this.model, this.changePageViewIndex, this.latitude, this.longitude}) : super(key: key); @override @@ -30,6 +31,7 @@ class NewCMCStepOnePage extends StatefulWidget { } class _NewCMCStepOnePageState extends State { + int selectedItem=0; @override void initState() { super.initState(); @@ -60,6 +62,7 @@ class _NewCMCStepOnePageState extends State { value: widget.model.cmcAllServicesList[index].serviceID, activeColor: Colors.red[800], onChanged: (newValue) async { + selectedItem=index; PatientERCMCInsertServicesList patientERCMCInsertServicesList = new PatientERCMCInsertServicesList( price: widget.model.cmcAllServicesList[index].price, serviceID: widget.model.cmcAllServicesList[index].serviceID.toString(), @@ -71,8 +74,8 @@ class _NewCMCStepOnePageState extends State { setState(() { widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList = [patientERCMCInsertServicesList]; }); - CMCGetItemsRequestModel cMCGetItemsRequestModel = new CMCGetItemsRequestModel(checkupType: newValue); - await widget.model.getCheckupItems(cMCGetItemsRequestModel: 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) @@ -102,7 +105,10 @@ class _NewCMCStepOnePageState extends State { return mDivider(Colors.grey); }, itemCount: widget.model.cmcAllServicesList.length), - Image.asset(projectViewModel.isArabic?"assets/images/cc_ar.png":"assets/images/cc_en.png",width: double.infinity,), + Image.asset( + projectViewModel.isArabic ? "assets/images/cc_ar.png" : "assets/images/cc_en.png", + width: double.infinity, + ), // Card( // shape: cardRadius(12), // elevation: 4, @@ -158,15 +164,16 @@ class _NewCMCStepOnePageState extends State { TranslationBase.of(context).next, () async { if (widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList.length != 0 || widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList == null) { - int index = widget.model.cmcAllServicesList.length; + // 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].descriptionN, - recordID: 1, - totalPrice: widget.model.cmcAllServicesList[index - 1].totalPrice, - vAT: widget.model.cmcAllServicesList[index - 1].vAT); + price: widget.model.cmcAllServicesList[selectedItem].price, + serviceID: widget.model.cmcAllServicesList[selectedItem].serviceID.toString(), + selectedServiceName: widget.model.cmcAllServicesList[selectedItem].description, + selectedServiceNameAR: widget.model.cmcAllServicesList[selectedItem].descriptionN, + recordID: 1, + totalPrice: widget.model.cmcAllServicesList[selectedItem].totalPrice, + vAT: widget.model.cmcAllServicesList[selectedItem].vAT, + ); widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList = [patientERCMCInsertServicesList]; await widget.model.getCustomerInfo(); @@ -174,14 +181,14 @@ class _NewCMCStepOnePageState extends State { Utils.showErrorToast(); } else { navigateTo( - context, - NewCMCStepTowPage( - longitude: widget.longitude, - latitude: widget.latitude, - cmcInsertPresOrderRequestModel: widget.cMCInsertPresOrderRequestModel, - model: widget.model, - )); - // widget.changePageViewIndex(1); + context, + NewCMCStepTowPage( + longitude: widget.longitude, + latitude: widget.latitude, + cmcInsertPresOrderRequestModel: widget.cMCInsertPresOrderRequestModel, + model: widget.model, + ), + ); } } }, 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 index e0bfb3bb..5a1fe867 100644 --- a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart @@ -56,29 +56,47 @@ class _NewCMCStepTowPageState extends State { if (await this.sharedPref.getDouble(USER_LAT) != null && await this.sharedPref.getDouble(USER_LONG) != null) { var lat = await this.sharedPref.getDouble(USER_LAT); var long = await this.sharedPref.getDouble(USER_LONG); + latitude = lat; + longitude = long; currentPostion = LatLng(lat, long); setMap(); } else { if (await Permission.location.request().isGranted) { var position = await GeolocatorPlatform.instance.getCurrentPosition(desiredAccuracy: LocationAccuracy.low); currentPostion = LatLng(position.latitude, position.longitude); + latitude = position.latitude; + longitude = position.longitude; setMap(); } else { - requestPermissions().then((value) async { - if (value[Permission.location].isGranted) { - var position = await GeolocatorPlatform.instance.getCurrentPosition(desiredAccuracy: LocationAccuracy.low); - currentPostion = LatLng(position.latitude, position.longitude); - setMap(); - } - }); + requestPermissions().then( + (value) async { + if (value[Permission.location].isGranted) { + var position = await GeolocatorPlatform.instance.getCurrentPosition(desiredAccuracy: LocationAccuracy.low); + currentPostion = LatLng(position.latitude, position.longitude); + latitude = position.latitude; + longitude = position.longitude; + setMap(); + } + }, + ); } } } @override void initState() { - _getUserLocation(); super.initState(); + appMap = AppMap( + cameraPosition.toMap(), + onCameraMove: (camera) { + setState(() {}); + _updatePosition(camera); + }, + onMapCreated: () { + print("_getUserLocation"); + _getUserLocation(); + }, + ); } setMap() { @@ -87,7 +105,7 @@ class _NewCMCStepTowPageState extends State { target: currentPostion, zoom: 14.4746, ); - appMap.moveTo(cameraPostion: cameraPosition); + if (appMap != null) appMap.moveTo(cameraPostion: cameraPosition); }); } @@ -123,8 +141,9 @@ class _NewCMCStepTowPageState extends State { setMap(); } } - + AppMap appMap; + @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); @@ -181,23 +200,22 @@ class _NewCMCStepTowPageState extends State { ), InkWell( onTap: () async { - - bool isNeedToUpdate=false; + bool isNeedToUpdate = false; await Navigator.of(context).push(new MaterialPageRoute( builder: (BuildContext context) { return CMCLocationPage( latitude: latitude, longitude: longitude, - onPick: (){ - isNeedToUpdate=true; - print("onPickonPick1"); + onPick: () { + isNeedToUpdate = true; + print("onPickonPick1"); }, ); }, )); - if(isNeedToUpdate){ + if (isNeedToUpdate) { print("onPickonPick2"); - _selectedAddress=new AddressInfo(); + _selectedAddress = new AddressInfo(); _selectedAddress.address1 = widget.model.addressesList.last.address1; showCurrentLocation = false; setLatitudeAndLongitude(); @@ -225,9 +243,7 @@ class _NewCMCStepTowPageState extends State { child: Stack( alignment: Alignment.center, children: [ - appMap = AppMap(cameraPosition.toMap(), onCameraMove: (camera){ - _updatePosition(camera); - }), + if (appMap != null) appMap, Icon( Icons.place, color: CustomColors.accentColor, diff --git a/lib/widgets/app_map/google_huawei_map.dart b/lib/widgets/app_map/google_huawei_map.dart index dfcc187d..f7b986db 100644 --- a/lib/widgets/app_map/google_huawei_map.dart +++ b/lib/widgets/app_map/google_huawei_map.dart @@ -11,8 +11,9 @@ class AppMap extends StatefulWidget { Map initialCamera; AppMapState _state; + Function onMapCreated; - AppMap(this.initialCamera, {this.onCameraMove}); + AppMap(this.initialCamera, {this.onCameraMove, this.onMapCreated}); @override State createState() => _state = AppMapState(); @@ -29,7 +30,7 @@ class AppMap extends StatefulWidget { } class AppMapState extends State { - bool isHuawei; + bool isHuawei = false; Completer _googleMapControllerComp = Completer(); GoogleMapController googleMapController; @@ -55,7 +56,7 @@ class AppMapState extends State { Widget map() => isHuawei ? huaweiMap() : googleMap(); - googleMap() { + Widget googleMap() { return GoogleMap( mapType: MapType.normal, zoomControlsEnabled: false, @@ -66,6 +67,7 @@ class AppMapState extends State { onMapCreated: (GoogleMapController controller) { googleMapController = controller; _googleMapControllerComp.complete(controller); + widget.onMapCreated(); }, ); } @@ -81,6 +83,7 @@ class AppMapState extends State { onMapCreated: (controller) { _huaweiMapController = controller; _huaweiMapControllerComp.complete(controller); + widget.onMapCreated(); }, ); }