3/27/2
This commit is contained in:
@@ -127,7 +127,7 @@ class AppLink {
|
|||||||
// =====================================
|
// =====================================
|
||||||
static String addRateToPassenger = "$ride/rate/add.php";
|
static String addRateToPassenger = "$ride/rate/add.php";
|
||||||
static String addRateToDriver = "$ride/rate/addRateToDriver.php";
|
static String addRateToDriver = "$ride/rate/addRateToDriver.php";
|
||||||
static String getDriveRrate = "$ride/rate/getDriveRrate.php";
|
static String getDriverRate = "$ride/rate/getDriveRrate.php";
|
||||||
|
|
||||||
////////////////emails ============//
|
////////////////emails ============//
|
||||||
static String sendEmailToPassengerForTripDetails =
|
static String sendEmailToPassengerForTripDetails =
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'package:SEFER/controller/home/captin/map_driver_controller.dart';
|
||||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -127,6 +128,7 @@ class FirebaseMessagesController extends GetxController {
|
|||||||
var myList = jsonDecode(myListString) as List<dynamic>;
|
var myList = jsonDecode(myListString) as List<dynamic>;
|
||||||
// var myPoints = jsonDecode(points) as List<dynamic>;
|
// var myPoints = jsonDecode(points) as List<dynamic>;
|
||||||
driverToken = myList[14].toString();
|
driverToken = myList[14].toString();
|
||||||
|
Get.find<MapDriverController>().rideId = 'rideId';
|
||||||
update();
|
update();
|
||||||
// print('driverToken==============$driverToken');
|
// print('driverToken==============$driverToken');
|
||||||
Get.to(() => OrderRequestPage(), arguments: {
|
Get.to(() => OrderRequestPage(), arguments: {
|
||||||
@@ -223,8 +225,10 @@ class FirebaseMessagesController extends GetxController {
|
|||||||
Get.offAll(const MapPagePassenger());
|
Get.offAll(const MapPagePassenger());
|
||||||
} else if (message.notification!.title! == 'Order Applied') {
|
} else if (message.notification!.title! == 'Order Applied') {
|
||||||
Get.snackbar(
|
Get.snackbar(
|
||||||
"The order has been accepted by another driver.".tr, // Corrected grammar
|
"The order has been accepted by another driver."
|
||||||
"Be more mindful next time to avoid dropping orders.".tr, // Improved sentence structure
|
.tr, // Corrected grammar
|
||||||
|
"Be more mindful next time to avoid dropping orders."
|
||||||
|
.tr, // Improved sentence structure
|
||||||
backgroundColor: AppColor.yellowColor,
|
backgroundColor: AppColor.yellowColor,
|
||||||
snackPosition: SnackPosition.BOTTOM,
|
snackPosition: SnackPosition.BOTTOM,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:SEFER/constant/table_names.dart';
|
import 'package:SEFER/constant/table_names.dart';
|
||||||
|
import 'package:SEFER/controller/home/captin/home_captain_controller.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
import 'package:location/location.dart';
|
import 'package:location/location.dart';
|
||||||
@@ -19,9 +20,9 @@ class LocationController extends GetxController {
|
|||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
late double heading = 0;
|
late double heading = 0;
|
||||||
late double accuracy = 0;
|
late double accuracy = 0;
|
||||||
LatLng? previousLocation;
|
late double previousTime = 0;
|
||||||
late double latitude;
|
late double latitude;
|
||||||
late double totalDistance;
|
late double totalDistance = 0;
|
||||||
late double longitude;
|
late double longitude;
|
||||||
late DateTime time;
|
late DateTime time;
|
||||||
late double speed = 0;
|
late double speed = 0;
|
||||||
@@ -63,9 +64,10 @@ class LocationController extends GetxController {
|
|||||||
'longitude': myLocation.longitude.toString(),
|
'longitude': myLocation.longitude.toString(),
|
||||||
'heading': heading.toString(),
|
'heading': heading.toString(),
|
||||||
'speed': speed.toString(),
|
'speed': speed.toString(),
|
||||||
|
'distance': totalDistance == 0 ? '0' : totalDistance.toString(),
|
||||||
'status': box.read(BoxName.statusDriverLocation).toString()
|
'status': box.read(BoxName.statusDriverLocation).toString()
|
||||||
});
|
});
|
||||||
if (Get.find<MapDriverController>().rideId == null) {
|
if (Get.find<HomeCaptainController>().rideId == '0') {
|
||||||
await sql.insertData({
|
await sql.insertData({
|
||||||
'driver_id': box.read(BoxName.driverID),
|
'driver_id': box.read(BoxName.driverID),
|
||||||
'latitude': myLocation.latitude.toString(),
|
'latitude': myLocation.latitude.toString(),
|
||||||
@@ -133,20 +135,43 @@ class LocationController extends GetxController {
|
|||||||
(_locationData.latitude != null && _locationData.longitude != null
|
(_locationData.latitude != null && _locationData.longitude != null
|
||||||
? LatLng(_locationData.latitude!, _locationData.longitude!)
|
? LatLng(_locationData.latitude!, _locationData.longitude!)
|
||||||
: null)!;
|
: null)!;
|
||||||
|
speed = _locationData.speed!;
|
||||||
|
heading = _locationData.heading!;
|
||||||
// Calculate the distance between the current location and the previous location
|
// Calculate the distance between the current location and the previous location
|
||||||
if (previousLocation != null) {
|
if (Get.find<HomeCaptainController>().rideId == 'rideId') {
|
||||||
// double distance = myLocation.distanceBetween(previousLocation);
|
if (previousTime > 0) {
|
||||||
// totalDistance += distance;
|
double distance = calculateDistanceInKmPerHour(
|
||||||
}
|
previousTime, _locationData.time, speed);
|
||||||
|
print('distance $distance');
|
||||||
|
totalDistance += distance;
|
||||||
|
}
|
||||||
|
print('totalDistance: $totalDistance');
|
||||||
|
|
||||||
previousLocation = myLocation;
|
previousTime = _locationData.time!;
|
||||||
|
}
|
||||||
// Print location details
|
// Print location details
|
||||||
// print('myLocation: ${myLocation}');
|
print('myLocation: ${myLocation}');
|
||||||
// print('Accuracy: ${_locationData.accuracy}');
|
print('Accuracy: ${_locationData.accuracy}');
|
||||||
// print('Latitude: ${_locationData.latitude}');
|
print('Latitude: ${_locationData.latitude}');
|
||||||
// print('Longitude: ${_locationData.longitude}');
|
print('Longitude: ${_locationData.longitude}');
|
||||||
// print('Time: ${_locationData.time}');
|
print('Time: ${_locationData.time}');
|
||||||
|
print('speed: ${_locationData.speed}');
|
||||||
|
print('Heading: ${_locationData.heading}');
|
||||||
// isLoading = false;
|
// isLoading = false;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double calculateDistanceInKmPerHour(
|
||||||
|
double? startTime, double? endTime, double speedInMetersPerSecond) {
|
||||||
|
// Calculate the time difference in hours
|
||||||
|
double timeDifferenceInHours = (endTime! - startTime!) / 1000 / 3600;
|
||||||
|
|
||||||
|
// Convert speed to kilometers per hour
|
||||||
|
double speedInKmPerHour = speedInMetersPerSecond * 3.6;
|
||||||
|
|
||||||
|
// Calculate the distance in kilometers
|
||||||
|
double distanceInKilometers = speedInKmPerHour * timeDifferenceInHours;
|
||||||
|
|
||||||
|
return distanceInKilometers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class HomeCaptainController extends GetxController {
|
|||||||
bool isCallOn = false;
|
bool isCallOn = false;
|
||||||
String totalMoneyToday = '0';
|
String totalMoneyToday = '0';
|
||||||
String rating = '0';
|
String rating = '0';
|
||||||
|
String rideId = '0';
|
||||||
String countRideToday = '0';
|
String countRideToday = '0';
|
||||||
String totalMoneyInSEFER = '0';
|
String totalMoneyInSEFER = '0';
|
||||||
String totalDurationToday = '0';
|
String totalDurationToday = '0';
|
||||||
@@ -244,7 +245,7 @@ class HomeCaptainController extends GetxController {
|
|||||||
|
|
||||||
getDriverRate() async {
|
getDriverRate() async {
|
||||||
var res = await CRUD().get(
|
var res = await CRUD().get(
|
||||||
link: AppLink.getDriveRrate,
|
link: AppLink.getDriverRate,
|
||||||
payload: {'driver_id': box.read(BoxName.driverID).toString()});
|
payload: {'driver_id': box.read(BoxName.driverID).toString()});
|
||||||
data = jsonDecode(res);
|
data = jsonDecode(res);
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class DrawerCaptain extends StatelessWidget {
|
|||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
Get.find<HomeCaptainController>().rating,
|
Get.find<HomeCaptainController>().rating.toString(),
|
||||||
style: AppStyle.number.copyWith(color: Colors.amber),
|
style: AppStyle.number.copyWith(color: Colors.amber),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
|
|||||||
Reference in New Issue
Block a user