fixed distance Mx

This commit is contained in:
Mohamed Nouffer
2023-06-14 11:27:11 +05:30
parent 6c8ac75b19
commit 3e06c4cd7f
2 changed files with 113 additions and 116 deletions

View File

@ -547,102 +547,102 @@ class BottomSheetNew extends GetView<BottomSheetController> {
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
indexController.rog_mode == 0 ? // indexController.rog_mode == 0 ?
IconButton( // // IconButton(
icon: Icon(Icons.pin_drop_sharp, size: 32, color: _selected == true ? Colors.amber : Colors.blue,), // // icon: Icon(Icons.pin_drop_sharp, size: 32, color: _selected == true ? Colors.amber : Colors.blue,),
onPressed: (){ // // onPressed: (){
if(_selected){ // // if(_selected){
// show remove from destination // // // show remove from destination
Get.defaultDialog( // // Get.defaultDialog(
title: "本当にこのポイントを通過順から外しますか?", // // title: "本当にこのポイントを通過順から外しますか?",
middleText: "場所は目的地リストから削除されます", // // middleText: "場所は目的地リストから削除されます",
backgroundColor: Colors.blue.shade300, // // backgroundColor: Colors.blue.shade300,
titleStyle: TextStyle(color: Colors.white), // // titleStyle: TextStyle(color: Colors.white),
middleTextStyle: TextStyle(color: Colors.white), // // middleTextStyle: TextStyle(color: Colors.white),
textConfirm: "はい", // // textConfirm: "はい",
textCancel: "いいえ", // // textCancel: "いいえ",
cancelTextColor: Colors.white, // // cancelTextColor: Colors.white,
confirmTextColor: Colors.blue, // // confirmTextColor: Colors.blue,
buttonColor: Colors.white, // // buttonColor: Colors.white,
barrierDismissible: false, // // barrierDismissible: false,
radius: 10, // // radius: 10,
content: Column( // // content: Column(
children: [ // // children: [
], // // ],
), // // ),
onConfirm: (){ // // onConfirm: (){
int _id = indexController.currentFeature[0].properties!["location_id"]; // // int _id = indexController.currentFeature[0].properties!["location_id"];
Destination? d = destinationController.destinationById(_id); // // Destination? d = destinationController.destinationById(_id);
print('--- des id is : ${d} -----'); // // print('--- des id is : ${d} -----');
if(d != null) { // // if(d != null) {
//print('--- des id is : ${d.location_id} -----'); // // //print('--- des id is : ${d.location_id} -----');
destinationController.deleteDestination(d); // // destinationController.deleteDestination(d);
Get.back(); // // Get.back();
Get.back(); // // Get.back();
Get.snackbar("追加した", "場所が削除されました"); // // Get.snackbar("追加した", "場所が削除されました");
} // // }
} // // }
); // // );
return; // // return;
} // // }
// show add to destination // // // show add to destination
Get.defaultDialog( // // Get.defaultDialog(
title: "この場所を登録してもよろしいですか", // // title: "この場所を登録してもよろしいですか",
middleText: "ロケーションがロガニング リストに追加されます", // // middleText: "ロケーションがロガニング リストに追加されます",
backgroundColor: Colors.blue.shade300, // // backgroundColor: Colors.blue.shade300,
titleStyle: TextStyle(color: Colors.white), // // titleStyle: TextStyle(color: Colors.white),
middleTextStyle: TextStyle(color: Colors.white), // // middleTextStyle: TextStyle(color: Colors.white),
textConfirm: "はい", // // textConfirm: "はい",
textCancel: "いいえ", // // textCancel: "いいえ",
cancelTextColor: Colors.white, // // cancelTextColor: Colors.white,
confirmTextColor: Colors.blue, // // confirmTextColor: Colors.blue,
buttonColor: Colors.white, // // buttonColor: Colors.white,
barrierDismissible: false, // // barrierDismissible: false,
radius: 10, // // radius: 10,
content: Column( // // content: Column(
children: [ // // children: [
], // // ],
), // // ),
onConfirm: (){ // // onConfirm: (){
GeoJsonMultiPoint mp = indexController.currentFeature[0].geometry as GeoJsonMultiPoint; // // GeoJsonMultiPoint mp = indexController.currentFeature[0].geometry as GeoJsonMultiPoint;
LatLng pt = LatLng(mp.geoSerie!.geoPoints[0].latitude, mp.geoSerie!.geoPoints[0].longitude); // // LatLng pt = LatLng(mp.geoSerie!.geoPoints[0].latitude, mp.geoSerie!.geoPoints[0].longitude);
print("----- want to go sub location is ---- ${indexController.currentFeature[0].properties!["sub_loc_id"]} -----"); // // print("----- want to go sub location is ---- ${indexController.currentFeature[0].properties!["sub_loc_id"]} -----");
Destination dest = Destination( // // Destination dest = Destination(
name: indexController.currentFeature[0].properties!["location_name"], // // name: indexController.currentFeature[0].properties!["location_name"],
address: indexController.currentFeature[0].properties!["address"], // // address: indexController.currentFeature[0].properties!["address"],
phone: indexController.currentFeature[0].properties!["phone"], // // phone: indexController.currentFeature[0].properties!["phone"],
email: indexController.currentFeature[0].properties!["email"], // // email: indexController.currentFeature[0].properties!["email"],
webcontents: indexController.currentFeature[0].properties!["webcontents"], // // webcontents: indexController.currentFeature[0].properties!["webcontents"],
videos: indexController.currentFeature[0].properties!["videos"], // // videos: indexController.currentFeature[0].properties!["videos"],
category: indexController.currentFeature[0].properties!["category"], // // category: indexController.currentFeature[0].properties!["category"],
series: 1, // // series: 1,
lat: pt.latitude, // // lat: pt.latitude,
lon: pt.longitude, // // lon: pt.longitude,
sub_loc_id: indexController.currentFeature[0].properties!["sub_loc_id"], // // sub_loc_id: indexController.currentFeature[0].properties!["sub_loc_id"],
location_id: indexController.currentFeature[0].properties!["location_id"], // // location_id: indexController.currentFeature[0].properties!["location_id"],
list_order: 1, // // list_order: 1,
photos: indexController.currentFeature[0].properties!["photos"], // // photos: indexController.currentFeature[0].properties!["photos"],
checkin_radious: indexController.currentFeature[0].properties!["checkin_radius"], // // checkin_radious: indexController.currentFeature[0].properties!["checkin_radius"],
auto_checkin: indexController.currentFeature[0].properties!["auto_checkin"] == true ? 1 : 0, // // auto_checkin: indexController.currentFeature[0].properties!["auto_checkin"] == true ? 1 : 0,
cp: indexController.currentFeature[0].properties!["cp"], // // cp: indexController.currentFeature[0].properties!["cp"],
checkin_point: indexController.currentFeature[0].properties!["checkin_point"], // // checkin_point: indexController.currentFeature[0].properties!["checkin_point"],
buy_point: indexController.currentFeature[0].properties!["buy_point"], // // buy_point: indexController.currentFeature[0].properties!["buy_point"],
selected: false, // // selected: false,
checkedin: false, // // checkedin: false,
hidden_location: indexController.currentFeature[0].properties!["hidden_location"] == true ?1 : 0 // // hidden_location: indexController.currentFeature[0].properties!["hidden_location"] == true ?1 : 0
); // // );
destinationController.addDestinations(dest); // // destinationController.addDestinations(dest);
Get.back(); // // Get.back();
Get.back(); // // Get.back();
Get.snackbar("追加した", "場所が追加されました"); // // Get.snackbar("追加した", "場所が追加されました");
} // // }
); // // );
}, // // },
): // // ):
Container(), // // Container(),
SizedBox(width: 8.0,) , SizedBox(width: 8.0,) ,
Obx((() => Obx((() =>

View File

@ -20,7 +20,6 @@ class _ListWidgetState extends State<ListWidget> {
final IndexController indexController = Get.find<IndexController>(); final IndexController indexController = Get.find<IndexController>();
final DestinationController destinationController = Get.find<DestinationController>(); final DestinationController destinationController = Get.find<DestinationController>();
List<Destination> destList = [];
Image getImage(int index){ Image getImage(int index){
if(indexController.locations[0].collection[index].properties!["photos"] == null || indexController.locations[0].collection[index].properties!["photos"] == ""){ if(indexController.locations[0].collection[index].properties!["photos"] == null || indexController.locations[0].collection[index].properties!["photos"] == ""){
@ -49,43 +48,41 @@ class _ListWidgetState extends State<ListWidget> {
indexController.currentFeature.add(fs); indexController.currentFeature.add(fs);
} }
void getDestinationCoords() {
Destination cdes = Destination(lat: indexController.current_lat, lon: indexController.current_lon);
List<Destination> dest = [cdes];
for(int k=0; k < indexController.locations[0].collection.length; k++){
GeoJsonMultiPoint _pt = indexController.locations[0].collection[k].geometry;
final de = Destination(
lat: _pt.geoSerie!.geoPoints.first.latitude,
lon: _pt.geoSerie!.geoPoints.first.longitude,
);
//print("---dest a is: ${dest} ---");
dest.insert(0, de);
}
destList.assignAll(dest);
//print("--- dest is: ${dest} ---");
}
@override @override
void initState() { void initState() {
super.initState(); super.initState();
getDestinationCoords(); }
Destination createDestination(GeoJsonFeature feature) {
final props = feature.properties;
GeoJsonMultiPoint _pt = feature.geometry;
return Destination(
cp: props!['cp'],
lat: _pt.geoSerie!.geoPoints.first.latitude,
lon: _pt.geoSerie!.geoPoints.first.longitude,
);
} }
Future<String> matrixDistance(int i) async { Future<String> matrixDistance(int i) async {
final res = await MatrixService.getDestinations(destList.sublist(i, i+2)); // Create two destinations directly from indexController.locations[0].collection
Destination dest1 = createDestination(indexController.locations[0].collection[i]);
Destination dest2 = createDestination(indexController.locations[0].collection[i+1]);
// Get the distance between these two destinations
final res = await MatrixService.getDestinations([dest1, dest2]);
return res["routes"][0]["legs"][0]["distance"]["text"]; return res["routes"][0]["legs"][0]["distance"]["text"];
//print("matrix result is ${i} : ${res["routes"][0]["legs"][0]["distance"]["text"]} "); //print("matrix result is ${i} : ${res["routes"][0]["legs"][0]["distance"]["text"]} ");
} }
Future<void> _pullRefresh() async { Future<void> _pullRefresh() async {
print("pull to refesh"); print("pull to refesh");
setState(() {
indexController.locations[0].collection.sort((a, b) => indexController.locations[0].collection.sort((a, b) =>
(a.properties!['cp'] as Comparable) (a.properties!['cp'] as Comparable)
.compareTo(b.properties!['cp'] as Comparable)); .compareTo(b.properties!['cp'] as Comparable));
setState(() {
}); });
// why use freshNumbers var? https://stackoverflow.com/a/52992836/2301224
} }
@override @override