From ed892b915bb30de374944254b57b29c8f23126fc Mon Sep 17 00:00:00 2001 From: Mohamed Nouffer Date: Tue, 18 Jul 2023 22:10:30 +0530 Subject: [PATCH] added refresh --- .../destination/destination_controller.dart | 30 +++++++++++-------- lib/pages/index/index_page.dart | 6 ++++ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/lib/pages/destination/destination_controller.dart b/lib/pages/destination/destination_controller.dart index 20c37c3..1845f60 100644 --- a/lib/pages/destination/destination_controller.dart +++ b/lib/pages/destination/destination_controller.dart @@ -553,7 +553,23 @@ class DestinationController extends GetxController { void onReady() { Get.toNamed(AppPages.LOGIN)!.then((value){ if(indexController.currentUser.length > 0) { - String _token = indexController.currentUser[0]["token"]; + fixMapBound(); + } + else { + Get.toNamed(AppPages.TRAVEL); + PerfectureService.getSubExt("9").then((value){ + if(value != null){ + LatLngBounds bnds = LatLngBounds(LatLng(value[1], value[0]), LatLng(value[3], value[2])); + indexController.mapController!.fitBounds(bnds); //.centerZoomFitBounds(bnds); + } + }); + } + }); + super.onReady(); + } + + void fixMapBound(){ + String _token = indexController.currentUser[0]["token"]; indexController.switchPage(AppPages.INITIAL); LocationService.getLocationsExt(_token).then((value) { if(value != null){ @@ -568,18 +584,6 @@ class DestinationController extends GetxController { indexController.loadLocationsBound(); } }); - } - else { - Get.toNamed(AppPages.TRAVEL); - PerfectureService.getSubExt("9").then((value){ - if(value != null){ - LatLngBounds bnds = LatLngBounds(LatLng(value[1], value[0]), LatLng(value[3], value[2])); - indexController.mapController!.fitBounds(bnds); //.centerZoomFitBounds(bnds); - } - }); - } - }); - super.onReady(); } void connectionChanged(String val) { diff --git a/lib/pages/index/index_page.dart b/lib/pages/index/index_page.dart index 4c50194..e76446d 100644 --- a/lib/pages/index/index_page.dart +++ b/lib/pages/index/index_page.dart @@ -39,6 +39,12 @@ class IndexPage extends GetView { //automaticallyImplyLeading: false, title: Text("add_location".tr), actions: [ + IconButton( + onPressed: (){ + destinationController.fixMapBound(); + }, + icon: Icon(Icons.refresh) + ), InkWell( onTap: (){ Get.toNamed(AppPages.SEARCH);