From 2e2f7334d5feb695ab134cd4d6dfe377cc423407 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 30 Aug 2021 16:24:00 +0300 Subject: [PATCH] fix issues PAP-910,PAP-911 --- .../NewCMC/cmc_location_page.dart | 6 +++- .../NewCMC/new_cmc_step_tow_page.dart | 34 ++++++++++++++----- .../NewHomeHealthCare/location_page.dart | 6 +++- .../new_Home_health_care_step_tow_page.dart | 29 ++++++++++++---- 4 files changed, 57 insertions(+), 18 deletions(-) diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/cmc_location_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/cmc_location_page.dart index 72aa40dc..d7bb61ed 100644 --- a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/cmc_location_page.dart +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/cmc_location_page.dart @@ -33,11 +33,15 @@ class CMCLocationPage extends StatefulWidget { class _CMCLocationPageState extends State { double latitude = 0; double longitude = 0; + bool showCurrentLocation = false; @override void initState() { latitude = widget.latitude; longitude = widget.longitude; + if(latitude == 0.0 && longitude == 0.0) { + showCurrentLocation = true; + } super.initState(); } @@ -149,7 +153,7 @@ class _CMCLocationPageState extends State { ); }, initialPosition: LatLng(latitude, longitude), - useCurrentLocation: false, + useCurrentLocation: showCurrentLocation, ), )); } 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 3d969d9e..12e1b622 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 @@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/Comprehens import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/customer_addresses_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/uitl/location_util.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/select_location_dialog.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -44,6 +45,7 @@ class _NewCMCStepTowPageState extends State { double latitude = 0; double longitude = 0; AddressInfo _selectedAddress; + bool showCurrentLocation = false; @override void initState() { @@ -56,14 +58,26 @@ class _NewCMCStepTowPageState extends State { super.initState(); } - setLatitudeAndLongitude({bool isSetState = false, String latLong}) { - if (latLong == null) - latLong = widget - .model.addressesList[widget.model.addressesList.length - 1].latLong; - List latLongArr = latLong.split(','); + setLatitudeAndLongitude({bool isSetState = false, String latLong}) async { + if (latLong == null){ + if(widget.model.addressesList.isEmpty) { - latitude = double.parse(latLongArr[0]); - longitude = double.parse(latLongArr[1]); + setState(() { + showCurrentLocation = true; + }); + } else { + latLong = widget + .model.addressesList[widget.model.addressesList.length - 1].latLong; + } + + } + + if(!showCurrentLocation) { + List latLongArr = latLong.split(','); + + latitude = double.parse(latLongArr[0]); + longitude = double.parse(latLongArr[1]); + } } @override @@ -144,9 +158,11 @@ class _NewCMCStepTowPageState extends State { ); }, initialPosition: LatLng(latitude, longitude), - useCurrentLocation: false, + useCurrentLocation: showCurrentLocation, ), - Container( + if(widget.model.addressesList.isNotEmpty) + + Container( child: InkWell( onTap: () => confirmSelectLocationDialog(widget.model.addressesList), diff --git a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.dart b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.dart index c87a3eb5..0e013ebf 100644 --- a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.dart +++ b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.dart @@ -33,12 +33,16 @@ class _LocationPageState extends State { double latitude = 0; double longitude = 0; + bool showCurrentLocation = false; @override void initState() { latitude = widget.latitude; longitude = widget.longitude; + if(latitude == 0.0 && longitude == 0.0) { + showCurrentLocation = true; + } super.initState(); } @@ -141,7 +145,7 @@ class _LocationPageState ); }, initialPosition: LatLng(latitude, longitude), - useCurrentLocation: false, + useCurrentLocation: showCurrentLocation, ), )); } 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 index e9ddd2d1..1b96cdc8 100644 --- 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 @@ -46,6 +46,8 @@ class _NewHomeHealthCareStepTowPageState double latitude = 0; double longitude = 0; AddressInfo _selectedAddress; + bool showCurrentLocation = false; + @override void initState() { @@ -60,13 +62,25 @@ class _NewHomeHealthCareStepTowPageState } setLatitudeAndLongitude({bool isSetState = false, String latLong}) { - if (latLong == null) - latLong = widget.model.addressesList[widget.model.addressesList - .length - 1].latLong; - List latLongArr = latLong.split(','); + if (latLong == null){ + if(widget.model.addressesList.isEmpty) { + setState(() { + showCurrentLocation = true; + }); + } else { + latLong = widget.model.addressesList[widget.model.addressesList + .length - 1].latLong; + } + + } + + if(!showCurrentLocation) { + List latLongArr = latLong.split(','); + + latitude = double.parse(latLongArr[0]); + longitude = double.parse(latLongArr[1]); + } - latitude = double.parse(latLongArr[0]); - longitude = double.parse(latLongArr[1]); } @override @@ -147,8 +161,9 @@ class _NewHomeHealthCareStepTowPageState ); }, initialPosition: LatLng(latitude, longitude), - useCurrentLocation: false, + useCurrentLocation: showCurrentLocation, ), + if(widget.model.addressesList.isNotEmpty) Container( child: InkWell( onTap: () =>