25-3/18/1
This commit is contained in:
0
lib/controller/functions/add_error.dart
Normal file → Executable file
0
lib/controller/functions/add_error.dart
Normal file → Executable file
0
lib/controller/functions/audio_controller.dart
Normal file → Executable file
0
lib/controller/functions/audio_controller.dart
Normal file → Executable file
0
lib/controller/functions/call_controller.dart
Normal file → Executable file
0
lib/controller/functions/call_controller.dart
Normal file → Executable file
0
lib/controller/functions/camer_controller.dart
Normal file → Executable file
0
lib/controller/functions/camer_controller.dart
Normal file → Executable file
73
lib/controller/functions/crud.dart
Normal file → Executable file
73
lib/controller/functions/crud.dart
Normal file → Executable file
@@ -9,7 +9,6 @@ import 'package:sefer_driver/main.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:sefer_driver/env/env.dart';
|
||||
import 'package:sefer_driver/views/widgets/error_snakbar.dart';
|
||||
|
||||
import '../../constant/api_key.dart';
|
||||
import '../../constant/char_map.dart';
|
||||
@@ -27,7 +26,7 @@ class CRUD {
|
||||
.r(X.r(X.r(box.read(BoxName.jwt), cn), cC), cs)
|
||||
.toString()
|
||||
.split(AppInformation.addd)[0]);
|
||||
Log.print('isTokenExpired: ${isTokenExpired}');
|
||||
// Log.print('isTokenExpired: ${isTokenExpired}');
|
||||
|
||||
if (isTokenExpired) {
|
||||
await LoginDriverController().getJWT();
|
||||
@@ -45,9 +44,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);
|
||||
print(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') {
|
||||
@@ -93,6 +92,10 @@ class CRUD {
|
||||
'Authorization': 'Bearer $s'
|
||||
},
|
||||
);
|
||||
// print(response.request);
|
||||
// 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') {
|
||||
@@ -121,6 +124,58 @@ class CRUD {
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> postWallet(
|
||||
{required String link, Map<String, dynamic>? payload}) async {
|
||||
var s = await LoginDriverController().getJwtWallet();
|
||||
var url = Uri.parse(link);
|
||||
try {
|
||||
await LoginDriverController().getJWT();
|
||||
|
||||
var response = await http.post(
|
||||
url,
|
||||
body: payload,
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'Authorization': 'Bearer $s'
|
||||
},
|
||||
);
|
||||
// print(response.request);
|
||||
// Log.print('response.body: ${response.body}');
|
||||
// print(payload);
|
||||
if (response.statusCode == 200) {
|
||||
try {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
if (jsonData['status'] == 'success') {
|
||||
return jsonData;
|
||||
} else {
|
||||
return jsonData['status'];
|
||||
}
|
||||
} catch (e) {
|
||||
addError(e.toString(), 'crud().post - JSON decoding');
|
||||
return 'failure';
|
||||
}
|
||||
} else if (response.statusCode == 401) {
|
||||
// Specifically handle 401 Unauthorized
|
||||
var jsonData = jsonDecode(response.body);
|
||||
|
||||
if (jsonData['error'] == 'Token expired') {
|
||||
return 'token_expired'; // Return a specific value for token expiration
|
||||
} else {
|
||||
// Other 401 errors
|
||||
addError('Unauthorized: ${jsonData['error']}', 'crud().post - 401');
|
||||
return 'failure';
|
||||
}
|
||||
} else {
|
||||
addError('Non-200 response code: ${response.statusCode}',
|
||||
'crud().post - Other');
|
||||
return 'failure';
|
||||
}
|
||||
} catch (e) {
|
||||
addError('HTTP request error: $e', 'crud().post - HTTP');
|
||||
return 'failure';
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> post(
|
||||
{required String link, Map<String, dynamic>? payload}) async {
|
||||
var url = Uri.parse(link);
|
||||
@@ -142,9 +197,9 @@ class CRUD {
|
||||
// 'Authorization': 'Bearer ${box.read(BoxName.jwt)}'
|
||||
},
|
||||
);
|
||||
print(response.request);
|
||||
print(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);
|
||||
@@ -154,7 +209,7 @@ class CRUD {
|
||||
return jsonData['status'];
|
||||
}
|
||||
} catch (e) {
|
||||
addError(e.toString(), 'crud().post - JSON decoding');
|
||||
addError(e.toString(), url);
|
||||
return 'failure';
|
||||
}
|
||||
} else if (response.statusCode == 401) {
|
||||
|
||||
0
lib/controller/functions/custom_pant.dart
Normal file → Executable file
0
lib/controller/functions/custom_pant.dart
Normal file → Executable file
0
lib/controller/functions/device_info.dart
Normal file → Executable file
0
lib/controller/functions/device_info.dart
Normal file → Executable file
0
lib/controller/functions/digit_obsecur_formate.dart
Normal file → Executable file
0
lib/controller/functions/digit_obsecur_formate.dart
Normal file → Executable file
0
lib/controller/functions/document_scanner.dart
Normal file → Executable file
0
lib/controller/functions/document_scanner.dart
Normal file → Executable file
0
lib/controller/functions/encrypt.dart
Normal file → Executable file
0
lib/controller/functions/encrypt.dart
Normal file → Executable file
0
lib/controller/functions/encrypt_decrypt.dart
Normal file → Executable file
0
lib/controller/functions/encrypt_decrypt.dart
Normal file → Executable file
0
lib/controller/functions/face_detect.dart
Normal file → Executable file
0
lib/controller/functions/face_detect.dart
Normal file → Executable file
0
lib/controller/functions/gemeni.dart
Normal file → Executable file
0
lib/controller/functions/gemeni.dart
Normal file → Executable file
0
lib/controller/functions/geolocation.dart
Normal file → Executable file
0
lib/controller/functions/geolocation.dart
Normal file → Executable file
0
lib/controller/functions/launch.dart
Normal file → Executable file
0
lib/controller/functions/launch.dart
Normal file → Executable file
0
lib/controller/functions/llama_ai.dart
Normal file → Executable file
0
lib/controller/functions/llama_ai.dart
Normal file → Executable file
0
lib/controller/functions/location_background_controller.dart
Normal file → Executable file
0
lib/controller/functions/location_background_controller.dart
Normal file → Executable file
89
lib/controller/functions/location_controller.dart
Normal file → Executable file
89
lib/controller/functions/location_controller.dart
Normal file → Executable file
@@ -170,7 +170,7 @@ class LocationController extends GetxController {
|
||||
|
||||
Future<void> getLocation() async {
|
||||
if (location == null) {
|
||||
location = Location(); // Ensure location is initialized
|
||||
location = Location(); // تأكد من أن `Location` مهيأ
|
||||
}
|
||||
|
||||
bool serviceEnabled;
|
||||
@@ -192,27 +192,80 @@ class LocationController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
LocationData _locationData = await location.getLocation();
|
||||
if (_locationData.latitude != null && _locationData.longitude != null) {
|
||||
myLocation = LatLng(_locationData.latitude!, _locationData.longitude!);
|
||||
} else {
|
||||
myLocation = LatLng(0, 0); // Default value
|
||||
}
|
||||
/// **تجنب استدعاء `getLocation()` مباشرة على الـ Main Thread**
|
||||
Future.delayed(Duration(milliseconds: 500), () async {
|
||||
try {
|
||||
LocationData _locationData = await location.getLocation();
|
||||
if (_locationData.latitude != null && _locationData.longitude != null) {
|
||||
myLocation =
|
||||
LatLng(_locationData.latitude!, _locationData.longitude!);
|
||||
} else {
|
||||
myLocation = LatLng(0, 0); // Default value
|
||||
}
|
||||
|
||||
speed = _locationData.speed ?? 0;
|
||||
heading = _locationData.heading ?? 0;
|
||||
speed = _locationData.speed ?? 0;
|
||||
heading = _locationData.heading ?? 0;
|
||||
|
||||
if (Get.find<HomeCaptainController>().rideId == 'rideId') {
|
||||
if (previousTime > 0) {
|
||||
double distance = calculateDistanceInKmPerHour(
|
||||
previousTime, _locationData.time, speed);
|
||||
totalDistance += distance;
|
||||
if (Get.find<HomeCaptainController>().rideId == 'rideId') {
|
||||
if (previousTime > 0) {
|
||||
double distance = calculateDistanceInKmPerHour(
|
||||
previousTime, _locationData.time, speed);
|
||||
totalDistance += distance;
|
||||
}
|
||||
previousTime = _locationData.time ?? 0;
|
||||
}
|
||||
|
||||
update();
|
||||
} catch (e) {
|
||||
print("Error getting location: $e");
|
||||
}
|
||||
previousTime = _locationData.time ?? 0;
|
||||
}
|
||||
|
||||
update();
|
||||
});
|
||||
}
|
||||
// Future<void> getLocation() async {
|
||||
// if (location == null) {
|
||||
// location = Location(); // Ensure location is initialized
|
||||
// }
|
||||
|
||||
// bool serviceEnabled;
|
||||
// PermissionStatus permissionGranted;
|
||||
|
||||
// serviceEnabled = await location.serviceEnabled();
|
||||
// if (!serviceEnabled) {
|
||||
// serviceEnabled = await location.requestService();
|
||||
// if (!serviceEnabled) {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// permissionGranted = await location.hasPermission();
|
||||
// if (permissionGranted == PermissionStatus.denied) {
|
||||
// permissionGranted = await location.requestPermission();
|
||||
// if (permissionGranted != PermissionStatus.granted) {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// LocationData _locationData = await location.getLocation();
|
||||
// if (_locationData.latitude != null && _locationData.longitude != null) {
|
||||
// myLocation = LatLng(_locationData.latitude!, _locationData.longitude!);
|
||||
// } else {
|
||||
// myLocation = LatLng(0, 0); // Default value
|
||||
// }
|
||||
|
||||
// speed = _locationData.speed ?? 0;
|
||||
// heading = _locationData.heading ?? 0;
|
||||
|
||||
// if (Get.find<HomeCaptainController>().rideId == 'rideId') {
|
||||
// if (previousTime > 0) {
|
||||
// double distance = calculateDistanceInKmPerHour(
|
||||
// previousTime, _locationData.time, speed);
|
||||
// totalDistance += distance;
|
||||
// }
|
||||
// previousTime = _locationData.time ?? 0;
|
||||
// }
|
||||
|
||||
// update();
|
||||
// }
|
||||
|
||||
double calculateDistanceInKmPerHour(
|
||||
double? startTime, double? endTime, double speedInMetersPerSecond) {
|
||||
|
||||
0
lib/controller/functions/location_permission.dart
Normal file → Executable file
0
lib/controller/functions/location_permission.dart
Normal file → Executable file
0
lib/controller/functions/log_out.dart
Normal file → Executable file
0
lib/controller/functions/log_out.dart
Normal file → Executable file
0
lib/controller/functions/ocr_controller.dart
Normal file → Executable file
0
lib/controller/functions/ocr_controller.dart
Normal file → Executable file
0
lib/controller/functions/overlay_permisssion.dart
Normal file → Executable file
0
lib/controller/functions/overlay_permisssion.dart
Normal file → Executable file
52
lib/controller/functions/package_info.dart
Normal file → Executable file
52
lib/controller/functions/package_info.dart
Normal file → Executable file
@@ -164,23 +164,45 @@ void showUpdateDialog(BuildContext context) {
|
||||
);
|
||||
}
|
||||
|
||||
getDeviceFingerprint() async {
|
||||
final deviceInfo = await DeviceInfoPlugin().deviceInfo;
|
||||
var deviceData;
|
||||
class DeviceHelper {
|
||||
static Future<String> getDeviceFingerprint() async {
|
||||
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
|
||||
var deviceData;
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
deviceData = deviceInfo.data;
|
||||
} else if (Platform.isIOS) {
|
||||
deviceData = deviceInfo.data;
|
||||
try {
|
||||
if (Platform.isAndroid) {
|
||||
// Fetch Android-specific device information
|
||||
AndroidDeviceInfo androidInfo = await deviceInfoPlugin.androidInfo;
|
||||
deviceData = androidInfo.toMap(); // Convert to a map for easier access
|
||||
// Log.print('deviceData: ${jsonEncode(deviceData)}');
|
||||
} else if (Platform.isIOS) {
|
||||
// Fetch iOS-specific device information
|
||||
IosDeviceInfo iosInfo = await deviceInfoPlugin.iosInfo;
|
||||
deviceData = iosInfo.toMap(); // Convert to a map for easier access
|
||||
} else {
|
||||
throw UnsupportedError('Unsupported platform');
|
||||
}
|
||||
|
||||
// Extract relevant device information
|
||||
final String deviceId = Platform.isAndroid
|
||||
? deviceData['androidId'] ?? deviceData['serialNumber'] ?? 'unknown'
|
||||
: deviceData['identifierForVendor'] ?? 'unknown';
|
||||
|
||||
final String deviceModel = deviceData['model'] ?? 'unknown';
|
||||
final String osVersion = Platform.isAndroid
|
||||
? deviceData['version']['release'] ?? 'unknown'
|
||||
: deviceData['systemVersion'] ?? 'unknown';
|
||||
|
||||
// Log the extracted information
|
||||
|
||||
// Generate and return the encrypted fingerprint
|
||||
final String fingerprint = '${deviceId}_${deviceModel}_$osVersion';
|
||||
print(EncryptionHelper.instance.encryptData(fingerprint));
|
||||
return EncryptionHelper.instance.encryptData(fingerprint);
|
||||
} catch (e) {
|
||||
throw Exception('Failed to generate device fingerprint');
|
||||
}
|
||||
}
|
||||
|
||||
final String deviceId =
|
||||
deviceData['androidId'] ?? deviceData['identifierForVendor'];
|
||||
final String deviceModel = deviceData['model'];
|
||||
final String osVersion = deviceData['systemVersion'];
|
||||
|
||||
return EncryptionHelper.instance
|
||||
.encryptData('${deviceId}_${deviceModel}_$osVersion');
|
||||
}
|
||||
|
||||
class SecurityHelper {
|
||||
|
||||
0
lib/controller/functions/remove_account.dart
Normal file → Executable file
0
lib/controller/functions/remove_account.dart
Normal file → Executable file
0
lib/controller/functions/scan_id_card.dart
Normal file → Executable file
0
lib/controller/functions/scan_id_card.dart
Normal file → Executable file
6
lib/controller/functions/secure_storage.dart
Normal file → Executable file
6
lib/controller/functions/secure_storage.dart
Normal file → Executable file
@@ -72,11 +72,7 @@ class AppInitializer {
|
||||
await CRUD().get(link: AppLink.getLocationAreaLinks, payload: {});
|
||||
if (res != 'failure') {
|
||||
links = List<Map<String, dynamic>>.from(jsonDecode(res)['message']);
|
||||
await box.remove(BoxName.locationName);
|
||||
await box.remove(BoxName.basicLink);
|
||||
await box.remove(links[4]['name']);
|
||||
await box.remove(links[1]['name']);
|
||||
await box.remove(links[2]['name']);
|
||||
|
||||
await box.write(BoxName.locationName, links);
|
||||
await box.write(BoxName.basicLink,
|
||||
EncryptionHelper.instance.decryptData(links[0]['server_link']));
|
||||
|
||||
0
lib/controller/functions/security_checks.dart
Normal file → Executable file
0
lib/controller/functions/security_checks.dart
Normal file → Executable file
0
lib/controller/functions/sms_egypt_controller.dart
Normal file → Executable file
0
lib/controller/functions/sms_egypt_controller.dart
Normal file → Executable file
0
lib/controller/functions/toast.dart
Normal file → Executable file
0
lib/controller/functions/toast.dart
Normal file → Executable file
0
lib/controller/functions/tts.dart
Normal file → Executable file
0
lib/controller/functions/tts.dart
Normal file → Executable file
0
lib/controller/functions/twilio_service.dart
Normal file → Executable file
0
lib/controller/functions/twilio_service.dart
Normal file → Executable file
0
lib/controller/functions/upload_image.dart
Normal file → Executable file
0
lib/controller/functions/upload_image.dart
Normal file → Executable file
0
lib/controller/functions/vibrate.dart
Normal file → Executable file
0
lib/controller/functions/vibrate.dart
Normal file → Executable file
Reference in New Issue
Block a user