update
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:flutter_map/plugin_api.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
@ -22,7 +25,6 @@ class IndexController extends GetxController {
|
||||
|
||||
List<Map<String, dynamic>> currentUser = <Map<String, dynamic>>[].obs;
|
||||
List<dynamic> currentAction = <dynamic>[].obs;
|
||||
|
||||
|
||||
var is_loading = false.obs;
|
||||
|
||||
@ -47,20 +49,19 @@ class IndexController extends GetxController {
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
if(locations.length == 0){
|
||||
LocationService.loadLocations().then((value){
|
||||
locations.add(value!);
|
||||
//print(value);
|
||||
});
|
||||
}
|
||||
// if(locations.length == 0){
|
||||
// LocationService.loadLocations().then((value){
|
||||
// locations.add(value!);
|
||||
// //print(value);
|
||||
// });
|
||||
// }
|
||||
if(perfectures.length == 0){
|
||||
PerfectureService.loadPerfectures().then((value){
|
||||
perfectures.add(value);
|
||||
loadSubPerfFor("9");
|
||||
});
|
||||
}
|
||||
loadCats();
|
||||
|
||||
}
|
||||
//loadCats();
|
||||
}
|
||||
|
||||
void login(String email, String password, BuildContext context){
|
||||
@ -112,25 +113,51 @@ class IndexController extends GetxController {
|
||||
|
||||
}
|
||||
|
||||
void loadCats(){
|
||||
// void loadCats(){
|
||||
// dynamic initVal = {'category':'---'};
|
||||
// CatService.loadCats().then((value) {
|
||||
// //value!.add(initVal);
|
||||
// print("###########");
|
||||
// print(value);
|
||||
// cats.add(value);
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
|
||||
void loadCatsv2(){
|
||||
dynamic initVal = {'category':'---'};
|
||||
CatService.loadCats().then((value) {
|
||||
//value!.add(initVal);
|
||||
print("###########");
|
||||
print(value);
|
||||
cats.add(value);
|
||||
});
|
||||
LatLngBounds bounds = mapController!.bounds!;
|
||||
if(bounds.southEast != null && bounds.southWest != null && bounds.northEast != null && bounds.southEast != null ){
|
||||
cats.clear();
|
||||
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) {
|
||||
print("###########");
|
||||
print(value);
|
||||
cats.add(value);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void refreshLocationForCat(){
|
||||
if(subDropdownValue == "-1"){
|
||||
LocationService.loadLocationsFor(dropdownValue, currentCat[0]);
|
||||
print("loading main------");
|
||||
}
|
||||
else{
|
||||
LocationService.loadLocationsSubFor(subDropdownValue, currentCat[0]);
|
||||
print("loading sub------");
|
||||
}
|
||||
loadLocationsBound();
|
||||
// if(subDropdownValue == "-1"){
|
||||
// LocationService.loadLocationsFor(dropdownValue, currentCat[0]).then((value){
|
||||
// locations.clear();
|
||||
// locations.add(value!);
|
||||
// is_loading.value = false;
|
||||
// });
|
||||
// print("loading main------");
|
||||
// }
|
||||
// else{
|
||||
// LocationService.loadLocationsSubFor(subDropdownValue, currentCat[0]).then((value){
|
||||
// locations.clear();
|
||||
// locations.add(value!);
|
||||
// is_loading.value = false;
|
||||
// });
|
||||
// print("loading sub------");
|
||||
// }
|
||||
}
|
||||
|
||||
void loadSubPerfFor(String perf){
|
||||
@ -158,18 +185,48 @@ class IndexController extends GetxController {
|
||||
}
|
||||
|
||||
void loadLocationforPerf(String perf, MapController mapController) async {
|
||||
String cat = currentCat.isNotEmpty == true ? currentCat[0] : "";
|
||||
print(currentCat);
|
||||
// LocationService.loadLocationsFor(perf, cat).then((value){
|
||||
// locations.clear();
|
||||
// locations.add(value!);
|
||||
// mapController.fitBounds(currentBound[0]);
|
||||
// });
|
||||
locations.clear();
|
||||
LocationService.loadLocationsFor(perf, currentCat[0]).then((value){
|
||||
mapController.fitBounds(currentBound[0]);
|
||||
}
|
||||
|
||||
void loadLocationforSubPerf(String subperf, MapController mapController) async {
|
||||
String cat = currentCat.isNotEmpty == true ? currentCat[0] : "";
|
||||
print(currentCat);
|
||||
LocationService.loadLocationsSubFor(subperf, cat).then((value){
|
||||
locations.clear();
|
||||
locations.add(value!);
|
||||
mapController.fitBounds(currentBound[0]);
|
||||
});
|
||||
}
|
||||
|
||||
void loadLocationforSubPerf(String subperf, MapController mapController) async {
|
||||
locations.clear();
|
||||
LocationService.loadLocationsSubFor(subperf, currentCat[0]).then((value){
|
||||
locations.add(value!);
|
||||
});
|
||||
void loadLocationsBound(){
|
||||
String cat = currentCat.isNotEmpty ? currentCat[0] : "";
|
||||
LatLngBounds bounds = mapController!.bounds!;
|
||||
print(currentCat);
|
||||
if(bounds.southEast != null && bounds.southWest != null && bounds.northEast != null && bounds.southEast != null ){
|
||||
LocationService.loadLocationsBound(bounds.southWest!.latitude, bounds.southWest!.longitude, bounds.northWest.latitude, bounds.northWest.longitude, bounds.northEast!.latitude, bounds.northEast!.longitude, bounds.southEast.latitude, bounds.southEast.longitude, cat).then((value){
|
||||
print("---value length ------ ${value!.collection.length}");
|
||||
if(value == null){
|
||||
return;
|
||||
}
|
||||
if(value != null && value.collection.isEmpty){
|
||||
Get.showSnackbar(GetSnackBar(message: "Too many points, please zoom in",));
|
||||
}
|
||||
if(value != null && value.collection.isNotEmpty){
|
||||
print("---- added---");
|
||||
locations.clear();
|
||||
locations.add(value);
|
||||
loadCatsv2();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void setBound(LatLngBounds bounds){
|
||||
@ -206,12 +263,14 @@ class IndexController extends GetxController {
|
||||
loadSubPerfFor(perf);
|
||||
loadLocationforPerf(perf, mapController);
|
||||
zoomtoMainPerf(perf);
|
||||
is_loading.value = false;
|
||||
}
|
||||
|
||||
void populateForSubPerf(String subperf, MapController mapController){
|
||||
subDropdownValue = subperf;
|
||||
loadLocationforSubPerf(subperf, mapController);
|
||||
zoomtoSubPerf(subperf);
|
||||
is_loading.value = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import 'package:get/get.dart';
|
||||
import 'package:rogapp/pages/drawer/drawer_page.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/services/maxtrix_service.dart';
|
||||
import 'package:rogapp/widgets/bread_crum_widget.dart';
|
||||
import 'package:rogapp/widgets/cat_widget.dart';
|
||||
import 'package:rogapp/widgets/list_widget.dart';
|
||||
@ -72,7 +73,20 @@ class IndexPage extends GetView<IndexController> {
|
||||
BreadCrumbWidget(),
|
||||
Container(width: 24.0,),
|
||||
Obx(()=>
|
||||
indexController.currentCat.isNotEmpty ? Text(indexController.currentCat[0].toString()): Text("")
|
||||
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,)
|
||||
],
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user