diff --git a/assets/images/A.png b/assets/images/A.png new file mode 100644 index 0000000..246b9d2 Binary files /dev/null and b/assets/images/A.png differ diff --git a/assets/images/b.png b/assets/images/b.png new file mode 100644 index 0000000..b22f96c Binary files /dev/null and b/assets/images/b.png differ diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index bbd72a5..d75847c 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -2,6 +2,7 @@ import UIKit import Flutter import FirebaseCore import GoogleMaps +import Constants @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { @@ -10,7 +11,7 @@ import GoogleMaps _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { - GMSServices.provideAPIKey("AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0") + GMSServices.provideAPIKey(mapsApiKey) FirebaseApp.configure() GeneratedPluginRegistrant.register(with: self) return true diff --git a/ios/Runner/Constants.swift b/ios/Runner/Constants.swift new file mode 100644 index 0000000..8085844 --- /dev/null +++ b/ios/Runner/Constants.swift @@ -0,0 +1 @@ +let mapsApiKey = "AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0" \ No newline at end of file diff --git a/lib/controller/home/map_passenger_controller.dart b/lib/controller/home/map_passenger_controller.dart index 031b4aa..8b97044 100644 --- a/lib/controller/home/map_passenger_controller.dart +++ b/lib/controller/home/map_passenger_controller.dart @@ -8,6 +8,7 @@ import 'package:google_polyline_algorithm/google_polyline_algorithm.dart'; import 'package:location/location.dart'; import 'package:ride/constant/colors.dart'; import 'package:ride/constant/style.dart'; +import 'package:ride/controller/home/points_for_rider_controller.dart'; import 'package:ride/views/home/map_page_passenger.dart'; import 'package:ride/views/home/map_widget.dart/form_serch_multiy_point.dart'; import '../../constant/api_key.dart'; @@ -77,6 +78,8 @@ class MapPassengerController extends GetxController { List driverCarsLocationToPassengerAfterApplied = []; BitmapDescriptor markerIcon = BitmapDescriptor.defaultMarker; BitmapDescriptor tripIcon = BitmapDescriptor.defaultMarker; + BitmapDescriptor startIcon = BitmapDescriptor.defaultMarker; + BitmapDescriptor endIcon = BitmapDescriptor.defaultMarker; BitmapDescriptor carIcon = BitmapDescriptor.defaultMarker; double height = 150; DateTime currentTime = DateTime.now(); @@ -170,6 +173,7 @@ class MapPassengerController extends GetxController { List currentLocationToFormPlacesAll = []; late String driverToken; int carsOrder = 0; + int wayPointIndex = 0; String? mapAPIKEY; late double totalME = 0; late double tax = 0; @@ -873,25 +877,22 @@ class MapPassengerController extends GetxController { } void changeMainBottomMenuMap() { - print(isWayPointStopsSheetUtilGetMap); - if (isWayPointStopsSheetUtilGetMap == true) { - isWayPointSheet = true; - wayPointSheetHeight = isWayPointSheet == false ? 0 : Get.height * .4; - update(); - } else { - isMainBottomMenuMap = !isMainBottomMenuMap; - mainBottomMenuMapHeight = - isMainBottomMenuMap == true ? Get.height * .2 : Get.height * .7; - if (heightMenuBool == true) { - getDrawerMenu(); - } - update(); + // else { + isMainBottomMenuMap = !isMainBottomMenuMap; + mainBottomMenuMapHeight = + isMainBottomMenuMap == true ? Get.height * .2 : Get.height * .7; + isWayPointSheet = false; + if (heightMenuBool == true) { + getDrawerMenu(); } + + update(); + // } } void changeWayPointSheet() { isWayPointSheet = !isWayPointSheet; - wayPointSheetHeight = isWayPointSheet == false ? 0 : Get.height * .4; + wayPointSheetHeight = isWayPointSheet == false ? 0 : Get.height * .45; // if (heightMenuBool == true) { // getDrawerMenu(); // } @@ -899,9 +900,14 @@ class MapPassengerController extends GetxController { } void changeWayPointStopsSheet() { - isWayPointStopsSheetUtilGetMap = true; + int waypointsLength = Get.find().wayPoints.length; + print('isWayPointStopsSheet $waypointsLength'); + if (waypointsLength > 2) { + isWayPointStopsSheet = true; + isWayPointStopsSheetUtilGetMap = true; + } isWayPointStopsSheet = !isWayPointStopsSheet; - wayPointSheetHeight = isWayPointStopsSheet == false ? 0 : Get.height * .4; + wayPointSheetHeight = isWayPointStopsSheet == false ? 0 : Get.height * .45; // if (heightMenuBool == true) { // getDrawerMenu(); // } @@ -1082,13 +1088,24 @@ class MapPassengerController extends GetxController { }); } - void addCustomTripIcon() { + void addCustomStartIcon() { ImageConfiguration config = ImageConfiguration( size: Size(Get.width * .6, Get.height * .6), ); - BitmapDescriptor.fromAssetImage(config, 'assets/images/brand.png') + BitmapDescriptor.fromAssetImage(config, 'assets/images/A.png') .then((value) { - tripIcon = value; + startIcon = value; + update(); + }); + } + + void addCustomEndIcon() { + ImageConfiguration config = ImageConfiguration( + size: Size(Get.width * .6, Get.height * .6), + ); + BitmapDescriptor.fromAssetImage(config, 'assets/images/b.png') + .then((value) { + endIcon = value; update(); }); } @@ -1395,14 +1412,14 @@ class MapPassengerController extends GetxController { } int totalStepDurations = 0; - getMapPoints(String origin, destination, int index) async { + getMapPoints(String origin, String destination, int index) async { isWayPointStopsSheetUtilGetMap = false; await getCarsLocationByPassenger(); isLoading = false; update(); var url = ('${AppLink.googleMapsLink}directions/json?&language=en&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AK.mapAPIKEY}'); - + print(url); var response = await CRUD().getGoogleApi(link: url, payload: {}); data = response['routes'][0]['legs']; // print(data); @@ -1676,7 +1693,8 @@ class MapPassengerController extends GetxController { getNearestDriverByPassengerLocation(); addCustomPicker(); addCustomCarIcon(); - addCustomTripIcon(); + addCustomStartIcon(); + addCustomEndIcon(); startMarkerReloading(); cardNumber = await SecureStorage().readData(BoxName.cardNumber); diff --git a/lib/views/home/map_widget.dart/form_serch_multiy_point.dart b/lib/views/home/map_widget.dart/form_serch_multiy_point.dart index b1c6b4d..f86c483 100644 --- a/lib/views/home/map_widget.dart/form_serch_multiy_point.dart +++ b/lib/views/home/map_widget.dart/form_serch_multiy_point.dart @@ -58,6 +58,8 @@ GetBuilder formSearchPlaces(int index) { ? InkWell( onTap: () { controller.startLocationFromMapAll[index] = true; + controller.wayPointIndex = index; + print(controller.wayPointIndex); Get.back(); // controller.changeMainBottomMenuMap(); controller.changeWayPointStopsSheet(); diff --git a/lib/views/home/map_widget.dart/google_map_passenger_widget.dart b/lib/views/home/map_widget.dart/google_map_passenger_widget.dart index f75f8c1..cb36096 100644 --- a/lib/views/home/map_widget.dart/google_map_passenger_widget.dart +++ b/lib/views/home/map_widget.dart/google_map_passenger_widget.dart @@ -152,7 +152,7 @@ class GoogleMapPassengerWidget extends StatelessWidget { markerId: MarkerId('MyLocation'.tr), position: controller.newStartPointLocation, draggable: true, - icon: controller.tripIcon, + icon: controller.startIcon, infoWindow: const InfoWindow( title: 'Time', // snippet: controller.durationFromDriverToPassenger @@ -167,12 +167,14 @@ class GoogleMapPassengerWidget extends StatelessWidget { markerId: MarkerId('Destination'.tr), position: controller.newMyLocation, draggable: true, - icon: controller.tripIcon, - infoWindow: const InfoWindow( - title: 'Time', - // snippet: controller.durationFromDriverToPassenger - // .toString(), - ), + icon: controller.endIcon, + infoWindow: InfoWindow( + anchor: const Offset(0.5, 0), + title: 'Time', + snippet: controller.durationByPassenger.toString() + // snippet: controller.durationFromDriverToPassenger + // .toString(), + ), onDragEnd: (value) { print(value); }, @@ -295,6 +297,13 @@ class GoogleMapPassengerWidget extends StatelessWidget { buildingsEnabled: true, mapToolbarEnabled: true, onCameraMove: (position) { + int waypointsLength = + Get.find().wayPoints.length; + int index = controller.wayPointIndex; + if (waypointsLength > 0) { + controller.placesCoordinate[index] = + '${position.target.latitude.toString()},${position.target.longitude}'; + } if (controller.startLocationFromMap == true) { controller.newStartPointLocation = position.target; }