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

View File

@ -20,7 +20,6 @@ class _ListWidgetState extends State<ListWidget> {
final IndexController indexController = Get.find<IndexController>();
final DestinationController destinationController = Get.find<DestinationController>();
List<Destination> destList = [];
Image getImage(int index){
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);
}
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
void 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 {
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"];
//print("matrix result is ${i} : ${res["routes"][0]["legs"][0]["distance"]["text"]} ");
}
Future<void> _pullRefresh() async {
print("pull to refesh");
setState(() {
indexController.locations[0].collection.sort((a, b) =>
(a.properties!['cp'] as Comparable)
.compareTo(b.properties!['cp'] as Comparable));
setState(() {
});
// why use freshNumbers var? https://stackoverflow.com/a/52992836/2301224
}
@override