diff --git a/android/app/build.gradle b/android/app/build.gradle index 9a87acb..af884a1 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -53,7 +53,7 @@ android { applicationId "com.sefer_driver" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. - minSdkVersion 22 + minSdkVersion 23 targetSdkVersion flutter.targetSdkVersion versionCode 30 versionName '1.5.30' diff --git a/lib/controller/functions/launch.dart b/lib/controller/functions/launch.dart index c4a5668..9ad78c2 100644 --- a/lib/controller/functions/launch.dart +++ b/lib/controller/functions/launch.dart @@ -18,19 +18,17 @@ void launchCommunication( case 'phone': url = 'tel:$contactInfo'; break; - case 'sms': - url = 'sms:$contactInfo?body=$message'; + url = 'sms:$contactInfo?body=${Uri.encodeComponent(message)}'; break; - case 'whatsapp': - url = 'https://api.whatsapp.com/send?phone=$contactInfo&text=$message'; + url = + 'https://api.whatsapp.com/send?phone=$contactInfo&text=${Uri.encodeComponent(message)}'; break; - case 'email': - url = 'mailto:$contactInfo?subject=Subject&body=$message'; + url = + 'mailto:$contactInfo?subject=Subject&body=${Uri.encodeComponent(message)}'; break; - default: print('Method not supported on iOS'); return; @@ -40,19 +38,27 @@ void launchCommunication( case 'phone': url = 'tel:$contactInfo'; break; - case 'sms': - url = 'sms:$contactInfo?body=$message'; + url = 'sms:$contactInfo?body=${Uri.encodeComponent(message)}'; break; - case 'whatsapp': - url = 'whatsapp://send?phone=$contactInfo&text=$message'; + // Check if WhatsApp is installed + final bool whatsappInstalled = + await canLaunchUrl(Uri.parse('whatsapp://')); + if (whatsappInstalled) { + url = + 'whatsapp://send?phone=$contactInfo&text=${Uri.encodeComponent(message)}'; + } else { + print('WhatsApp is not installed on this device.'); + // Provide an alternative action, such as opening the WhatsApp Web API + url = + 'https://api.whatsapp.com/send?phone=$contactInfo&text=${Uri.encodeComponent(message)}'; + } break; - case 'email': - url = 'mailto:$contactInfo?subject=Subject&body=$message'; + url = + 'mailto:$contactInfo?subject=Subject&body=${Uri.encodeComponent(message)}'; break; - default: print('Method not supported on Android'); return; @@ -62,8 +68,10 @@ void launchCommunication( return; } + print('Launching URL: $url'); + if (await canLaunchUrl(Uri.parse(url))) { - launchUrl(Uri.parse(url)); + await launchUrl(Uri.parse(url)); } else { print('Could not launch $url'); } diff --git a/lib/controller/home/captin/map_driver_controller.dart b/lib/controller/home/captin/map_driver_controller.dart index 83df9ff..f3453e4 100644 --- a/lib/controller/home/captin/map_driver_controller.dart +++ b/lib/controller/home/captin/map_driver_controller.dart @@ -97,8 +97,8 @@ class MapDriverController extends GetxController { String? mapAPIKEY; final zones = []; String canelString = 'yet'; - late LatLng latLngpassengerLocation; - late LatLng latLngPassengerDestination; + LatLng latLngPassengerLocation = LatLng(0, 0); + late LatLng latLngPassengerDestination = LatLng(0, 0); void onMapCreated(GoogleMapController controller) async { myLocation = Get.find().location as LatLng; @@ -136,8 +136,8 @@ class MapDriverController extends GetxController { } Future openGoogleMapFromDriverToPassenger() async { - var endLat = latLngpassengerLocation.latitude; - var endLng = latLngpassengerLocation.longitude; + var endLat = latLngPassengerLocation.latitude; + var endLng = latLngPassengerLocation.longitude; var startLat = Get.find().myLocation.latitude; var startLng = Get.find().myLocation.longitude; @@ -365,8 +365,8 @@ class MapDriverController extends GetxController { calculateDistanceBetweenDriverAndPassengerLocation() { double distance2 = Geolocator.distanceBetween( - latLngpassengerLocation.latitude, - latLngpassengerLocation.longitude, + latLngPassengerLocation.latitude, + latLngPassengerLocation.longitude, Get.find().myLocation.latitude, Get.find().myLocation.longitude, ); @@ -843,19 +843,11 @@ class MapDriverController extends GetxController { update(); } - late Duration durationToAdd; - int hours = 0; - int minutes = 0; - late String carType; - late String kazan; - late String startNameLocation; - late String endNameLocation; - @override - void onInit() async { - mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY); - // Get the passenger location from the arguments. + argumentLoading() async { passengerLocation = Get.arguments['passengerLocation']; + print(passengerLocation); passengerDestination = Get.arguments['passengerDestination']; + print(passengerDestination); duration = Get.arguments['Duration']; totalCost = Get.arguments['totalCost']; passengerId = Get.arguments['passengerId']; @@ -886,22 +878,29 @@ class MapDriverController extends GetxController { startNameLocation = Get.arguments['startNameLocation']; endNameLocation = Get.arguments['endNameLocation']; - var coords = passengerLocation.split(','); - var coordDestination = passengerDestination.split(','); + // var coords = passengerLocation.toString().split(','); + // var coordDestination = passengerDestination.toString().split(','); // Parse to double - double latPassengerLocation = double.parse(coords[0]); - double lngPassengerLocation = double.parse(coords[1]); - double latPassengerDestination = double.parse(coordDestination[0]); - double lngPassengerDestination = double.parse(coordDestination[1]); - latLngpassengerLocation = + double latPassengerLocation = + double.parse(passengerLocation.toString().split(',')[0]); + double lngPassengerLocation = + double.parse(passengerLocation.toString().split(',')[1]); + double latPassengerDestination = + double.parse(passengerDestination.toString().split(',')[0]); + double lngPassengerDestination = + double.parse(passengerDestination.toString().split(',')[1]); + latLngPassengerLocation = LatLng(latPassengerLocation, lngPassengerLocation); latLngPassengerDestination = LatLng(latPassengerDestination, lngPassengerDestination); String lat = Get.find().myLocation.latitude.toString(); String lng = Get.find().myLocation.longitude.toString(); String origin = '$lat,$lng'; + print('latLngpassengerLocation $latLngPassengerLocation'); + print('latLngPassengerDestination $latLngPassengerDestination'); // Set the origin and destination coordinates for the Google Maps directions request. + Future.delayed(const Duration(seconds: 1)); getMap(origin, passengerLocation); isHaveSteps == 'haveSteps' ? ( @@ -911,6 +910,22 @@ class MapDriverController extends GetxController { step4 == '' ? await getMapDestination(step3, step4) : () {}, ) : await getMapDestination(passengerLocation, passengerDestination); + update(); + } + + late Duration durationToAdd; + int hours = 0; + int minutes = 0; + late String carType; + late String kazan; + late String startNameLocation; + late String endNameLocation; + + @override + void onInit() async { + mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY); + // Get the passenger location from the arguments. + await argumentLoading(); addCustomCarIcon(); addCustomPassengerIcon(); addCustomStartIcon(); diff --git a/lib/controller/home/captin/order_request_controller.dart b/lib/controller/home/captin/order_request_controller.dart index ae5a847..6d2182f 100644 --- a/lib/controller/home/captin/order_request_controller.dart +++ b/lib/controller/home/captin/order_request_controller.dart @@ -120,14 +120,14 @@ class OrderRequestController extends GetxController { update(); } - // if (remainingTimeSpeed == 0) { - // if (applied == false) { - // print('applied========================='); - // print(applied); - // Get.back(); - // // refuseOrder(box.read(BoxName.driverID), orderID); - // } - // } + if (remainingTimeSpeed == 0) { + if (applied == false) { + print('applied========================='); + print(applied); + Get.back(); + // refuseOrder(box.read(BoxName.driverID), orderID); + } + } } void refuseOrder( diff --git a/lib/controller/home/captin/speed_map_controller.dart b/lib/controller/home/captin/speed_map_controller.dart new file mode 100644 index 0000000..5bddc4a --- /dev/null +++ b/lib/controller/home/captin/speed_map_controller.dart @@ -0,0 +1,355 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:google_polyline_algorithm/google_polyline_algorithm.dart'; + +import '../../../constant/api_key.dart'; +import '../../../constant/box_name.dart'; +import '../../../constant/colors.dart'; +import '../../../constant/links.dart'; +import '../../../main.dart'; +import '../../functions/crud.dart'; +import '../../functions/location_controller.dart'; +import 'home_captain_controller.dart'; + +class SpeedMapController extends GetxController { + bool isLoading = true; + final formKey1 = GlobalKey(); + final sosEmergincyNumberCotroller = TextEditingController(); + List data = []; + List dataDestination = []; + LatLngBounds? boundsData; + double mpg = 0; + BitmapDescriptor carIcon = BitmapDescriptor.defaultMarker; + BitmapDescriptor passengerIcon = BitmapDescriptor.defaultMarker; + BitmapDescriptor startIcon = BitmapDescriptor.defaultMarker; + BitmapDescriptor endIcon = BitmapDescriptor.defaultMarker; + final List polylineCoordinates = []; + final List polylineCoordinatesDestination = []; + List polyLines = []; + List polyLinesDestination = []; + Set markers = {}; + late String passengerLocation; + late String passengerDestination; + late String step0; + late String step1; + late String step2; + late String step3; + late String step4; + late String passengerWalletBurc; + late String timeOfOrder; + late String duration; + late String totalCost; + late String distance; + late String passengerName; + late String passengerEmail; + late String totalPassenger; + late String passengerPhone; + late String rideId; + late String isHaveSteps; + late String paymentAmount; + late String paymentMethod; + late String passengerId; + late String driverId; + late String tokenPassenger; + late String durationToPassenger; + late String walletChecked; + late String direction; + late String carType; + late String kazan; + late String startNameLocation; + late String endNameLocation; + late String durationOfRideValue; + late String status; + String stringRemainingTimeToPassenger = ''; + + String stringRemainingTimeWaitingPassenger = ''; + late Duration durationToAdd; + int hours = 0; + int minutes = 0; + int timeWaitingPassenger = 5; //5 miniute + bool isPassengerInfoWindow = false; + bool isBtnRideBegin = false; + bool isArrivedSend = true; + bool isdriverWaitTimeEnd = false; + bool isRideFinished = false; + bool isRideStarted = false; + bool isPriceWindow = false; + double passengerInfoWindowHeight = Get.height * .38; + double driverEndPage = 100; + double progress = 0; + double progressToPassenger = 0; + double progressInPassengerLocationFromDriver = 0; + bool isRideBegin = false; + int progressTimerToShowPassengerInfoWindowFromDriver = 25; + int remainingTimeToShowPassengerInfoWindowFromDriver = 25; + int remainingTimeToPassenger = 60; + int remainingTimeInPassengerLocatioWait = 60; + bool isDriverNearPassengerStart = false; + GoogleMapController? mapController; + late LatLng myLocation; + int remainingTimeTimerRideBegin = 60; + String stringRemainingTimeRideBegin = ''; + String stringRemainingTimeRideBegin1 = ''; + double progressTimerRideBegin = 0; + late Timer timer; + String? mapAPIKEY; + final zones = []; + String canelString = 'yet'; + late LatLng latLngPassengerLocation; + late LatLng latLngPassengerDestination; + void clearPolyline() { + polyLines = []; + polyLinesDestination = []; + polylineCoordinates.clear(); + polylineCoordinatesDestination.clear(); + update(); + } + + argumentLoading() async { + passengerLocation = Get.arguments['passengerLocation']; + print(passengerLocation); + passengerDestination = Get.arguments['passengerDestination']; + print(passengerDestination); + duration = Get.arguments['Duration']; + totalCost = Get.arguments['totalCost']; + passengerId = Get.arguments['passengerId']; + driverId = Get.arguments['driverId']; + distance = Get.arguments['Distance']; + passengerName = Get.arguments['name']; + passengerEmail = Get.arguments['email']; + totalPassenger = Get.arguments['totalPassenger']; + passengerPhone = Get.arguments['phone']; + walletChecked = Get.arguments['WalletChecked']; + tokenPassenger = Get.arguments['tokenPassenger']; + direction = Get.arguments['direction']; + durationToPassenger = Get.arguments['DurationToPassenger']; + rideId = Get.arguments['rideId']; + durationOfRideValue = Get.arguments['durationOfRideValue']; + paymentAmount = Get.arguments['paymentAmount']; + paymentMethod = Get.arguments['paymentMethod']; + isHaveSteps = Get.arguments['isHaveSteps']; + step0 = Get.arguments['step0']; + step1 = Get.arguments['step1']; + step2 = Get.arguments['step2']; + step3 = Get.arguments['step3']; + step4 = Get.arguments['step4']; + passengerWalletBurc = Get.arguments['passengerWalletBurc']; + timeOfOrder = Get.arguments['timeOfOrder']; + carType = Get.arguments['carType']; + kazan = Get.arguments['kazan']; + startNameLocation = Get.arguments['startNameLocation']; + endNameLocation = Get.arguments['endNameLocation']; + + // var coords = passengerLocation.toString().split(','); + // var coordDestination = passengerDestination.toString().split(','); + +// Parse to double + double latPassengerLocation = + double.parse(passengerLocation.toString().split(',')[0]); + double lngPassengerLocation = + double.parse(passengerLocation.toString().split(',')[1]); + double latPassengerDestination = + double.parse(passengerDestination.toString().split(',')[0]); + double lngPassengerDestination = + double.parse(passengerDestination.toString().split(',')[1]); + latLngPassengerLocation = + LatLng(latPassengerLocation, lngPassengerLocation); + latLngPassengerDestination = + LatLng(latPassengerDestination, lngPassengerDestination); + String lat = Get.find().myLocation.latitude.toString(); + String lng = Get.find().myLocation.longitude.toString(); + String origin = '$lat,$lng'; + print('latLngpassengerLocation $latLngPassengerLocation'); + print('latLngPassengerDestination $latLngPassengerDestination'); + // Set the origin and destination coordinates for the Google Maps directions request. + Future.delayed(const Duration(seconds: 1)); + getMap(origin, passengerLocation); + isHaveSteps == 'haveSteps' + ? ( + await getMapDestination(step0, step1), + await getMapDestination(step1, step2), + step3 == '' ? await getMapDestination(step2, step3) : () {}, + step4 == '' ? await getMapDestination(step3, step4) : () {}, + ) + : await getMapDestination(passengerLocation, passengerDestination); + update(); + } + + double distanceBetweenDriverAndPassengerWhenConfirm = 0; + getMap(String origin, destination) async { + isLoading = false; + + update(); + + var url = + ('${AppLink.googleMapsLink}directions/json?&language=${box.read(BoxName.lang)}&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AK.mapAPIKEY}'); + + var response = await CRUD().getGoogleApi(link: url, payload: {}); + data = response['routes'][0]['legs']; + print(data); + distanceBetweenDriverAndPassengerWhenConfirm = + (data[0]['distance']['value']) / 1000; + final points = + decodePolyline(response["routes"][0]["overview_polyline"]["points"]); + for (int i = 0; i < points.length; i++) { + double lat = points[i][0].toDouble(); + double lng = points[i][1].toDouble(); + polylineCoordinates.add(LatLng(lat, lng)); + } + if (polyLines.isNotEmpty) { + clearPolyline(); + var polyline = Polyline( + polylineId: PolylineId(response["routes"][0]["summary"]), + points: polylineCoordinates, + width: 10, + color: AppColor.blueColor, + ); + polyLines.add(polyline); + // rideConfirm = false; + update(); + } else { + var polyline = Polyline( + polylineId: PolylineId(response["routes"][0]["summary"]), + points: polylineCoordinates, + width: 10, + color: AppColor.blueColor, + ); + // final dataBounds = response["routes"][0]["bounds"]; + + // updateCameraFromBoundsAfterGetMap(dataBounds); + +// Fit the camera to the bounds + + polyLines.add(polyline); + // rideConfirm = false; + // Define the northeast and southwest coordinates + final bounds = response["routes"][0]["bounds"]; + LatLng northeast = + LatLng(bounds['northeast']['lat'], bounds['northeast']['lng']); + LatLng southwest = + LatLng(bounds['southwest']['lat'], bounds['southwest']['lng']); + +// Create the LatLngBounds object + LatLngBounds boundsData = + LatLngBounds(northeast: northeast, southwest: southwest); + +// Fit the camera to the bounds + var cameraUpdate = CameraUpdate.newLatLngBounds(boundsData, 140); + mapController!.animateCamera(cameraUpdate); + update(); + } + } + + getMapDestination(String origin, destination) async { + var url = + ('${AppLink.googleMapsLink}directions/json?&language=${box.read(BoxName.lang)}&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AK.mapAPIKEY}'); + + var response = await CRUD().getGoogleApi(link: url, payload: {}); + dataDestination = response['routes'][0]['legs']; + // print(data); + final points = + decodePolyline(response["routes"][0]["overview_polyline"]["points"]); + for (int i = 0; i < points.length; i++) { + double lat = points[i][0].toDouble(); + double lng = points[i][1].toDouble(); + polylineCoordinatesDestination.add(LatLng(lat, lng)); + } + if (polyLinesDestination.isNotEmpty) { + // clearPolyline(); + var polyline = Polyline( + polylineId: PolylineId(response["routes"][0]["summary"]), + points: polylineCoordinatesDestination, + width: 10, + color: AppColor.redColor, + ); + polyLinesDestination.add(polyline); + // rideConfirm = false; + update(); + } else { + var polyline = Polyline( + polylineId: PolylineId(response["routes"][0]["summary"]), + points: polylineCoordinatesDestination, + width: 10, + color: AppColor.redColor, + ); + // final dataBounds = response["routes"][0]["bounds"]; + + // updateCameraFromBoundsAfterGetMap(dataBounds); + // polyLinesDestination.add(polyline); + // rideConfirm = false; + // Define the northeast and southwest coordinates + + update(); + } + } + + void startTimerToShowPassengerInfoWindowFromDriver() async { + isPassengerInfoWindow = true; + for (int i = 0; i <= int.parse(durationToPassenger); i++) { + await Future.delayed(const Duration(seconds: 1)); + progressToPassenger = i / int.parse(durationToPassenger); + remainingTimeToPassenger = int.parse(durationToPassenger) - i; + if (remainingTimeToPassenger == 0) { + isBtnRideBegin = true; + print(isBtnRideBegin); + update(); + } + print(isBtnRideBegin); + print(remainingTimeToPassenger); + + int minutes = (remainingTimeToPassenger / 60).floor(); + int seconds = remainingTimeToPassenger % 60; + stringRemainingTimeToPassenger = + '$minutes:${seconds.toString().padLeft(2, '0')}'; + + update(); + } + // update(); + // startTimerToShowDriverToPassengerDuration(); + } + + void onMapCreated(GoogleMapController controller) async { + myLocation = Get.find().location as LatLng; + myLocation = myLocation; + mapController = controller; + controller.getVisibleRegion(); + controller.animateCamera( + CameraUpdate.newLatLng(Get.find().myLocation), + ); + update(); + // Set up a timer or interval to trigger the marker update every 3 seconds. + timer = Timer.periodic(const Duration(seconds: 1), (_) { + // updateMarker(); + }); + } + + @override + void onInit() async { + mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY); + // Get the passenger location from the arguments. + await argumentLoading(); + // addCustomCarIcon(); + // addCustomPassengerIcon(); + // addCustomStartIcon(); + // addCustomEndIcon(); + // updateMarker(); + // updateLocation(); + startTimerToShowPassengerInfoWindowFromDriver(); + durationToAdd = Duration(seconds: int.parse(duration)); + hours = durationToAdd.inHours; + minutes = (durationToAdd.inMinutes % 60).round(); + calculateConsumptionFuel(); + // cancelCheckRidefromPassenger(); + // checkIsDriverNearPassenger(); + super.onInit(); + } + + calculateConsumptionFuel() { + mpg = Get.find().fuelPrice / + 12; //todo in register car add mpg in box + update(); + } +} diff --git a/lib/controller/local/translations.dart b/lib/controller/local/translations.dart index a65fbf1..c824409 100644 --- a/lib/controller/local/translations.dart +++ b/lib/controller/local/translations.dart @@ -4,7 +4,11 @@ class MyTranslation extends Translations { @override Map> get keys => { "ar": { - "No data yet!": "ccc", + "Special Order": "طلب خاص", + "Speed Order": "طلب سريع", + "No data yet!": "لا توجد بيانات حتى الآن!", + "You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!": + "لقد رفضت 3 رحلات اليوم وهذا هو السبب \nأراك غدًا!", "fromBudget": "من الميزانية", "You must restart the app to change the language.": "يجب إعادة تشغيل التطبيق لتغيير اللغة", diff --git a/lib/views/home/Captin/driver_map_page.dart b/lib/views/home/Captin/driver_map_page.dart index 1e97e78..94f189e 100644 --- a/lib/views/home/Captin/driver_map_page.dart +++ b/lib/views/home/Captin/driver_map_page.dart @@ -16,11 +16,11 @@ import 'mapDriverWidgets/sos_connect.dart'; class PassengerLocationMapPage extends StatelessWidget { PassengerLocationMapPage({super.key}); final LocationController locationController = Get.put(LocationController()); - final MapDriverController mapDriverController = - Get.put(MapDriverController()); + // final MapDriverController mapDriverController = + // Get.put(MapDriverController()); @override Widget build(BuildContext context) { - // Get.put(MapDriverController()); + Get.put(MapDriverController()); return MyScafolld( title: 'Map Passenger'.tr, @@ -31,7 +31,7 @@ class PassengerLocationMapPage extends StatelessWidget { const SosConnect(), speedCircle(), const GoogleMapApp(), - PricesWindow(), + const PricesWindow(), ], isleading: false); } diff --git a/lib/views/home/Captin/driver_map_speed.dart b/lib/views/home/Captin/driver_map_speed.dart new file mode 100644 index 0000000..c4f3ac8 --- /dev/null +++ b/lib/views/home/Captin/driver_map_speed.dart @@ -0,0 +1,92 @@ +import 'package:SEFER/constant/style.dart'; +import 'package:SEFER/controller/home/captin/speed_map_controller.dart'; +import 'package:SEFER/views/home/Captin/mapDriverWidgets/speed_google_map.dart'; +import 'package:SEFER/views/widgets/elevated_btn.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:SEFER/controller/home/captin/map_driver_controller.dart'; +import 'package:SEFER/views/widgets/my_scafold.dart'; + +import '../../../controller/functions/location_controller.dart'; +import '../../Rate/rate_passenger.dart'; +import 'mapDriverWidgets/driver_end_ride_bar.dart'; +import 'mapDriverWidgets/google_driver_map_page.dart'; +import 'mapDriverWidgets/google_map_app.dart'; +import 'mapDriverWidgets/passenger_info_window.dart'; +import 'mapDriverWidgets/sos_connect.dart'; + +class DriverSpeedLocationMapPage extends StatelessWidget { + DriverSpeedLocationMapPage({super.key}); + final LocationController locationController = Get.put(LocationController()); + // final MapDriverController mapDriverController = + // Get.put(MapDriverController()); + @override + Widget build(BuildContext context) { + Get.put(SpeedMapController()) + .startTimerToShowPassengerInfoWindowFromDriver(); + Get.find().argumentLoading(); + Get.put(MapDriverController()); + + return MyScafolld( + title: 'Map Passenger'.tr, + body: [ + SpeedGoogleDriverMap(locationController: locationController), + const PassengerInfoWindow(), + driverEndRideBar(), + const SosConnect(), + speedCircle(), + const GoogleMapApp(), + const PricesWindow(), + ], + isleading: false); + } +} + +class PricesWindow extends StatelessWidget { + const PricesWindow({ + super.key, + }); + + @override + Widget build(BuildContext context) { + return GetBuilder(builder: (mapDriverController) { + return mapDriverController.isPriceWindow + ? Positioned( + bottom: Get.height * 1.2, + // top: Get.height * 3, + left: Get.height * 1, + right: Get.height * 1, + child: Container( + height: Get.height * 3, + decoration: AppStyle.boxDecoration1, + child: Column( + children: [ + Container( + decoration: AppStyle.boxDecoration1, + child: Padding( + padding: const EdgeInsets.all(3), + child: Text( + 'Total Price is '.tr, + style: AppStyle.headTitle2, + textAlign: TextAlign.center, + ), + )), + const SizedBox( + height: 20, + ), + MyElevatedButton( + title: 'ok'.tr, + onPressed: () => + Get.to(() => RatePassenger(), arguments: { + 'rideId': mapDriverController.rideId, + 'passengerId': mapDriverController.passengerId, + 'driverId': mapDriverController.driverId + })) + ], + ), + ), + ) + : const SizedBox(); + }); + } +} diff --git a/lib/views/home/Captin/mapDriverWidgets/google_driver_map_page.dart b/lib/views/home/Captin/mapDriverWidgets/google_driver_map_page.dart index 45a0300..7d7f5e3 100644 --- a/lib/views/home/Captin/mapDriverWidgets/google_driver_map_page.dart +++ b/lib/views/home/Captin/mapDriverWidgets/google_driver_map_page.dart @@ -16,7 +16,7 @@ class GoogleDriverMap extends StatelessWidget { @override Widget build(BuildContext context) { - // Get.put(MapDriverController()); + Get.put(MapDriverController()); return Padding( padding: const EdgeInsets.all(8.0), child: GetBuilder( @@ -54,8 +54,8 @@ class GoogleDriverMap extends StatelessWidget { visible: true, polylineId: const PolylineId('route1'), points: controller.polylineCoordinates, - color: AppColor.greenColor, - width: 3, + color: AppColor.yellowColor, + width: 4, ), Polyline( zIndex: 2, @@ -67,7 +67,7 @@ class GoogleDriverMap extends StatelessWidget { polylineId: const PolylineId('route'), points: controller.polylineCoordinatesDestination, color: AppColor.primaryColor, - width: 2, + width: 4, ), }, markers: { @@ -79,7 +79,7 @@ class GoogleDriverMap extends StatelessWidget { rotation: locationController.heading), Marker( markerId: MarkerId('start'.tr), - position: controller.latLngpassengerLocation, + position: controller.latLngPassengerLocation, draggable: true, icon: controller.startIcon, ), diff --git a/lib/views/home/Captin/mapDriverWidgets/google_map_app.dart b/lib/views/home/Captin/mapDriverWidgets/google_map_app.dart index 156e589..67f3622 100644 --- a/lib/views/home/Captin/mapDriverWidgets/google_map_app.dart +++ b/lib/views/home/Captin/mapDriverWidgets/google_map_app.dart @@ -21,10 +21,10 @@ class GoogleMapApp extends StatelessWidget { child: IconButton( onPressed: () async { var startLat = Get.find() - .latLngpassengerLocation + .latLngPassengerLocation .latitude; var startLng = Get.find() - .latLngpassengerLocation + .latLngPassengerLocation .longitude; var endLat = Get.find() diff --git a/lib/views/home/Captin/mapDriverWidgets/speed_google_map.dart b/lib/views/home/Captin/mapDriverWidgets/speed_google_map.dart new file mode 100644 index 0000000..5fd3c8b --- /dev/null +++ b/lib/views/home/Captin/mapDriverWidgets/speed_google_map.dart @@ -0,0 +1,97 @@ +import 'package:SEFER/controller/home/captin/speed_map_controller.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; + +import '../../../../constant/colors.dart'; +import '../../../../controller/functions/location_controller.dart'; + +class SpeedGoogleDriverMap extends StatelessWidget { + const SpeedGoogleDriverMap({ + super.key, + required this.locationController, + }); + + final LocationController locationController; + + @override + Widget build(BuildContext context) { + Get.put(SpeedMapController()); + return Padding( + padding: const EdgeInsets.all(8.0), + child: GetBuilder( + builder: (controller) => GoogleMap( + onMapCreated: controller.onMapCreated, + initialCameraPosition: CameraPosition( + // bearing: 45, + target: locationController.myLocation, + zoom: 16, + tilt: 40, + ), + onCameraMoveStarted: () {}, + onCameraMove: (position) { + locationController.myLocation = position.target; + controller.mapController! + .animateCamera(CameraUpdate.newCameraPosition(position)); + }, + minMaxZoomPreference: const MinMaxZoomPreference(6, 18), + myLocationEnabled: true, + compassEnabled: true, + mapType: MapType.normal, + trafficEnabled: true, + buildingsEnabled: true, + mapToolbarEnabled: true, + zoomControlsEnabled: true, + fortyFiveDegreeImageryEnabled: true, + zoomGesturesEnabled: true, + polylines: { + Polyline( + zIndex: 2, + consumeTapEvents: true, + geodesic: true, + endCap: Cap.buttCap, + startCap: Cap.buttCap, + visible: true, + polylineId: const PolylineId('route1'), + points: controller.polylineCoordinates, + color: AppColor.yellowColor, + width: 4, + ), + Polyline( + zIndex: 2, + consumeTapEvents: true, + geodesic: true, + endCap: Cap.buttCap, + startCap: Cap.buttCap, + visible: true, + polylineId: const PolylineId('route'), + points: controller.polylineCoordinatesDestination, + color: AppColor.primaryColor, + width: 4, + ), + }, + markers: { + Marker( + markerId: MarkerId('MyLocation'.tr), + position: locationController.myLocation, + draggable: true, + icon: controller.carIcon, + rotation: locationController.heading), + Marker( + markerId: MarkerId('start'.tr), + position: controller.latLngPassengerLocation, + draggable: true, + icon: controller.startIcon, + ), + Marker( + markerId: MarkerId('end'.tr), + position: controller.latLngPassengerDestination, + draggable: true, + icon: controller.endIcon, + ), + }, + ), + ), + ); + } +} diff --git a/lib/views/home/Captin/orderCaptin/order_request_page.dart b/lib/views/home/Captin/orderCaptin/order_request_page.dart index a6a2da7..0e048d0 100644 --- a/lib/views/home/Captin/orderCaptin/order_request_page.dart +++ b/lib/views/home/Captin/orderCaptin/order_request_page.dart @@ -82,7 +82,7 @@ class OrderRequestPage extends StatelessWidget { // orderRequestController.calculateConsumptionFuel(); return MyScafolld( - title: 'Order Details'.tr, + title: 'Special Order'.tr, body: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 6), diff --git a/lib/views/home/Captin/orderCaptin/order_speed_request.dart b/lib/views/home/Captin/orderCaptin/order_speed_request.dart index 4c29bfb..67b1e11 100644 --- a/lib/views/home/Captin/orderCaptin/order_speed_request.dart +++ b/lib/views/home/Captin/orderCaptin/order_speed_request.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:SEFER/controller/functions/tts.dart'; import 'package:SEFER/controller/home/captin/home_captain_controller.dart'; +import 'package:SEFER/views/home/Captin/driver_map_speed.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:SEFER/constant/box_name.dart'; @@ -90,7 +91,7 @@ class OrderSpeedRequest extends StatelessWidget { // } return MyScafolld( - title: 'Order Details'.tr, + title: 'Speed Order'.tr, body: [ ListView( // crossAxisAlignment: CrossAxisAlignment.start, @@ -336,6 +337,7 @@ class OrderSpeedRequest extends StatelessWidget { })); } else if (jsonDecode(res)['status'] == "success") { box.write(BoxName.statusDriverLocation, 'on'); + orderRequestController.changeApplied(); List bodyToPassenger = [ box.read(BoxName.driverID).toString(), box.read(BoxName.nameDriver).toString(), @@ -359,40 +361,75 @@ class OrderSpeedRequest extends StatelessWidget { bodyToPassenger, ); Get.back(); - Get.to(() => PassengerLocationMapPage(), arguments: { - 'passengerLocation': myList[0].toString(), - 'passengerDestination': myList[1].toString(), - 'Duration': myList[4].toString(), - 'totalCost': myList[26].toString(), - 'Distance': myList[5].toString(), - 'name': myList[8].toString(), - 'phone': myList[10].toString(), - 'email': myList[28].toString(), - 'WalletChecked': myList[13].toString(), - 'tokenPassenger': myList[9].toString(), - 'direction': - 'https://www.google.com/maps/dir/${myList[0]}/${myList[1]}/', - 'DurationToPassenger': myList[15].toString(), - 'rideId': myList[16].toString(), - 'passengerId': myList[7].toString(), - 'driverId': myList[18].toString(), - 'durationOfRideValue': myList[19].toString(), - 'paymentAmount': myList[2].toString(), - 'paymentMethod': myList[13].toString() == 'true' - ? 'visa' - : 'cash', - 'isHaveSteps': myList[20].toString(), - 'step0': myList[21].toString(), - 'step1': myList[22].toString(), - 'step2': myList[23].toString(), - 'step3': myList[24].toString(), - 'step4': myList[25].toString(), - 'passengerWalletBurc': myList[26].toString(), - 'timeOfOrder': DateTime.now().toString(), - 'totalPassenger': myList[2].toString(), - 'carType': myList[31].toString(), - 'kazan': myList[32].toString(), - }); + + print( + 'Arguments passed to PassengerLocationMapPage:'); + print('Passenger Location: ${myList[0]}'); + print('Passenger Destination: ${myList[1]}'); + print('Duration: ${myList[4]}'); + print('Total Cost: ${myList[26]}'); + print('Distance: ${myList[5]}'); + print('Name: ${myList[8]}'); + print('Phone: ${myList[10]}'); + print('Email: ${myList[28]}'); + print('Wallet Checked: ${myList[13]}'); + print('Token Passenger: ${myList[9]}'); + print('Direction: ${myList[29]}'); + print('Duration To Passenger: ${myList[15]}'); + print('Ride ID: ${myList[16]}'); + print('Passenger ID: ${myList[7]}'); + print('Driver ID: ${myList[18]}'); + print('Duration Of Ride Value: ${myList[19]}'); + print('Payment Amount: ${myList[2]}'); + print( + 'Payment Method: ${myList[13] == 'true' ? 'visa' : 'cash'}'); + print('Is Have Steps: ${myList[20]}'); + print('Step 0: ${myList[21]}'); + print('Step 1: ${myList[22]}'); + print('Step 2: ${myList[23]}'); + print('Step 3: ${myList[24]}'); + print('Step 4: ${myList[25]}'); + print('Passenger Wallet Burc: ${myList[26]}'); + print('Time Of Order: ${myList[30]}'); + print('Total Passenger: ${myList[2]}'); + print('Car Type: ${myList[31]}'); + print('Kazan: ${myList[32]}'); + + Get.to(() => DriverSpeedLocationMapPage(), + arguments: { + 'passengerLocation': myList[0].toString(), + 'passengerDestination': myList[1].toString(), + 'Duration': myList[4].toString(), + 'totalCost': myList[26].toString(), + 'Distance': myList[5].toString(), + 'name': myList[8].toString(), + 'phone': myList[10].toString(), + 'email': myList[28].toString(), + 'WalletChecked': myList[13].toString(), + 'tokenPassenger': myList[9].toString(), + 'direction': + 'https://www.google.com/maps/dir/${myList[0]}/${myList[1]}/', + 'DurationToPassenger': myList[15].toString(), + 'rideId': myList[16].toString(), + 'passengerId': myList[7].toString(), + 'driverId': myList[18].toString(), + 'durationOfRideValue': myList[19].toString(), + 'paymentAmount': myList[2].toString(), + 'paymentMethod': myList[13].toString() == 'true' + ? 'visa' + : 'cash', + 'isHaveSteps': myList[20].toString(), + 'step0': myList[21].toString(), + 'step1': myList[22].toString(), + 'step2': myList[23].toString(), + 'step3': myList[24].toString(), + 'step4': myList[25].toString(), + 'passengerWalletBurc': myList[26].toString(), + 'timeOfOrder': DateTime.now().toString(), + 'totalPassenger': myList[2].toString(), + 'carType': myList[31].toString(), + 'kazan': myList[32].toString(), + }); } // }); // Get.back();