diff --git a/android/app/build.gradle b/android/app/build.gradle index b9214b5..d16ca8c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -55,8 +55,8 @@ android { // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. minSdkVersion 26 targetSdkVersion flutter.targetSdkVersion - versionCode 20 - versionName '1.4.4' + versionCode 21 + versionName '1.4.5' // manifestPlaceholders = [mapsApiKey: 'android/app/src/main/AndroidManifest.xml'] } diff --git a/lib/controller/functions/location_controller.dart b/lib/controller/functions/location_controller.dart index c675b8d..60624f7 100644 --- a/lib/controller/functions/location_controller.dart +++ b/lib/controller/functions/location_controller.dart @@ -63,8 +63,12 @@ class LocationController extends GetxController { 'latitude': myLocation.latitude.toString(), 'longitude': myLocation.longitude.toString(), 'heading': heading.toString(), - 'speed': speed.toString(), - 'distance': totalDistance == 0 ? '0' : totalDistance.toString(), + 'speed': (speed * 3.6).toStringAsFixed(1), + 'distance': totalDistance == 0 + ? '0' + : totalDistance < 1 + ? totalDistance.toStringAsFixed(3) + : totalDistance.toStringAsFixed(1), 'status': box.read(BoxName.statusDriverLocation).toString() }); if (Get.find().rideId == '0') { diff --git a/lib/controller/home/captin/home_captain_controller.dart b/lib/controller/home/captin/home_captain_controller.dart index 9baa504..ca50a5f 100644 --- a/lib/controller/home/captin/home_captain_controller.dart +++ b/lib/controller/home/captin/home_captain_controller.dart @@ -25,6 +25,11 @@ class HomeCaptainController extends GetxController { Timer? activeTimer; Map data = {}; bool isLoading = true; + late double kazan; + double latePrice = 0; + double heavyPrice = 0; + double comfortPrice = 0, speedPrice = 0, deliveryPrice = 0, freePrice = 0; + double naturePrice = 0; bool isCallOn = false; String totalMoneyToday = '0'; String rating = '0'; @@ -203,6 +208,7 @@ class HomeCaptainController extends GetxController { onButtonSelected(); await getPaymentToday(); await getDriverRate(); + getKazanPercent(); getCountRideToday(); getAllPayment(); startPeriodicExecution(); @@ -232,6 +238,22 @@ class HomeCaptainController extends GetxController { update(); } + getKazanPercent() async { + var res = await CRUD().get(link: AppLink.getKazanPercent); + if (res != 'failure') { + kazan = double.parse(jsonDecode(res)['message'][0]['kazan']); + naturePrice = double.parse(jsonDecode(res)['message'][0]['naturePrice']); + heavyPrice = double.parse(jsonDecode(res)['message'][0]['heavyPrice']); + latePrice = double.parse(jsonDecode(res)['message'][0]['latePrice']); + comfortPrice = + double.parse(jsonDecode(res)['message'][0]['comfortPrice']); + speedPrice = double.parse(jsonDecode(res)['message'][0]['speedPrice']); + deliveryPrice = + double.parse(jsonDecode(res)['message'][0]['deliveryPrice']); + freePrice = double.parse(jsonDecode(res)['message'][0]['freePrice']); + } + } + getCountRideToday() async { var res = await CRUD().get( link: AppLink.getCountRide, diff --git a/lib/controller/home/captin/map_driver_controller.dart b/lib/controller/home/captin/map_driver_controller.dart index be3260d..feb5297 100644 --- a/lib/controller/home/captin/map_driver_controller.dart +++ b/lib/controller/home/captin/map_driver_controller.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'dart:math' as math; import 'dart:math' show cos; import 'package:SEFER/constant/table_names.dart'; +import 'package:SEFER/controller/home/captin/home_captain_controller.dart'; import 'package:flutter/material.dart'; import 'package:geolocator/geolocator.dart'; import 'package:get/get.dart'; @@ -501,7 +502,7 @@ update ui for totla results isRideStarted = false; isPriceWindow = false; if (cartype == 'Comfort') { - totalCost = (price * rideTimerFromBegin).toString(); + totalCost = price.toStringAsFixed(2); } box.write(BoxName.statusDriverLocation, 'off'); // changeRideToBeginToPassenger(); @@ -599,10 +600,24 @@ update ui for totla results await Future.delayed(const Duration(seconds: 1)); recentDistanceToDash = Get.find().totalDistance; rideTimerFromBegin = i; - price = rideTimerFromBegin ~/ 60 + - (recentDistanceToDash * 4); //todo from kazan - price = (price * .10) + price; - speed = Get.find().speed; + price = cartype == 'Comfort' + ? (i ~/ 60) + + (recentDistanceToDash * + Get.find().comfortPrice) + : cartype == 'Speed' + ? (i ~/ 60) + + (recentDistanceToDash * + Get.find().speedPrice) + : cartype == 'Delivery' + ? (i ~/ 60) + + (recentDistanceToDash * + Get.find().deliveryPrice) + : (i ~/ 60) + + (recentDistanceToDash * + Get.find() + .freePrice); // $1 for each minute + $4 for each km + price = (price * .10) + price; // Add 10% tax + speed = Get.find().speed * 3.6; progressTimerRideBegin = i / durationOfRide; remainingTimeTimerRideBegin = durationOfRide - i; remainingTimeTimerRideBegin < 60 ? driverEndPage = 160 : 100; @@ -619,41 +634,6 @@ update ui for totla results } } - double calculateDistanceBetweenLocations(LatLng start, LatLng end) { - double startLat = start.latitude * math.pi / 180; - double startLon = start.longitude * math.pi / 180; - double endLat = end.latitude * math.pi / 180; - double endLon = end.longitude * math.pi / 180; - - double dLat = endLat - startLat; - double dLon = endLon - startLon; - - double a = math.pow(math.sin(dLat / 2), 2) + - math.cos(startLat) * math.cos(endLat) * math.pow(math.sin(dLon / 2), 2); - double c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a)); - double distance = 6371000 * c; // Distance in meters - - return distance; - } - - double calculateAngleBetweenLocations(LatLng start, LatLng end) { - double startLat = start.latitude * math.pi / 180; - double startLon = start.longitude * math.pi / 180; - double endLat = end.latitude * math.pi / 180; - double endLon = end.longitude * math.pi / 180; - - double dLon = endLon - startLon; - - double y = math.sin(dLon) * cos(endLat); - double x = cos(startLat) * math.sin(endLat) - - math.sin(startLat) * cos(endLat) * cos(dLon); - - double angle = math.atan2(y, x); - double angleDegrees = angle * 180 / math.pi; - - return angleDegrees; - } - double recentDistanceToDash = 0; double recentAngelToMarker = 0; double speed = 0; @@ -681,8 +661,8 @@ LIMIT var lng = double.parse(previousLocationOfDrivers[0]['lng']); LatLng prev = LatLng(lat, lng); - recentDistanceToDash = - calculateDistanceBetweenLocations(prev, myLocation); + // recentDistanceToDash = + // calculateDistanceBetweenLocations(prev, myLocation); print('recentAngelToMarker $recentAngelToMarker'); print('recentDistanceToDash $recentDistanceToDash'); } diff --git a/lib/controller/profile/captain_profile_controller.dart b/lib/controller/profile/captain_profile_controller.dart index 6c8f5d6..31768e7 100644 --- a/lib/controller/profile/captain_profile_controller.dart +++ b/lib/controller/profile/captain_profile_controller.dart @@ -72,14 +72,23 @@ class CaptainProfileController extends GetxController { print(d['message']); box.write(BoxName.sexDriver, d['message']['gender']); box.write(BoxName.dobDriver, d['message']['birthdate']); + box.write(BoxName.vin, d['message']['vin']); + box.write(BoxName.color, d['message']['color']); + box.write(BoxName.model, d['message']['model']); + box.write(BoxName.make, d['message']['make']); + box.write(BoxName.year, d['message']['year']); + box.write(BoxName.expirationDate, d['message']['expiration_date']); + // box.write(BoxName.acc, d['message']['accountBank']); + + update(); } } @override void onInit() { - if (box.read(BoxName.dobDriver) == null) { + // if (box.read(BoxName.dobDriver) == null) { getProfileData(); - } + // } super.onInit(); } diff --git a/lib/views/Rate/rate_passenger.dart b/lib/views/Rate/rate_passenger.dart index 32bb3ce..295f7b0 100644 --- a/lib/views/Rate/rate_passenger.dart +++ b/lib/views/Rate/rate_passenger.dart @@ -48,8 +48,12 @@ class RatePassenger extends StatelessWidget { child: Padding( padding: const EdgeInsets.all(4), child: Text( - Get.find() - .totalPassenger, + Get.find().cartype == + 'Comfort' + ? Get.find() + .totalCost + : Get.find() + .totalPassenger, style: AppStyle.number, ), ), diff --git a/lib/views/home/Captin/mapDriverWidgets/driver_end_ride_bar.dart b/lib/views/home/Captin/mapDriverWidgets/driver_end_ride_bar.dart index 2d8827d..67123d2 100644 --- a/lib/views/home/Captin/mapDriverWidgets/driver_end_ride_bar.dart +++ b/lib/views/home/Captin/mapDriverWidgets/driver_end_ride_bar.dart @@ -117,8 +117,8 @@ GetBuilder speedCircle() { child: Container( decoration: BoxDecoration( shape: BoxShape.circle, - color: AppColor.redColor, - border: Border.all(width: 2,color: AppColor.secondaryColor)), + color: AppColor.secondaryColor, + border: Border.all(width: 3, color: AppColor.redColor)), height: 60, width: 60, child: Center( diff --git a/lib/views/home/profile/profile_captain.dart b/lib/views/home/profile/profile_captain.dart index 5bc44c1..694b1e5 100644 --- a/lib/views/home/profile/profile_captain.dart +++ b/lib/views/home/profile/profile_captain.dart @@ -4,7 +4,6 @@ import 'package:get/get.dart'; import 'package:SEFER/constant/box_name.dart'; import 'package:SEFER/constant/style.dart'; import 'package:SEFER/controller/profile/captain_profile_controller.dart'; -import 'package:SEFER/env/env.dart'; import 'package:SEFER/main.dart'; import 'package:SEFER/views/widgets/elevated_btn.dart'; import 'package:SEFER/views/widgets/my_scafold.dart';