refactoring
This commit is contained in:
@ -1,14 +1,11 @@
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/model/location.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/services/destination_service.dart';
|
||||
@ -24,10 +21,10 @@ class DestinationController extends GetxController {
|
||||
late LocationSettings locationSettings;
|
||||
|
||||
var destinationCount = 0.obs;
|
||||
List<Destination> destinations = <Destination>[].obs;
|
||||
List<Location> destinations = <Location>[].obs;
|
||||
List<Map<String, dynamic>> destination_index_data = <Map<String, dynamic>>[].obs;
|
||||
|
||||
List<Destination> currentSelectedDestinations = <Destination>[].obs;
|
||||
List<Location> currentSelectedDestinations = <Location>[].obs;
|
||||
|
||||
bool checking_in = false;
|
||||
List<bool> isSelected = [true].obs;
|
||||
@ -42,23 +39,12 @@ class DestinationController extends GetxController {
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
|
||||
|
||||
Future<Destination?> getDEstinationForLatLong(double lat, double long)async {
|
||||
Future<Location?> getDEstinationForLatLong(double lat, double long)async {
|
||||
|
||||
String jjjj = '{"id":1,"type":"Feature","geometry":{"type":"MultiPoint","coordinates":[[136.731357,35.370094]]},"properties":{"location_id":915101,"location_name":"柳津","category":"買い物","zip":"〒501-6100","address":"柳津町字仙右城7696-1"}}';
|
||||
|
||||
for(final d in destinations){
|
||||
// var geom = d["location"]["geometry"];
|
||||
// var props = d["location"]["properties"];
|
||||
// print("--props- ${d["location"]["geometry"]["coordinates"][0][1]}");
|
||||
// List<dynamic> geom_multi = [geom];
|
||||
// Map<String, dynamic> final_geom = {"features":[{"id":d["id"],"type":"Feature", "geometry": geom, "properties": props}]};
|
||||
// //print("----- geom : ${final_geom}");
|
||||
|
||||
// String js = json.encode(final_geom);
|
||||
// //print("---features-- ${js}-----");
|
||||
// GeoJsonFeatureCollection features = await featuresFromGeoJson(js);
|
||||
// GeoJsonMultiPoint p = features.collection[0].geometry as GeoJsonMultiPoint;
|
||||
if(lat == d.lat && long == d.lon){
|
||||
if(lat == d.latitude && long == d.longitude){
|
||||
return d;
|
||||
}
|
||||
}
|
||||
@ -71,56 +57,22 @@ class DestinationController extends GetxController {
|
||||
if(!checking_in)
|
||||
{
|
||||
checking_in = true;
|
||||
double lat = d.lat!;
|
||||
double lon = d.lon!;
|
||||
LatLng p = LatLng(lat, lon);
|
||||
double lat = d.latitude!;
|
||||
double lon = d.longitude!;
|
||||
getDEstinationForLatLong(lat, lon).then((value){
|
||||
var distance = Distance();
|
||||
double dist = distance.as(LengthUnit.Meter, LatLng(lat, lon), LatLng(la, ln));
|
||||
double rad = value!.checkin_radious ?? double.infinity;
|
||||
int rad = value!.checkin_radius! ?? 1000000;
|
||||
bool auto_checkin = value.auto_checkin == 0 ? false : true;
|
||||
|
||||
indexController.currentDestinationFeature.add(value);
|
||||
//indexController.getAction();
|
||||
|
||||
|
||||
if(rad >= dist){
|
||||
if(auto_checkin){
|
||||
makeCheckin(value, true);
|
||||
}
|
||||
else{
|
||||
// showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
// builder:((context) => BottomSheetWidget())
|
||||
// ).whenComplete((){
|
||||
// checking_in = false;
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if(!checking_in){
|
||||
// checking_in = true;
|
||||
// if(rad >= dist){
|
||||
// if(auto_checkin){
|
||||
// if(indexController.currentAction.isNotEmpty){
|
||||
// print(indexController.currentAction[0]);
|
||||
// indexController.currentAction[0][0]["checkin"] = true;
|
||||
// Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
|
||||
// indexController.currentAction.clear();
|
||||
// print("---temp---${temp}");
|
||||
// indexController.currentAction.add([temp]);
|
||||
// }
|
||||
// indexController.makeAction(Get.context!);
|
||||
// }
|
||||
// else{
|
||||
// showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
// builder:((context) => BottomSheetWidget())
|
||||
// ).whenComplete((){
|
||||
// checking_in = false;
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
}
|
||||
@ -128,12 +80,12 @@ class DestinationController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
void makeCheckin(Destination destination, bool action) async {
|
||||
void makeCheckin(Location destination, bool action) async {
|
||||
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ressssss ${action}@@@@@@@@@@@");
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
int res = await db.updateAction(destination, action);
|
||||
|
||||
List<Destination> ddd = await db.getDestinationByLatLon(destination.lat!, destination.lon!);
|
||||
List<Location> ddd = await db.getDestinationByLatLon(destination.lat!, destination.lon!);
|
||||
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ddddd ${ddd[0].checkedin} @@@@@@@@@@@");
|
||||
|
||||
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ressssss ${res}@@@@@@@@@@@");
|
||||
|
||||
Reference in New Issue
Block a user