update
This commit is contained in:
@ -21,6 +21,7 @@ class IndexController extends GetxController {
|
||||
List<LatLngBounds> currentBound = <LatLngBounds>[].obs;
|
||||
List<dynamic> subPerfs = <dynamic>[].obs;
|
||||
List<dynamic> areas = <dynamic>[].obs;
|
||||
List<dynamic> customAreas = <dynamic>[].obs;
|
||||
List<dynamic> cats = <dynamic>[].obs;
|
||||
|
||||
List<String> currentCat = <String>[].obs;
|
||||
@ -36,6 +37,8 @@ class IndexController extends GetxController {
|
||||
|
||||
var mode = 0.obs;
|
||||
|
||||
var rog_mode = 0.obs;
|
||||
|
||||
var desination_mode = 0.obs;
|
||||
|
||||
|
||||
@ -43,6 +46,8 @@ class IndexController extends GetxController {
|
||||
String subDropdownValue = "-1";
|
||||
String areaDropdownValue = "-1";
|
||||
|
||||
late Worker _ever;
|
||||
|
||||
void toggleMode(){
|
||||
if(mode.value==0){
|
||||
mode += 1;
|
||||
@ -61,9 +66,33 @@ class IndexController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
void switchPage(String page){
|
||||
//print("######## ${currentUser[0]["user"]["id"]}");
|
||||
switch (page) {
|
||||
case AppPages.INITIAL :{
|
||||
rog_mode.value = 0;
|
||||
Get.toNamed(page);
|
||||
}
|
||||
break;
|
||||
case AppPages.TRAVEL : {
|
||||
rog_mode.value = 1;
|
||||
Get.toNamed(page);
|
||||
}
|
||||
break;
|
||||
case AppPages.LOGIN :{
|
||||
rog_mode.value = 2;
|
||||
Get.toNamed(page);
|
||||
}
|
||||
break;
|
||||
default:{
|
||||
rog_mode.value = 0;
|
||||
Get.toNamed(AppPages.INITIAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
// if(locations.length == 0){
|
||||
// LocationService.loadLocations().then((value){
|
||||
@ -71,23 +100,59 @@ class IndexController extends GetxController {
|
||||
// //print(value);
|
||||
// });
|
||||
// }
|
||||
|
||||
_ever = ever(rog_mode, (_) => print("$_ has been changed (ever)"));
|
||||
|
||||
if(perfectures.length == 0){
|
||||
PerfectureService.loadPerfectures().then((value){
|
||||
perfectures.add(value);
|
||||
loadAreaFor("9");
|
||||
|
||||
//loadSubPerfFor("9");
|
||||
});
|
||||
}
|
||||
//loadCats();
|
||||
}
|
||||
}
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
void login(String email, String password, BuildContext context){
|
||||
|
||||
LatLngBounds boundsFromLatLngList(List<LatLng> list) {
|
||||
double? x0, x1, y0, y1;
|
||||
for (LatLng latLng in list) {
|
||||
if (x0 == null || x1 == null || y0 == null || y1 == null) {
|
||||
x0 = x1 = latLng.latitude;
|
||||
y0 = y1 = latLng.longitude;
|
||||
} else {
|
||||
if (latLng.latitude > x1) x1 = latLng.latitude;
|
||||
if (latLng.latitude < x0) x0 = latLng.latitude;
|
||||
if (latLng.longitude > y1) y1 = latLng.longitude;
|
||||
if (latLng.longitude < y0) y0 = latLng.longitude;
|
||||
}
|
||||
}
|
||||
|
||||
return LatLngBounds(LatLng(x1!, y1!), LatLng(x0!, y0!));
|
||||
}
|
||||
|
||||
|
||||
List<LatLng> getLocationsList(){
|
||||
List<LatLng> locs = [];
|
||||
for(int i=0; i<= locations[0].collection.length - 1; i++){
|
||||
GeoJsonMultiPoint p = locations[0].collection[i].geometry as GeoJsonMultiPoint;
|
||||
|
||||
LatLng latLng = LatLng(p.geoSerie!.geoPoints[0].latitude, p.geoSerie!.geoPoints[0].longitude);
|
||||
locs.add(latLng);
|
||||
}
|
||||
return locs;
|
||||
}
|
||||
|
||||
|
||||
void login(String email, String password, BuildContext context){
|
||||
AuthService.login(email, password).then((value){
|
||||
if(value.isNotEmpty){
|
||||
currentUser.clear();
|
||||
currentUser.add(value);
|
||||
is_loading.value = false;
|
||||
Navigator.pop(context);
|
||||
loadUserDetails();
|
||||
if(currentFeature.isNotEmpty){
|
||||
getAction();
|
||||
}
|
||||
@ -107,6 +172,7 @@ class IndexController extends GetxController {
|
||||
currentUser.add(value);
|
||||
is_loading.value = false;
|
||||
Navigator.pop(context);
|
||||
loadUserDetails();
|
||||
Get.toNamed(AppPages.INITIAL);
|
||||
}else{
|
||||
is_loading.value = false;
|
||||
@ -121,26 +187,13 @@ class IndexController extends GetxController {
|
||||
bool wanttogo = currentAction[0][0]["wanttogo"];
|
||||
bool like = currentAction[0][0]["like"];
|
||||
bool checkin = currentAction[0][0]["checkin"];
|
||||
print("----userid----${user_id}");
|
||||
if(user_id > 0){
|
||||
ActionService.makeAction(user_id, location_id, wanttogo, like, checkin).then((value){
|
||||
print("----action value----${value}");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// void loadCats(){
|
||||
// dynamic initVal = {'category':'---'};
|
||||
// CatService.loadCats().then((value) {
|
||||
// //value!.add(initVal);
|
||||
// print("###########");
|
||||
// print(value);
|
||||
// cats.add(value);
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
|
||||
void loadCatsv2(){
|
||||
dynamic initVal = {'category':'---'};
|
||||
@ -148,7 +201,6 @@ class IndexController extends GetxController {
|
||||
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);
|
||||
});
|
||||
@ -181,11 +233,30 @@ class IndexController extends GetxController {
|
||||
areas.clear();
|
||||
dynamic initVal = {'id':'-1', 'adm2_ja':'----'};
|
||||
PerfectureService.loadGifuAreas(perf).then((value){
|
||||
print(value);
|
||||
value!.add(initVal);
|
||||
areas.add(value);
|
||||
//loadSubPerfFor("9");
|
||||
//subDropdownValue = getSubInitialVal();
|
||||
});
|
||||
}
|
||||
|
||||
void loadUserDetails(){
|
||||
if(currentUser.length > 0){
|
||||
int user_id = currentUser[0]["user"]["id"] as int;
|
||||
AuthService.UserDetails(user_id).then((value){
|
||||
//print("--------- user details ----- ${value}");
|
||||
bool paid = value![0]["paid"] as bool;
|
||||
if(paid){
|
||||
loadCustomAreas();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void loadCustomAreas(){
|
||||
customAreas.clear();
|
||||
PerfectureService.loadCustomAreas().then((value){
|
||||
print("--- loading custom areas ${value}");
|
||||
customAreas.add(value);
|
||||
});
|
||||
}
|
||||
|
||||
@ -235,12 +306,20 @@ class IndexController extends GetxController {
|
||||
});
|
||||
}
|
||||
|
||||
void loadCustomLocation(String customarea, MapController mapController) async {
|
||||
void loadCustomLocation(String customarea) async {
|
||||
String cat = currentCat.isNotEmpty == true ? currentCat[0] : "";
|
||||
print(currentCat);
|
||||
LocationService.loadCustomLocations(cat).then((value){
|
||||
print("----- ${customarea}");
|
||||
LocationService.loadCustomLocations(customarea, cat).then((value){
|
||||
locations.clear();
|
||||
locations.add(value!);
|
||||
List<LatLng> locs = getLocationsList();
|
||||
LatLngBounds bounds = boundsFromLatLngList(locs);
|
||||
mapController!.fitBounds(bounds);
|
||||
setBound(bounds);
|
||||
Future.delayed(Duration(microseconds: 400), () {
|
||||
mapController!.fitBounds(bounds);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -312,8 +391,9 @@ class IndexController extends GetxController {
|
||||
is_loading.value = false;
|
||||
}
|
||||
|
||||
void populateForCustomArea(String customarea, MapController mapController){
|
||||
loadCustomLocation("cus", mapController);
|
||||
void populateSubPerForArea(String area, MapController mapController){
|
||||
loadSubPerfFor(area);
|
||||
//loadCustomLocation("cus", mapController);
|
||||
//zoomtoSubPerf(subperf);
|
||||
is_loading.value = false;
|
||||
}
|
||||
@ -337,6 +417,7 @@ class IndexController extends GetxController {
|
||||
return;
|
||||
}
|
||||
int user_id = currentUser[0]["user"]["id"] as int;
|
||||
print("---- loc id ${currentFeature[0].properties}");
|
||||
int location_id = currentFeature[0].properties!["location_id"] as int;
|
||||
ActionService.userAction(user_id, location_id).then((value){
|
||||
print("------${value}");
|
||||
|
||||
@ -37,10 +37,12 @@ class IndexPage extends GetView<IndexController> {
|
||||
const Expanded(child: Text('')),
|
||||
Expanded(child: IconButton(icon: const Icon(Icons.travel_explore), onPressed: (){
|
||||
if(indexController.currentUser.isNotEmpty){
|
||||
Get.toNamed(AppPages.TRAVEL);
|
||||
indexController.switchPage(AppPages.TRAVEL);
|
||||
//Get.toNamed(AppPages.TRAVEL);
|
||||
}
|
||||
else{
|
||||
Get.toNamed(AppPages.LOGIN);
|
||||
indexController.switchPage(AppPages.LOGIN);
|
||||
//Get.toNamed(AppPages.LOGIN);
|
||||
}
|
||||
}),),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user