25-6-13/1
This commit is contained in:
@@ -232,10 +232,7 @@ class LoginDriverController extends GetxController {
|
||||
Log.print('(BoxName.emailDriver): ${box.read(BoxName.emailDriver)}');
|
||||
|
||||
var res = await CRUD().get(link: AppLink.loginFromGoogleCaptin, payload: {
|
||||
'email': email.toString().contains('@')
|
||||
// ? (box.read(BoxName.emailDriver))
|
||||
? (email)
|
||||
: email,
|
||||
'email': email,
|
||||
'id': driverID,
|
||||
});
|
||||
|
||||
|
||||
@@ -408,7 +408,8 @@ class FirebaseMessagesController extends GetxController {
|
||||
var encryptedKey = await storage.read(key: 'FCM_PRIVATE_KEY');
|
||||
// Log.print('encryptedKey: ${encryptedKey}');
|
||||
if (encryptedKey != null) {
|
||||
serviceAccountKeyJson = (encryptedKey);
|
||||
serviceAccountKeyJson =
|
||||
EncryptionHelper.instance.decryptData(encryptedKey);
|
||||
// Log.print('serviceAccountKeyJson: ${serviceAccountKeyJson}');
|
||||
} else {
|
||||
print('🔴 Error: FCM_PRIVATE_KEY not found in Secure Storage');
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:secure_string_operations/secure_string_operations.dart';
|
||||
import 'package:sefer_driver/constant/box_name.dart';
|
||||
import 'package:sefer_driver/constant/links.dart';
|
||||
import 'package:sefer_driver/controller/auth/captin/login_captin_controller.dart';
|
||||
import 'package:sefer_driver/controller/functions/add_error.dart';
|
||||
import 'package:sefer_driver/main.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
@@ -44,9 +43,9 @@ class CRUD {
|
||||
'Bearer ${X.r(X.r(X.r(box.read(BoxName.jwt), cn), cC), cs).toString().split(AppInformation.addd)[0]}'
|
||||
},
|
||||
);
|
||||
// print(response.request);
|
||||
// Log.print('response.body: ${response.body}');
|
||||
// print(payload);
|
||||
print(response.request);
|
||||
Log.print('response.body: ${response.body}');
|
||||
print(payload);
|
||||
if (response.statusCode == 200) {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
if (jsonData['status'] == 'success') {
|
||||
@@ -82,7 +81,7 @@ class CRUD {
|
||||
}) async {
|
||||
var s = await LoginDriverController().getJwtWallet();
|
||||
final hmac = box.read(BoxName.hmac);
|
||||
Log.print('hmac: ${hmac}');
|
||||
// Log.print('hmac: ${hmac}');
|
||||
var url = Uri.parse(
|
||||
link,
|
||||
);
|
||||
@@ -95,10 +94,9 @@ class CRUD {
|
||||
'X-HMAC-Auth': hmac.toString(),
|
||||
},
|
||||
);
|
||||
// print(response.request);
|
||||
// // Log.print('response.request: ${response.request}');
|
||||
// Log.print('response.body: ${response.body}');
|
||||
// print(payload);
|
||||
Log.print('response.request: ${response.request}');
|
||||
Log.print('response.body: ${response.body}');
|
||||
print(payload);
|
||||
if (response.statusCode == 200) {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
if (jsonData['status'] == 'success') {
|
||||
@@ -145,9 +143,9 @@ class CRUD {
|
||||
'X-HMAC-Auth': hmac.toString(),
|
||||
},
|
||||
);
|
||||
// print(response.request);
|
||||
// Log.print('response.body: ${response.body}');
|
||||
// print(payload);
|
||||
print(response.request);
|
||||
Log.print('response.body: ${response.body}');
|
||||
print(payload);
|
||||
if (response.statusCode == 200) {
|
||||
try {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
@@ -203,9 +201,9 @@ class CRUD {
|
||||
// 'Authorization': 'Bearer ${box.read(BoxName.jwt)}'
|
||||
},
|
||||
);
|
||||
// print(response.request);
|
||||
// Log.print('response.body: ${response.body}');
|
||||
// print(payload);
|
||||
print(response.request);
|
||||
Log.print('response.body: ${response.body}');
|
||||
print(payload);
|
||||
if (response.statusCode == 200) {
|
||||
try {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
|
||||
@@ -4,10 +4,12 @@ import 'dart:math';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:location/location.dart';
|
||||
import 'package:sefer_driver/constant/table_names.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../../main.dart';
|
||||
import '../../print.dart';
|
||||
import '../home/captin/home_captain_controller.dart';
|
||||
import '../home/payment/captain_wallet_controller.dart';
|
||||
import 'crud.dart';
|
||||
@@ -72,6 +74,8 @@ class LocationController extends GetxController {
|
||||
}
|
||||
|
||||
int _insertCounter = 0;
|
||||
double? _lastSpeed;
|
||||
DateTime? _lastSpeedTime;
|
||||
|
||||
Future<void> startLocationUpdates() async {
|
||||
if (box.read(BoxName.driverID) != null) {
|
||||
@@ -111,13 +115,17 @@ class LocationController extends GetxController {
|
||||
if (_lastSavedPosition == null ||
|
||||
_calculateDistanceInMeters(_lastSavedPosition!, myLocation) >=
|
||||
10) {
|
||||
double currentSpeed = speed; // m/s
|
||||
double? acceleration = _calculateAcceleration(currentSpeed);
|
||||
|
||||
await sql.insertData({
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
'latitude': myLocation.latitude,
|
||||
'longitude': myLocation.longitude,
|
||||
'acceleration': acceleration ?? 0.0,
|
||||
'created_at': DateTime.now().toIso8601String(),
|
||||
'updated_at': DateTime.now().toIso8601String(),
|
||||
}, 'car_locations');
|
||||
}, TableName.behavior);
|
||||
|
||||
_lastSavedPosition = myLocation;
|
||||
}
|
||||
@@ -125,6 +133,7 @@ class LocationController extends GetxController {
|
||||
|
||||
// ✅ إدخال للسيرفر كل دقيقة
|
||||
_insertCounter++;
|
||||
Log.print('_insertCounter: ${_insertCounter}');
|
||||
if (_insertCounter >= 12) {
|
||||
_insertCounter = 0;
|
||||
await CRUD().post(
|
||||
@@ -199,4 +208,22 @@ class LocationController extends GetxController {
|
||||
2;
|
||||
return 12742 * 1000 * asin(sqrt(a)); // meters
|
||||
}
|
||||
|
||||
double? _calculateAcceleration(double currentSpeed) {
|
||||
final now = DateTime.now();
|
||||
if (_lastSpeed != null && _lastSpeedTime != null) {
|
||||
final deltaTime =
|
||||
now.difference(_lastSpeedTime!).inMilliseconds / 1000.0; // seconds
|
||||
if (deltaTime > 0) {
|
||||
final acceleration = (currentSpeed - _lastSpeed!) / deltaTime;
|
||||
_lastSpeed = currentSpeed;
|
||||
_lastSpeedTime = now;
|
||||
return double.parse(acceleration.toStringAsFixed(2));
|
||||
}
|
||||
}
|
||||
|
||||
_lastSpeed = currentSpeed;
|
||||
_lastSpeedTime = now;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:sefer_driver/constant/box_name.dart';
|
||||
@@ -90,7 +91,8 @@ class HomeCaptainController extends GetxController {
|
||||
isActive = !isActive;
|
||||
if (isActive) {
|
||||
if (double.parse(totalPoints) > -300) {
|
||||
// locationController.startLocationUpdates();
|
||||
locationController.startLocationUpdates();
|
||||
HapticFeedback.heavyImpact();
|
||||
// locationBackController.startBackLocation();
|
||||
activeStartTime = DateTime.now();
|
||||
activeTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
|
||||
@@ -173,6 +173,7 @@ class MapDriverController extends GetxController {
|
||||
|
||||
cancelTripFromDriverAfterApplied() async {
|
||||
if (formKeyCancel.currentState!.validate()) {
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
"Cancel Trip from driver",
|
||||
"Trip Cancelled from driver. We are looking for a new driver. Please wait."
|
||||
|
||||
@@ -65,7 +65,7 @@ class MyTranslation extends Translations {
|
||||
"Order Applied": "تم تطبيق الطلب",
|
||||
|
||||
//firebase above
|
||||
"cancel": "إلغاء",
|
||||
"cancel": "إلغاء", "Syria": "سوريا",
|
||||
"Security Warning": "تحذير أمني",
|
||||
"Potential security risks detected. The application will close in @seconds seconds.":
|
||||
"تم اكتشاف مخاطر أمنية محتملة. سيتم إغلاق التطبيق خلال @seconds ثانية.",
|
||||
|
||||
Reference in New Issue
Block a user