From ff018a56fe098d27449748d8712b593a695cce3e Mon Sep 17 00:00:00 2001 From: Mohamed Nouffer Date: Mon, 25 Jul 2022 19:56:32 +0530 Subject: [PATCH] update --- .../destination_map/destination_map_page.dart | 25 +++++++++------- lib/pages/index/index_controller.dart | 30 +++++++++++++++++-- lib/pages/index/index_page.dart | 28 ++++++++--------- lib/services/cat_service.dart | 21 +++++++++++++ lib/widgets/base_layer_widget.dart | 5 ++++ lib/widgets/bottom_sheet_new.dart | 22 +++++++------- lib/widgets/map_widget.dart | 2 +- lib/widgets/perfecture_widget.dart | 17 +++++++---- 8 files changed, 106 insertions(+), 44 deletions(-) diff --git a/lib/pages/destination_map/destination_map_page.dart b/lib/pages/destination_map/destination_map_page.dart index 11d8a79..b5e9e30 100644 --- a/lib/pages/destination_map/destination_map_page.dart +++ b/lib/pages/destination_map/destination_map_page.dart @@ -182,7 +182,7 @@ class _DestinationMapPageState extends State { } , bounds: indexController.currentBound.length > 0 ? indexController.currentBound[0]: LatLngBounds.fromPoints([LatLng(35.03999881162295, 136.40587119778962), LatLng(36.642756778706904, 137.95226720406063)]), zoom: 1, - maxZoom: 20, + maxZoom: 42, interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag, //plugins: [LocationMarkerPlugin(),] ), @@ -193,15 +193,20 @@ class _DestinationMapPageState extends State { subdomains: ['a', 'b', 'c'], ), ), - PolylineLayerWidget( - options: PolylineLayerOptions( - polylines: [ - Polyline( - points: getPoints()!, - strokeWidth: 4.0, - color: Colors.purple), - ], - ), + Obx(() => + indexController.routePoints.length > 0 ? + PolylineLayerWidget( + options: PolylineLayerOptions( + polylines: [ + Polyline( + points: getPoints()!, + strokeWidth: 4.0, + color: Colors.purple), + ], + ), + ) + : + Container(), ), // PopupMarkerLayerWidget( // options: PopupMarkerLayerOptions( diff --git a/lib/pages/index/index_controller.dart b/lib/pages/index/index_controller.dart index 34feeba..33b3adf 100644 --- a/lib/pages/index/index_controller.dart +++ b/lib/pages/index/index_controller.dart @@ -241,7 +241,27 @@ void login(String email, String password, BuildContext context){ CatService.loadCats(bounds.southWest!.latitude, bounds.southWest!.longitude, bounds.northWest.latitude, bounds.northWest.longitude, bounds.northEast!.latitude, bounds.northEast!.longitude, bounds.southEast.latitude, bounds.southEast.longitude).then((value) { cats.clear(); cats.add(initVal); - cats.addAll(value!); + for(dynamic cat in value!){ + if(cat['category'] != null){ + cats.add(cat!); + } + } + }); + } + } + + void loadCatForCity(String city){ + dynamic initVal = {'category':'-all-'}; + LatLngBounds bounds = mapController!.bounds!; + if(bounds.southEast != null && bounds.southWest != null && bounds.northEast != null && bounds.southEast != null ){ + CatService.loadCatByCity(city).then((value) { + cats.clear(); + cats.add(initVal); + for(dynamic cat in value!){ + if(cat['category'] != null){ + cats.add(cat!); + } + } }); } } @@ -338,7 +358,9 @@ void login(String email, String password, BuildContext context){ void loadLocationforSubPerf(String subperf, MapController mapController) async { String cat = currentCat.isNotEmpty == true ? currentCat[0] : ""; - print(currentCat); + if(currentCat[0] == "-all-"){ + cat = ""; + } LocationService.loadLocationsSubFor(subperf, cat).then((value){ locations.clear(); locations.add(value!); @@ -419,6 +441,8 @@ void login(String email, String password, BuildContext context){ } void zoomtoSubPerf(String id){ + + print("zooooom"); PerfectureService.getSubExt(id).then((value){ LatLng lat1 = LatLng(value![1], value[0]); @@ -439,7 +463,7 @@ void login(String email, String password, BuildContext context){ } void populateForSubPerf(String subperf, MapController mapController){ - subDropdownValue = subperf; + //subDropdownValue = subperf; loadLocationforSubPerf(subperf, mapController); zoomtoSubPerf(subperf); is_loading.value = false; diff --git a/lib/pages/index/index_page.dart b/lib/pages/index/index_page.dart index d621045..5c1f437 100644 --- a/lib/pages/index/index_page.dart +++ b/lib/pages/index/index_page.dart @@ -112,20 +112,20 @@ class IndexPage extends GetView { : BreadCrumbWidget(mapController: indexController.mapController), Container(width: 24.0,), - Row( - children: [ - indexController.currentCat.isNotEmpty ? Text(indexController.currentCat[0].toString()): Text(""), - indexController.currentCat.isNotEmpty ? - IconButton( - onPressed: (){ - indexController.currentCat.clear(); - indexController.loadLocationsBound(); - }, - icon: Icon(Icons.cancel, color: Colors.red,) - ) : - Container(width: 0, height: 0,) - ], - ) + // Row( + // children: [ + // indexController.currentCat.isNotEmpty ? Text(indexController.currentCat[0].toString()): Text(""), + // indexController.currentCat.isNotEmpty ? + // IconButton( + // onPressed: (){ + // indexController.currentCat.clear(); + // indexController.loadLocationsBound(); + // }, + // icon: Icon(Icons.cancel, color: Colors.red,) + // ) : + // Container(width: 0, height: 0,) + // ], + // ) ], ) ), diff --git a/lib/services/cat_service.dart b/lib/services/cat_service.dart index 60203c8..5fc682c 100644 --- a/lib/services/cat_service.dart +++ b/lib/services/cat_service.dart @@ -30,6 +30,27 @@ class CatService{ } + static Future?> loadCatByCity(String cityname)async { + List cats = []; + String server_url = ConstValues.currentServer(); + String url = '${server_url}/api/catbycity/?${cityname}'; + //String url = 'http://localhost:8100/api/cats/?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}'; + + + //String url = 'http://container.intranet.sumasen.net:8100/api/cats/'; + print("---- cat url is ${url}"); + final response = await http.get(Uri.parse(url), + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + }, + ); + + if (response.statusCode == 200) { + + cats = json.decode(utf8.decode(response.bodyBytes)); + } + return cats; + } } diff --git a/lib/widgets/base_layer_widget.dart b/lib/widgets/base_layer_widget.dart index b7bdde9..2123fb4 100644 --- a/lib/widgets/base_layer_widget.dart +++ b/lib/widgets/base_layer_widget.dart @@ -10,8 +10,13 @@ class BaseLayer extends StatelessWidget { options: TileLayerOptions( backgroundColor: Colors.transparent, urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + //urlTemplate: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', subdomains: ['a', 'b', 'c'], ), ); } } + +// var Esri_WorldImagery = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', { +// attribution: 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community' +// }); \ No newline at end of file diff --git a/lib/widgets/bottom_sheet_new.dart b/lib/widgets/bottom_sheet_new.dart index d315a75..b3c788b 100644 --- a/lib/widgets/bottom_sheet_new.dart +++ b/lib/widgets/bottom_sheet_new.dart @@ -25,7 +25,7 @@ class BottomSheetNew extends GetView { return Image(image: AssetImage('assets/images/empty_image.png')); } else{ - print("@@@@@@@@@@@@@ rog mode -------------------- ${indexController.currentDestinationFeature[0].photos} @@@@@@@@@@@"); + //print("@@@@@@@@@@@@@ rog mode -------------------- ${indexController.currentDestinationFeature[0].photos} @@@@@@@@@@@"); return Image(image: NetworkImage( indexController.currentDestinationFeature[0].photos!, ), @@ -110,7 +110,7 @@ class BottomSheetNew extends GetView { ), MaterialButton( onPressed: () { - print("----- next is ${indexController.currentFeature[0]} ------"); + //print("----- next is ${indexController.currentFeature[0]} ------"); //indexController.makeNext(indexController.currentFeature[0]); }, color: Colors.blue, @@ -222,7 +222,7 @@ class BottomSheetNew extends GetView { ), MaterialButton( onPressed: () { - print("----- next is ${indexController.currentFeature[0]} ------"); + //print("----- next is ${indexController.currentFeature[0]} ------"); indexController.makeNext(indexController.currentFeature[0]); }, color: Colors.blue, @@ -267,7 +267,7 @@ class BottomSheetNew extends GetView { ); }, ), - indexController.currentFeature[0].properties!["location_name"] != null && (indexController.currentFeature[0].properties!["address"] as String).isNotEmpty ? + indexController.currentFeature[0].properties!["location_name"] != null && (indexController.currentFeature[0].properties!["location_name"] as String).isNotEmpty ? Flexible(child: Text(indexController.currentFeature[0].properties!["location_name"])) : Container(width: 0.0, height: 0,), @@ -398,7 +398,7 @@ class BottomSheetNew extends GetView { Destination dest = indexController.currentDestinationFeature[0]!; //print("------ curent destination is ${dest!.checkedIn}-------"); if(dest != null){ - print("------ curent destination is ${dest!.checkedin}-------::::::::::"); + //print("------ curent destination is ${dest!.checkedin}-------::::::::::"); destinationController.makeCheckin(dest, !dest.checkedin!); } }, @@ -419,7 +419,7 @@ class BottomSheetNew extends GetView { Widget getCheckin(BuildContext context){ - print("------ currentAction ----- ${indexController.currentAction}-----"); + //print("------ currentAction ----- ${indexController.currentAction}-----"); return Row( mainAxisAlignment: MainAxisAlignment.center, @@ -437,7 +437,7 @@ class BottomSheetNew extends GetView { child: Text("Image"), onPressed: (){ final ImagePicker _picker = ImagePicker(); _picker.pickImage(source: ImageSource.camera).then((value){ - print("----- image---- ${value!.path}"); + //print("----- image---- ${value!.path}"); }); }, ) @@ -446,11 +446,11 @@ class BottomSheetNew extends GetView { ElevatedButton( onPressed: (){ if(indexController.currentAction.isNotEmpty){ - print(indexController.currentAction[0]); + //print(indexController.currentAction[0]); indexController.currentAction[0][0]["checkin"] = true; Map temp = Map.from(indexController.currentAction[0][0]); indexController.currentAction.clear(); - print("---temp---${temp}"); + //print("---temp---${temp}"); indexController.currentAction.add([temp]); } indexController.makeAction(context); @@ -463,11 +463,11 @@ class BottomSheetNew extends GetView { ElevatedButton( onPressed: (){ if(indexController.currentAction.isNotEmpty){ - print(indexController.currentAction[0]); + //print(indexController.currentAction[0]); indexController.currentAction[0][0]["checkin"] = false; Map temp = Map.from(indexController.currentAction[0][0]); indexController.currentAction.clear(); - print("---temp---${temp}"); + //print("---temp---${temp}"); indexController.currentAction.add([temp]); } indexController.makeAction(context); diff --git a/lib/widgets/map_widget.dart b/lib/widgets/map_widget.dart index 609312b..fb90c46 100644 --- a/lib/widgets/map_widget.dart +++ b/lib/widgets/map_widget.dart @@ -57,7 +57,7 @@ class MapWidget extends StatelessWidget { //center: LatLng(37.15319600454702, 139.58765950528198), bounds: indexController.currentBound.length > 0 ? indexController.currentBound[0]: LatLngBounds.fromPoints([LatLng(35.03999881162295, 136.40587119778962), LatLng(36.642756778706904, 137.95226720406063)]), zoom: 1, - maxZoom: 20, + maxZoom: 24, interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag, plugins: [ MarkerClusterPlugin(), diff --git a/lib/widgets/perfecture_widget.dart b/lib/widgets/perfecture_widget.dart index d3b3293..4583095 100644 --- a/lib/widgets/perfecture_widget.dart +++ b/lib/widgets/perfecture_widget.dart @@ -105,7 +105,7 @@ class _PerfectureWidgetState extends State { //print("--------cats ------############### ${widget.indexController.cats.toString()} -------------"); for(dynamic d in widget.indexController.cats){ - print("-------- ddd ------############### ${d} --------dddd-----"); + //print("-------- ddd ------############### ${d} --------dddd-----"); var newDropdown = DropdownMenuItem(child: Text(d['category'].toString()), value: d['category'].toString()); //print("--------cats ------############### ${d['category'].toString()} -------------"); dropDownItems.add(newDropdown); @@ -187,10 +187,11 @@ class _PerfectureWidgetState extends State { onChanged: (String? newValue) { setState(() { if(newValue != null){ - widget.indexController.is_loading.value = true; - widget.indexController.populateForSubPerf(newValue, widget.mapController); + //widget.indexController.is_loading.value = true; + //widget.indexController.populateForSubPerf(newValue, widget.mapController); //widget.indexController.loadLocationforSubPerf(newValue, widget.mapController); - //widget.indexController.subDropdownValue = newValue; + widget.indexController.subDropdownValue = newValue; + widget.indexController.loadCatForCity(newValue); } }); }, @@ -199,6 +200,7 @@ class _PerfectureWidgetState extends State { ) : const Text(""), //CatWidget(indexController: widget.indexController,), + widget.indexController.cats.length > 0 ? DropdownButton( value: widget.indexController.cateogory, icon: const Icon(Icons.arrow_downward), @@ -213,7 +215,10 @@ class _PerfectureWidgetState extends State { setState(() { if(newValue != null){ widget.indexController.is_loading.value = true; - widget.indexController.populateForSubPerf(newValue, widget.mapController); + widget.indexController.cateogory = newValue; + widget.indexController.currentCat.clear(); + widget.indexController.currentCat.add(newValue); + widget.indexController.populateForSubPerf(widget.indexController.subDropdownValue, widget.mapController); //widget.indexController.loadLocationforSubPerf(newValue, widget.mapController); //widget.indexController.subDropdownValue = newValue; } @@ -222,6 +227,8 @@ class _PerfectureWidgetState extends State { items: getCategory(), ) + : + Container(), ], ),