From 8df852ab661be2e246d96f42eb17262090056ea0 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Wed, 11 Sep 2024 13:52:17 +0300 Subject: [PATCH] 8/11/1 --- android/app/build.gradle | 4 +- .../functions/location_controller.dart | 10 +- .../home/captin/map_driver_controller.dart | 294 +++++++++--------- 3 files changed, 160 insertions(+), 148 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index d146007..36eb45b 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -54,8 +54,8 @@ android { // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. minSdk = 23 targetSdk = flutter.targetSdkVersion - versionCode = 83 - versionName = '1.5.83' + versionCode = 84 + versionName = '1.5.84' multiDexEnabled =true } diff --git a/lib/controller/functions/location_controller.dart b/lib/controller/functions/location_controller.dart index b1e33d6..00f8937 100644 --- a/lib/controller/functions/location_controller.dart +++ b/lib/controller/functions/location_controller.dart @@ -129,9 +129,9 @@ class LocationController extends GetxController { 'longitude': myLocation.longitude.toString(), 'heading': heading.toString(), 'speed': (speed * 3.6).toStringAsFixed(1), - 'distance': totalDistance == 0 + 'distance': totalDistance == 0 && (speed * 3.6) < 5 ? '0.0' - : totalDistance < 1 + : totalDistance < 7 ? totalDistance.toStringAsFixed(3) : totalDistance.toStringAsFixed(1), 'status': box.read(BoxName.statusDriverLocation).toString(), @@ -229,6 +229,10 @@ class LocationController extends GetxController { // Calculate the distance in kilometers double distanceInKilometers = speedInKmPerHour * timeDifferenceInHours; - return distanceInKilometers; + // Convert distance from kilometers to meters + double distanceInMeters = distanceInKilometers * 1000; + + // If the calculated distance is less than 6 meters, return 0 to avoid fake distance + return distanceInMeters < 5 ? 0 : distanceInKilometers; } } diff --git a/lib/controller/home/captin/map_driver_controller.dart b/lib/controller/home/captin/map_driver_controller.dart index ea03e3f..30477cc 100644 --- a/lib/controller/home/captin/map_driver_controller.dart +++ b/lib/controller/home/captin/map_driver_controller.dart @@ -694,166 +694,174 @@ class MapDriverController extends GetxController { durationOfRide = infinity; update(); } - if (carType != 'Comfort' || - carType != 'Mishwar Vip' || - carType != 'Lady' || - carType != 'RayehGaiComfort') { - price = double.parse(totalCost); - update(); - } + // if (carType != 'Comfort' || + // carType != 'Mishwar Vip' || + // carType != 'Lady' || + // carType != 'RayehGaiComfort') { + price = double.parse(totalCost); + // update(); + // } for (int i = 0; i <= durationOfRide; i++) { await Future.delayed(const Duration(seconds: 1)); recentDistanceToDash = Get.find().totalDistance; - rideTimerFromBegin = i; - - if (startNameLocation.toLowerCase().contains('airport') || - endNameLocation.toLowerCase().contains('airport') || - startNameLocation.contains('مطار') || - startNameLocation.contains('المطار') || - endNameLocation.contains('مطار') || - endNameLocation.contains('المطار')) { - price = carType == 'Comfort' // || carType == 'Free Ride' - ? (i ~/ 60) * Get.find().latePrice + - 20 + - (recentDistanceToDash * - Get.find().comfortPrice) - - // : carType == 'Speed' - // ? (i ~/ 60) + - // (recentDistanceToDash * - // Get.find().speedPrice) - : carType == 'Lady' - ? (i ~/ 60) * Get.find().latePrice + - 20 + - (recentDistanceToDash * - Get.find().comfortPrice) - // : carType == 'Delivery' - // ? (i ~/ 60) + - // (recentDistanceToDash * - // Get.find().deliveryPrice) - : carType == 'RayehGaiComfort' - ? (i ~/ 60) * Get.find().latePrice + - 20 + - (recentDistanceToDash * - Get.find().comfortPrice) - : (i ~/ 60) * Get.find().latePrice + - 20 + - (recentDistanceToDash * - Get.find().mashwariPrice); - } else if (currentTime.hour >= 21 && currentTime.hour < 0) { - price = carType == 'Comfort' // || carType == 'Free Ride' - ? (i ~/ 60) * Get.find().latePrice + - 20 + - (recentDistanceToDash * - Get.find().comfortPrice) - - // : carType == 'Speed' - // ? (i ~/ 60) + - // (recentDistanceToDash * - // Get.find().speedPrice) - : carType == 'Lady' - ? (i ~/ 60) * Get.find().latePrice + - 20 + - (recentDistanceToDash * - Get.find().comfortPrice) - // : carType == 'Delivery' - // ? (i ~/ 60) + - // (recentDistanceToDash * - // Get.find().deliveryPrice) - : carType == 'RayehGaiComfort' - ? (i ~/ 60) * Get.find().latePrice + - 20 + - (recentDistanceToDash * - Get.find().comfortPrice) - : (i ~/ 60) * Get.find().latePrice + - 20 + - (recentDistanceToDash * - Get.find().mashwariPrice); - } else if (currentTime.hour >= 1 && currentTime.hour < 5) { - if (startNameLocation.contains('club') || - startNameLocation.contains('nightclub') || - startNameLocation.contains('ديسكو') || - startNameLocation.contains('ملهى ليلي') || - startNameLocation.contains('Night club')) { + // rideTimerFromBegin = i; + if (int.parse(duration) > i) { + price = double.parse(totalCost); + } else { + if (startNameLocation.toLowerCase().contains('airport') || + endNameLocation.toLowerCase().contains('airport') || + startNameLocation.contains('مطار') || + startNameLocation.contains('المطار') || + endNameLocation.contains('مطار') || + endNameLocation.contains('المطار')) { price = carType == 'Comfort' // || carType == 'Free Ride' - ? (i ~/ 60) * - (Get.find().latePrice + .5) * - 2 + - (recentDistanceToDash * - Get.find().comfortPrice) + ? (i ~/ 60) * Get.find().latePrice + + (price) - + int.parse(duration) * + Get.find().latePrice + + // : carType == 'Speed' + // ? (i ~/ 60) + + // (recentDistanceToDash * + // Get.find().speedPrice) + : carType == 'Lady' + ? (i ~/ 60) * Get.find().latePrice + + (price) - + int.parse(duration) * + Get.find().latePrice + // : carType == 'Delivery' + // ? (i ~/ 60) + + // (recentDistanceToDash * + // Get.find().deliveryPrice) + : carType == 'RayehGaiComfort' + ? (i ~/ 60) * + Get.find().latePrice + + (recentDistanceToDash * + Get.find().comfortPrice) + : (i ~/ 60) * + Get.find().latePrice + + (recentDistanceToDash * + Get.find().mashwariPrice); + } else if (currentTime.hour >= 21 && currentTime.hour < 0) { + price = carType == 'Comfort' // || carType == 'Free Ride' + ? (i ~/ 60) * Get.find().latePrice + + (price) - + int.parse(duration) * + Get.find().latePrice + + // : carType == 'Speed' + // ? (i ~/ 60) + + // (recentDistanceToDash * + // Get.find().speedPrice) + : carType == 'Lady' + ? (i ~/ 60) * Get.find().latePrice + + (price) - + int.parse(duration) * + Get.find().latePrice + // : carType == 'Delivery' + // ? (i ~/ 60) + + // (recentDistanceToDash * + // Get.find().deliveryPrice) + : carType == 'RayehGaiComfort' + ? (i ~/ 60) * + Get.find().latePrice + + (recentDistanceToDash * + Get.find().comfortPrice) + : (i ~/ 60) * + Get.find().latePrice + + (recentDistanceToDash * + Get.find().mashwariPrice); + } else if (currentTime.hour >= 1 && currentTime.hour < 5) { + if (startNameLocation.contains('club') || + startNameLocation.contains('nightclub') || + startNameLocation.contains('ديسكو') || + startNameLocation.contains('ملهى ليلي') || + startNameLocation.contains('Night club')) { + price = carType == 'Comfort' // || carType == 'Free Ride' + ? (i ~/ 60) * + (Get.find().latePrice + .5) * + 2 + + (price) - + int.parse(duration) * + (Get.find().latePrice + .5) * + 2 + : carType == 'Lady' + ? (i ~/ 60) * + (Get.find().latePrice + .5) * + 2 + + (price) - + int.parse(duration) * + (Get.find().latePrice + .5) * + 2 + : carType == 'RayehGaiComfort' + ? (i ~/ 60) * + (Get.find().latePrice + + .5) * + 2 + + (price) + : (i ~/ 60) * + (Get.find().latePrice + + .5) * + 2 + + (price); + } + price = carType == 'Comfort' // || carType == 'Free Ride' + ? (i ~/ 60) * (Get.find().latePrice + .5) + + (price) - + int.parse(duration) * + (Get.find().latePrice + .5) : carType == 'Lady' ? (i ~/ 60) * - (Get.find().latePrice + .5) * - 2 + - (recentDistanceToDash * - Get.find().comfortPrice) + (Get.find().latePrice + .5) + + (price) - + int.parse(duration) * + (Get.find().latePrice + .5) : carType == 'RayehGaiComfort' ? (i ~/ 60) * (Get.find().latePrice + - .5) * - 2 + + .5) + (recentDistanceToDash * Get.find().comfortPrice) : (i ~/ 60) * (Get.find().latePrice + - .5) * - 2 + + .5) + + (recentDistanceToDash * + Get.find().mashwariPrice); + } else if (currentTime.hour >= 14 && currentTime.hour <= 17) { + price = carType == 'Comfort' // || carType == 'Free Ride' + ? (i ~/ 60) * (Get.find().heavyPrice) + + (price) - + int.parse(duration) * + (Get.find().heavyPrice + .5) + : carType == 'Lady' + ? (i ~/ 60) * (Get.find().heavyPrice) + + (price) - + int.parse(duration) * + (Get.find().heavyPrice + .5) + : carType == 'RayehGaiComfort' + ? (i ~/ 60) * + (Get.find().heavyPrice) + + (recentDistanceToDash * + Get.find().comfortPrice) + : (i ~/ 60) * + (Get.find().heavyPrice) + + (recentDistanceToDash * + Get.find().mashwariPrice); + } else { + price = carType == 'Comfort' // || carType == 'Free Ride' + ? (i ~/ 60) + (price) - int.parse(duration) + : carType == 'Lady' + ? (i ~/ 60) + (price) - int.parse(duration) + : carType == 'RayehGaiComfort' + ? (i ~/ 60) + + (recentDistanceToDash * + Get.find().comfortPrice) + : (i ~/ 60) + (recentDistanceToDash * Get.find().mashwariPrice); } - price = carType == 'Comfort' // || carType == 'Free Ride' - ? (i ~/ 60) * (Get.find().latePrice + .5) + - (recentDistanceToDash * - Get.find().comfortPrice) - : carType == 'Lady' - ? (i ~/ 60) * - (Get.find().latePrice + .5) + - (recentDistanceToDash * - Get.find().comfortPrice) - : carType == 'RayehGaiComfort' - ? (i ~/ 60) * - (Get.find().latePrice + .5) + - (recentDistanceToDash * - Get.find().comfortPrice) - : (i ~/ 60) * - (Get.find().latePrice + .5) + - (recentDistanceToDash * - Get.find().mashwariPrice); - } else if (currentTime.hour >= 14 && currentTime.hour <= 17) { - price = carType == 'Comfort' // || carType == 'Free Ride' - ? (i ~/ 60) * (Get.find().heavyPrice) + - (recentDistanceToDash * - Get.find().comfortPrice) - : carType == 'Lady' - ? (i ~/ 60) * (Get.find().heavyPrice) + - (recentDistanceToDash * - Get.find().comfortPrice) - : carType == 'RayehGaiComfort' - ? (i ~/ 60) * - (Get.find().heavyPrice) + - (recentDistanceToDash * - Get.find().comfortPrice) - : (i ~/ 60) * - (Get.find().heavyPrice) + - (recentDistanceToDash * - Get.find().mashwariPrice); - } else { - price = carType == 'Comfort' // || carType == 'Free Ride' - ? (i ~/ 60) + - (recentDistanceToDash * - Get.find().comfortPrice) - : carType == 'Lady' - ? (i ~/ 60) + - (recentDistanceToDash * - Get.find().comfortPrice) - : carType == 'RayehGaiComfort' - ? (i ~/ 60) + - (recentDistanceToDash * - Get.find().comfortPrice) - : (i ~/ 60) + - (recentDistanceToDash * - Get.find().mashwariPrice); } + // $1 for each minute + $4 for each km price = (price * double.parse(kazan)) + price; // Add 10% tax speed = Get.find().speed * 3.6;