This commit is contained in:
Hamza-Ayed
2024-12-22 01:36:07 +03:00
parent 90d4ca39bf
commit 2910750483
32 changed files with 1804 additions and 1231 deletions

View File

@@ -1,93 +1,93 @@
import 'dart:io';
import 'package:get/get.dart';
import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart';
// import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart';
import 'package:image_cropper/image_cropper.dart';
import 'package:image_picker/image_picker.dart';
import 'package:sefer_driver/constant/colors.dart';
import 'package:sefer_driver/controller/functions/llama_ai.dart';
class CarRegistrationRecognizerController extends GetxController {
@override
void onInit() {
// scanText();
super.onInit();
}
// class CarRegistrationRecognizerController extends GetxController {
// @override
// void onInit() {
// // scanText();
// super.onInit();
// }
// The ImagePicker instance
final ImagePicker _imagePicker = ImagePicker();
// // The ImagePicker instance
// final ImagePicker _imagePicker = ImagePicker();
// The GoogleMlKit TextRecognizer instance
final TextRecognizer _textRecognizer = TextRecognizer();
// // The GoogleMlKit TextRecognizer instance
// // final TextRecognizer _textRecognizer = TextRecognizer();
// The scanned text
String? scannedText;
String? jsonOutput;
final List<Map<String, dynamic>> lines = [];
Map extracted = {};
XFile? image;
CroppedFile? croppedFile;
// Picks an image from the camera or gallery and extracts the text
final List<Map<String, dynamic>> extractedTextWithCoordinates = [];
// // The scanned text
// String? scannedText;
// String? jsonOutput;
// final List<Map<String, dynamic>> lines = [];
// Map extracted = {};
// XFile? image;
// CroppedFile? croppedFile;
// // Picks an image from the camera or gallery and extracts the text
// final List<Map<String, dynamic>> extractedTextWithCoordinates = [];
Future<void> scanText() async {
// Pick an image from the camera or gallery
image = await _imagePicker.pickImage(source: ImageSource.gallery);
update();
// Future<void> scanText() async {
// // Pick an image from the camera or gallery
// image = await _imagePicker.pickImage(source: ImageSource.gallery);
// update();
// If no image was picked, return
if (image == null) {
return;
}
// // If no image was picked, return
// if (image == null) {
// return;
// }
// Crop the image
croppedFile = await ImageCropper().cropImage(
sourcePath: image!.path,
//
uiSettings: [
AndroidUiSettings(
toolbarTitle: 'Cropper'.tr,
toolbarColor: AppColor.blueColor,
toolbarWidgetColor: AppColor.yellowColor,
initAspectRatio: CropAspectRatioPreset.original,
lockAspectRatio: false),
IOSUiSettings(
title: 'Cropper'.tr,
),
],
);
// // Crop the image
// croppedFile = await ImageCropper().cropImage(
// sourcePath: image!.path,
// //
// uiSettings: [
// AndroidUiSettings(
// toolbarTitle: 'Cropper'.tr,
// toolbarColor: AppColor.blueColor,
// toolbarWidgetColor: AppColor.yellowColor,
// initAspectRatio: CropAspectRatioPreset.original,
// lockAspectRatio: false),
// IOSUiSettings(
// title: 'Cropper'.tr,
// ),
// ],
// );
// If no cropped image was obtained, return
if (croppedFile == null) {
return;
}
// // If no cropped image was obtained, return
// if (croppedFile == null) {
// return;
// }
// Convert the cropped file to an InputImage object
final InputImage inputImage = InputImage.fromFile(File(croppedFile!.path));
// // Convert the cropped file to an InputImage object
// final InputImage inputImage = InputImage.fromFile(File(croppedFile!.path));
// Recognize the text in the image
final RecognizedText recognizedText =
await _textRecognizer.processImage(inputImage);
scannedText = recognizedText.text;
// // Recognize the text in the image
// final RecognizedText recognizedText =
// await _textRecognizer.processImage(inputImage);
// scannedText = recognizedText.text;
// Extract the scanned text line by line
final List<Map<String, dynamic>> lines = [];
for (var i = 0; i < recognizedText.blocks.length; i++) {
lines.add({
i.toString(): recognizedText.blocks[i].text,
});
}
// // Extract the scanned text line by line
// final List<Map<String, dynamic>> lines = [];
// for (var i = 0; i < recognizedText.blocks.length; i++) {
// lines.add({
// i.toString(): recognizedText.blocks[i].text,
// });
// }
String result = lines.map((map) => map.values.first.toString()).join(' ');
if (result.length > 2200) {
result = result.substring(0, 2200);
}
Map result2 = await LlamaAi().getCarRegistrationData(result,
'vin,make,made,year,expiration_date,color,owner,registration_date'); //
// String result = lines.map((map) => map.values.first.toString()).join(' ');
// if (result.length > 2200) {
// result = result.substring(0, 2200);
// }
// Map result2 = await LlamaAi().getCarRegistrationData(result,
// 'vin,make,made,year,expiration_date,color,owner,registration_date'); //
// Assign the result to the extracted variable
extracted = result2;
// // Assign the result to the extracted variable
// extracted = result2;
update();
}
}
// update();
// }
// }

View File

@@ -313,7 +313,7 @@ class RegisterCaptainController extends GetxController {
'') {
Get.offAll(() => HomeCaptain());
} else {
Get.to(() => CarLicensePage());
// Get.to(() => CarLicensePage());
}
}
}

View File

@@ -29,8 +29,8 @@ class NotificationController extends GetxController {
requestAlertPermission: true,
requestBadgePermission: true,
requestSoundPermission: true,
onDidReceiveLocalNotification:
(int id, String? title, String? body, String? payload) async {},
// onDidReceiveLocalNotification:
// (int id, String? title, String? body, String? payload) async {},
);
InitializationSettings initializationSettings =
InitializationSettings(android: android, iOS: ios);
@@ -176,11 +176,12 @@ class NotificationController extends GetxController {
message,
scheduledTime,
details,
androidAllowWhileIdle: true,
// androidAllowWhileIdle: true,
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime,
matchDateTimeComponents:
DateTimeComponents.time, // Triggers daily at the same time
matchDateTimeComponents: DateTimeComponents.time,
androidScheduleMode:
AndroidScheduleMode.alarmClock, // Triggers daily at the same time
);
print('Notification scheduled successfully');
}
@@ -232,6 +233,7 @@ class NotificationController extends GetxController {
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime,
matchDateTimeComponents: DateTimeComponents.time,
androidScheduleMode: AndroidScheduleMode.alarmClock,
);
print('Notification scheduled successfully');
});
@@ -397,10 +399,11 @@ class NotificationController extends GetxController {
message.tr,
scheduledTime,
details,
androidAllowWhileIdle: true,
// androidAllowWhileIdle: true,
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime,
matchDateTimeComponents: DateTimeComponents.time,
androidScheduleMode: AndroidScheduleMode.alarmClock,
);
});

View File

@@ -3,7 +3,7 @@ import 'dart:io';
import 'package:camera/camera.dart';
import 'package:get/get.dart';
import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart';
// import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart';
import 'package:sefer_driver/constant/box_name.dart';
import 'package:sefer_driver/constant/links.dart';
import 'package:sefer_driver/views/widgets/elevated_btn.dart';
@@ -16,7 +16,7 @@ class CameraClassController extends GetxController {
late CameraController cameraController;
late List<CameraDescription> cameras;
bool isCameraInitialized = false;
final TextRecognizer _textRecognizer = TextRecognizer();
// final TextRecognizer _textRecognizer = TextRecognizer();
String? scannedText;
bool isloading = false;
@@ -126,45 +126,45 @@ class CameraClassController extends GetxController {
return responseString;
}
Future<void> takePictureAndMLGoogleScan() async {
try {
// Construct the path for the image file
final directory = await path_provider.getTemporaryDirectory();
final imagePath =
path.join(directory.path, '${box.read(BoxName.driverID)}.png');
// Future<void> takePictureAndMLGoogleScan() async {
// try {
// // Construct the path for the image file
// final directory = await path_provider.getTemporaryDirectory();
// final imagePath =
// path.join(directory.path, '${box.read(BoxName.driverID)}.png');
// Capture the image and save it to the specified path
final XFile capturedImage = await cameraController.takePicture();
// // Capture the image and save it to the specified path
// final XFile capturedImage = await cameraController.takePicture();
// Move the captured image to the desired path
await capturedImage.saveTo(imagePath);
// // Move the captured image to the desired path
// await capturedImage.saveTo(imagePath);
// Recognize the text in the image
final InputImage inputImage =
InputImage.fromFile(File(capturedImage.path));
final RecognizedText recognizedText =
await _textRecognizer.processImage(inputImage);
scannedText = recognizedText.text;
// // Recognize the text in the image
// final InputImage inputImage =
// InputImage.fromFile(File(capturedImage.path));
// final RecognizedText recognizedText =
// await _textRecognizer.processImage(inputImage);
// scannedText = recognizedText.text;
// Extract the scanned text line by line
final List<Map<String, dynamic>> lines = [];
for (var i = 0; i < recognizedText.blocks.length; i++) {
lines.add({
'line_number': i,
'text': recognizedText.blocks[i].text,
});
}
// // Extract the scanned text line by line
// final List<Map<String, dynamic>> lines = [];
// for (var i = 0; i < recognizedText.blocks.length; i++) {
// lines.add({
// 'line_number': i,
// 'text': recognizedText.blocks[i].text,
// });
// }
// Convert the list of lines to a JSON string
final String jsonOutput = jsonEncode(lines);
// // Convert the list of lines to a JSON string
// final String jsonOutput = jsonEncode(lines);
update();
// update();
// Print the JSON output
// // Print the JSON output
// Get.back();
} catch (e) {}
}
// // Get.back();
// } catch (e) {}
// }
String getTextAsJSON(String text) {
final lines = text.split('\n');

View File

@@ -42,6 +42,8 @@ enum DocumentType {
carLicenseFront,
carLicenseBack,
idCardFront,
nonIdCardFront,
nonIdCardBack,
idCardBack,
driverLicense,
unknown,
@@ -150,6 +152,14 @@ class AI extends GetxController {
// Check if the inspection date is before today
final inspectionDateTime = DateTime(year, 12, 31);
final isInspectionExpired = inspectionDateTime.isBefore(today);
// Add birthdate comparison for non-Egyptian ID
final frontBirthDate =
DateTime.tryParse(responseNonIdCardFront['birthdate'] ?? '');
final backBirthDate =
DateTime.tryParse(responseNonIdCardBack['birthDate'] ?? '');
final birthdatesMismatch = frontBirthDate != null &&
backBirthDate != null &&
frontBirthDate != backBirthDate;
if (isExpiredCar || isInspectionExpired) {
Get.defaultDialog(
@@ -186,6 +196,41 @@ class AI extends GetxController {
),
],
);
} else if (birthdatesMismatch && !isEgypt) {
Get.defaultDialog(
title: 'Birthdate Mismatch'.tr,
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.warning, size: 48, color: Colors.red),
const SizedBox(height: 16),
Text(
"The birthdate on your ID front doesn't match the one on the back. Please verify your documents."
.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
),
const SizedBox(height: 16),
IconButton(
onPressed: () async {
await Get.find<TextToSpeechController>().speakText(
"The birthdate on your ID front doesn't match the one on the back. Please verify your documents."
.tr,
);
},
icon: const Icon(Icons.volume_up),
),
],
),
actions: [
TextButton(
onPressed: () {
Get.back();
},
child: const Text('OK'),
),
],
);
} else if (isExpired) {
Get.defaultDialog(
title: 'Expired Drivers License'.tr,
@@ -298,7 +343,7 @@ class AI extends GetxController {
// );
// }
else {
await addDriverEgypt();
isEgypt ? await addDriverEgypt() : await addDriverForeign();
await addRegistrationCarEgypt();
if (isCarSaved && isDriverSaved) {
@@ -343,6 +388,99 @@ class AI extends GetxController {
return dob;
}
Future<void> addDriverForeign() async {
isLoading = true;
update();
var payload = {
'first_name':
responseNonIdCardFront['full_name']?.toString().split(' ')[0] ??
'Not specified',
'last_name':
responseNonIdCardFront['full_name']?.toString().split(' ').last ??
'Not specified',
'email': box.read(BoxName.emailDriver)?.toString() ?? 'Not specified',
'phone': box.read(BoxName.phoneDriver)?.toString() ?? 'Not specified',
'id': box.read(BoxName.driverID)?.toString() ?? 'Not specified',
'password':
Get.put(LoginDriverController()).passwordController.text.isEmpty
? box.read(BoxName.emailDriver).toString()
: Get.find<LoginDriverController>()
.passwordController
.text
.toString(),
'gender': responseNonIdCardFront['gender']?.toString() ?? 'Not specified',
'license_type': 'Foreign',
'national_number':
responseNonIdCardFront['passport_no']?.toString() ?? 'Not specified',
'name_arabic':
responseNonIdCardFront['full_name']?.toString() ?? 'Not specified',
'name_english': 'Not specified',
'issue_date':
responseNonIdCardBack['issueDate']?.toString() ?? 'Not specified',
'expiry_date':
responseNonIdCardBack['residencyExpirationDate']?.toString() ??
'Not specified',
'license_categories': responseIdEgyptDriverLicense['license_categories']
is List
? responseIdEgyptDriverLicense['license_categories'].join(', ')
: responseIdEgyptDriverLicense['license_categories']?.toString() ??
'Not specified',
'address':
responseNonIdCardFront['address']?.toString() ?? 'Not specified',
'card_id':
responseNonIdCardFront['card_id']?.toString() ?? 'Not specified',
'occupation':
responseNonIdCardBack['workStatus']?.toString() ?? 'Not specified',
'education': 'Not specified',
'licenseIssueDate':
responseNonIdCardBack['issueDate']?.toString() ?? 'Not specified',
'religion':
responseNonIdCardFront['country']?.toString() ?? 'Not specified',
'status': 'yet',
'birthdate':
responseNonIdCardFront['birthdate']?.toString() ?? 'Not specified',
'maritalStatus': 'Not specified',
'site': responseNonIdCardFront['address']?.toString() ?? 'Not specified',
'employmentType':
responseNonIdCardBack['residencyType']?.toString() ?? 'Not specified',
};
try {
var res = await CRUD().post(link: AppLink.signUpCaptin, payload: payload);
var status1;
try {
status1 = jsonDecode(res);
} catch (e) {
throw FormatException("Invalid JSON response: $res");
}
isLoading = false;
update();
if (status1['status'] == 'success') {
isDriverSaved = true;
CRUD().post(
link: '${AppLink.seferGizaServer}/auth/captin/register.php',
payload: payload);
CRUD().post(
link: '${AppLink.seferAlexandriaServer}/auth/captin/register.php',
payload: payload);
mySnackbarSuccess('Foreign driver data saved successfully');
} else {
mySnackeBarError(
'${'Failed to save driver data'.tr}: ${status1['message']}');
}
} catch (e) {
isLoading = false;
update();
mySnackeBarError(
'An error occurred while saving driver data'.tr,
);
}
}
Future<void> addDriverEgypt() async {
isLoading = true;
update();
@@ -542,16 +680,24 @@ class AI extends GetxController {
Map<String, dynamic> responseForComplaint = {};
Map<String, dynamic> responseIdCardDriverEgyptFront = {};
Map<String, dynamic> responseIdEgyptFront = {};
Map<String, dynamic> responseNonIdCardFront = {};
Map<String, dynamic> responseNonIdCardBack = {};
Map<String, dynamic> responseCriminalRecordEgypt = {};
Map<String, dynamic> responseIdEgyptBack = {};
Map<String, dynamic> responseIdEgyptDriverLicense = {};
String? responseIdCardDriverEgypt1;
bool isloading = false;
bool isLoading = false;
bool isEgypt = true;
var image;
CroppedFile? croppedFile;
DateTime now = DateTime.now();
changeNationality() {
isEgypt = !isEgypt;
update();
}
Future<void> pickImage() async {
final pickedImage = await picker.pickImage(source: ImageSource.gallery);
@@ -607,6 +753,12 @@ class AI extends GetxController {
],
DocumentType.idCardBack: ['البطاقةساريةحتى'],
DocumentType.driverLicense: ['قيادةخاصة', 'خاصه', 'قيادة'],
DocumentType.nonIdCardFront: ['Foreign Residence Card', 'أجنبي', 'جواز'],
DocumentType.nonIdCardBack: [
'نوع الإقامة',
'الإقامة',
'Cardexpiresbyendofresidencepermit'
],
};
// Check each document type
@@ -637,7 +789,10 @@ class AI extends GetxController {
var extractedString =
await CRUD().arabicTextExtractByVisionAndAI(imagePath: imagePath);
var json = jsonDecode(extractedString);
// Log.print('extractedString: ${extractedString}');
var textValues = CRUD().extractTextFromLines(json);
Log.print('textValues: ${textValues}');
// Log.print('json: ${json}');
DocumentType detectedType = checkDocumentType(textValues);
String expectedDocument = getExpectedDocument(imagePath);
@@ -720,6 +875,10 @@ class AI extends GetxController {
return 'id_card_back'.tr;
case 'id_front':
return 'id_card_front'.tr;
case 'non_id_front':
return 'non_id_card_front'.tr;
case 'non_id_back':
return 'non_id_card_back'.tr;
case 'driver_license':
return 'driver_license'.tr;
default:
@@ -737,6 +896,10 @@ class AI extends GetxController {
return DocumentType.idCardBack;
case 'id_front':
return DocumentType.idCardFront;
case 'non_id_front':
return DocumentType.nonIdCardFront;
case 'non_id_back':
return DocumentType.nonIdCardBack;
case 'driver_license':
return DocumentType.driverLicense;
default:
@@ -754,6 +917,10 @@ class AI extends GetxController {
return 'id_card_front'.tr;
case DocumentType.idCardBack:
return 'id_card_back'.tr;
case DocumentType.nonIdCardFront:
return 'non_id_card_front'.tr;
case DocumentType.nonIdCardBack:
return 'non_id_card_back'.tr;
case DocumentType.driverLicense:
return 'driver_license'.tr;
default:
@@ -938,6 +1105,11 @@ class AI extends GetxController {
} else if (idType == 'criminalRecord') {
responseCriminalRecordEgypt =
jsonDecode(responseData['content'][0]['text']);
} else if (idType == 'non_id_front') {
responseNonIdCardFront = jsonDecode(responseData['content'][0]['text']);
Log.print('responseNonIdCardFront: ${responseNonIdCardFront}');
} else if (idType == 'non_id_back') {
responseNonIdCardBack = jsonDecode(responseData['content'][0]['text']);
}
update();
@@ -1014,6 +1186,12 @@ class AI extends GetxController {
responseIdEgyptBack = jsonDecode(jsonString);
} else if (idType == 'driver_license') {
responseIdEgyptDriverLicense = jsonDecode(jsonString);
} else if (idType == 'non_id_front') {
responseNonIdCardFront =
jsonDecode(responseData['content'][0]['text']);
} else if (idType == 'non_id_back') {
responseNonIdCardBack =
jsonDecode(responseData['content'][0]['text']);
}
update();

View File

@@ -1,21 +1,20 @@
import 'dart:async';
import 'package:sefer_driver/controller/home/captin/home_captain_controller.dart';
import 'package:get/get.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:location/location.dart';
import 'package:sefer_driver/constant/box_name.dart';
import 'package:sefer_driver/constant/links.dart';
import 'package:sefer_driver/controller/functions/crud.dart';
import 'package:sefer_driver/controller/home/payment/captain_wallet_controller.dart';
import 'package:sefer_driver/main.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';
// LocationController.dart
class LocationController extends GetxController {
LocationData? _currentLocation;
late Location location;
late Location location = Location();
bool isLoading = false;
late double heading = 0;
late double accuracy = 0;
@@ -28,7 +27,7 @@ class LocationController extends GetxController {
late double speedAccuracy = 0;
late double headingAccuracy = 0;
bool isActive = false;
late LatLng myLocation;
late LatLng myLocation = LatLng(0, 0); // Default value
String totalPoints = '0';
LocationData? get currentLocation => _currentLocation;
Timer? _locationTimer;
@@ -36,13 +35,13 @@ class LocationController extends GetxController {
@override
void onInit() async {
super.onInit();
location = Location();
getLocation();
// startLocationUpdates();
location = Location(); // Initialize the location object
await getLocation(); // Fetch the location immediately
startLocationUpdates(); // Start periodic location updates
totalPoints = Get.put(CaptainWalletController()).totalPoints.toString();
// isActive = Get.put(HomeCaptainController()).isActive;
} // Function to determine which area the coordinates belong to
isActive = Get.put(HomeCaptainController()).isActive;
}
String getLocationArea(double latitude, double longitude) {
if (latitude >= 29.918901 &&
@@ -67,6 +66,10 @@ class LocationController extends GetxController {
Future<void> startLocationUpdates() async {
if (box.read(BoxName.driverID) != null) {
if (location == null) {
location = Location(); // Ensure location is initialized
}
_locationTimer =
Timer.periodic(const Duration(seconds: 5), (timer) async {
try {
@@ -77,10 +80,12 @@ class LocationController extends GetxController {
if (isActive) {
if (double.parse(totalPoints) > -300) {
await getLocation();
if (myLocation == null) {
return;
}
print(
'Latitude: ${myLocation.latitude}, Longitude: ${myLocation.longitude}');
// Determine the area
String area =
getLocationArea(myLocation.latitude, myLocation.longitude);
print('Determined Area: $area');
@@ -89,56 +94,25 @@ class LocationController extends GetxController {
switch (area) {
case 'Cairo':
print('Area matched: Cairo');
box.write(BoxName.serverChosen, AppLink.seferCairoServer);
endpoint = AppLink.addCarsLocationCairoEndpoint;
break;
case 'Giza':
print('Area matched: Giza');
box.write(BoxName.serverChosen, AppLink.seferGizaServer);
endpoint = AppLink.addCarsLocationGizaEndpoint;
break;
case 'Alexandria':
print('Area matched: Alexandria');
box.write(
BoxName.serverChosen, AppLink.seferAlexandriaServer);
endpoint = AppLink.addCarsLocationAlexandriaEndpoint;
break;
default:
print('Unknown location area. Fallback to Cairo');
endpoint = AppLink.addCarsLocationCairoEndpoint;
box.write(BoxName.serverChosen, AppLink.seferCairoServer);
}
Log.print('Final Endpoint: $endpoint');
switch (area) {
case 'Cairo':
box.write(BoxName.serverChosen, AppLink.seferCairoServer);
endpoint = AppLink.addCarsLocationCairoEndpoint;
Log.print('Endpoint: $endpoint');
break;
case 'Giza':
box.write(BoxName.serverChosen, AppLink.seferGizaServer);
endpoint = AppLink.addCarsLocationGizaEndpoint;
Log.print('Endpoint: $endpoint');
break;
case 'Alexandria':
box.write(
BoxName.serverChosen, AppLink.seferAlexandriaServer);
endpoint = AppLink.addCarsLocationAlexandriaEndpoint;
Log.print('Endpoint: $endpoint');
break;
default:
// Handle any other unexpected cases
print('Unknown location area');
endpoint = AppLink
.addCarsLocationCairoEndpoint; // Fallback to Cairo endpoint
Log.print('Fallback Endpoint: $endpoint');
box.write(BoxName.serverChosen, AppLink.seferCairoServer);
return;
}
// Ensure driver ID exists before making the API call
if (box.read(BoxName.driverID) != null) {
await CRUD().post(link: endpoint, payload: {
'driver_id': box.read(BoxName.driverID).toString(),
@@ -154,7 +128,6 @@ class LocationController extends GetxController {
'status': box.read(BoxName.statusDriverLocation).toString(),
});
// Update the camera position on the map
Get.find<HomeCaptainController>()
.mapHomeCaptainController
?.animateCamera(
@@ -169,7 +142,6 @@ class LocationController extends GetxController {
}
}
} catch (e) {
// Handle the error gracefully
Log.print('Error during location update: $e');
}
});
@@ -181,75 +153,58 @@ class LocationController extends GetxController {
}
Future<void> getLocation() async {
// isLoading = true;
// update();
if (location == null) {
location = Location(); // Ensure location is initialized
}
bool serviceEnabled;
PermissionStatus permissionGranted;
// Check if location services are enabled
serviceEnabled = await location.serviceEnabled();
if (!serviceEnabled) {
serviceEnabled = await location.requestService();
if (!serviceEnabled) {
// Location services are still not enabled, handle the error
return;
}
}
// Check if the app has permission to access location
permissionGranted = await location.hasPermission();
if (permissionGranted == PermissionStatus.denied) {
permissionGranted = await location.requestPermission();
if (permissionGranted != PermissionStatus.granted) {
// Location permission is still not granted, handle the error
return;
}
}
// Configure location accuracy
// LocationAccuracy desiredAccuracy = LocationAccuracy.high;
// Get the current location
LocationData _locationData = await location.getLocation();
myLocation =
(_locationData.latitude != null && _locationData.longitude != null
? LatLng(_locationData.latitude!, _locationData.longitude!)
: null)!;
getLocationArea(_locationData.latitude!, _locationData.longitude!);
speed = _locationData.speed!;
heading = _locationData.heading!;
// Calculate the distance between the current location and the previous location
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') {
Log.print(
'Get.find<HomeCaptainController>().rideId: ${Get.find<HomeCaptainController>().rideId}');
if (previousTime > 0) {
double distance = calculateDistanceInKmPerHour(
previousTime, _locationData.time, speed);
totalDistance += distance;
}
previousTime = _locationData.time!;
previousTime = _locationData.time ?? 0;
}
// Print location details
// isLoading = false;
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 timeDifferenceInHours =
(endTime ?? 0 - startTime! ?? 0) / 1000 / 3600;
double speedInKmPerHour = speedInMetersPerSecond * 3.6;
// Calculate the distance in kilometers
double distanceInKilometers = speedInKmPerHour * timeDifferenceInHours;
// 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;
}
}

View File

@@ -90,7 +90,7 @@ class HomeCaptainController extends GetxController {
isActive = !isActive;
if (isActive) {
if (double.parse(totalPoints) > -300) {
locationController.startLocationUpdates();
// locationController.startLocationUpdates();
// locationBackController.startBackLocation();
activeStartTime = DateTime.now();
activeTimer = Timer.periodic(const Duration(seconds: 1), (timer) {

View File

@@ -584,7 +584,7 @@ class MapDriverController extends GetxController {
Get.find<LocationController>().myLocation.longitude,
);
if (distanceToDestination > double.parse(distance.toString()) / 3) {
if (distanceToDestination > (double.parse(distance.toString()) / 3)) {
Log.print('distanceToDestination: ${distanceToDestination}');
MyDialog().getDialog(

View File

@@ -170,7 +170,7 @@ class MyTranslation extends Translations {
'Remaining time': 'الوقت المتبقي',
'Add bank Account': 'إضافة حساب بنكي',
'Are you sure to exit ride?': 'هل أنت متأكد من إنهاء الرحلة؟',
"Today": "اليوم",
"seconds": "ثواني",
'You will cancel registration': 'ستقوم بإلغاء التسجيل',
"Create new Account": "إنشاء حساب جديد",

View File

@@ -81,8 +81,8 @@ class RideAvailableController extends GetxController {
getRideAvailable() async {
isLoading = true;
LatLngBounds bounds = calculateBounds(
Get.find<LocationController>().myLocation.latitude,
Get.find<LocationController>().myLocation.longitude,
Get.find<LocationController>().myLocation!.latitude,
Get.find<LocationController>().myLocation!.longitude,
4000);
var payload = {
// "carType": box.read(BoxName.carTypeOfDriver).toString(),

View File

@@ -44,7 +44,8 @@ class RateController extends GetxController {
Future addPassengerWallet() async {
if (formKey.currentState!.validate()) {
var priceOfTrip =
double.parse(Get.find<MapDriverController>().paymentAmount);
double.parse(price.toString());
// double.parse(Get.find<MapDriverController>().paymentAmount);
double remainingFee = double.parse(passengerPayAmount.text) - priceOfTrip;
if (remainingFee > 0) {
var paymentToken2 = await Get.find<MapDriverController>()

View File

@@ -23,7 +23,6 @@ import 'constant/notification.dart';
import 'controller/firebase/firbase_messge.dart';
import 'controller/firebase/local_notification.dart';
import 'controller/functions/location_controller.dart';
import 'controller/functions/overlay_permisssion.dart';
import 'controller/local/local_controller.dart';
import 'controller/local/translations.dart';
import 'controller/payment/paymob/paymob_wallet.dart';

View File

@@ -10,160 +10,160 @@ import '../../../controller/auth/captin/register_captin_controller.dart';
import '../../widgets/elevated_btn.dart';
import '../../widgets/my_scafold.dart';
class CarLicensePage extends StatelessWidget {
CarLicensePage({super.key});
CarRegistrationRecognizerController carRegistrationRecognizerController =
Get.put(CarRegistrationRecognizerController());
RegisterCaptainController registerCaptainController =
Get.put(RegisterCaptainController());
// class CarLicensePage extends StatelessWidget {
// CarLicensePage({super.key});
// // CarRegistrationRecognizerController carRegistrationRecognizerController =
// // Get.put(CarRegistrationRecognizerController());
// RegisterCaptainController registerCaptainController =
// Get.put(RegisterCaptainController());
@override
Widget build(BuildContext context) {
Get.find<ScanDocumentsByApi>().uploadImagePortrate();
return MyScafolld(
title: 'Car License Card'.tr,
body: [
Positioned(
top: 3,
left: Get.width * .2,
right: Get.width * .2,
child: MyElevatedButton(
title: 'Take Picture Of ID Card'.tr,
onPressed: () async {
//0vQRyaYYDWpsv73A5CZOknseK7S2sgwE
//3vQRyaYYSWpmv69A58ZOkxmeK6M1mgwEDlXrXlBl
//0pALdqDDYHvzp73Q59SIgbzjG7Z2zkhJXr
// String? visionApi = AK.serverPHP;
await carRegistrationRecognizerController.scanText();
},
)),
Positioned(
top: 50,
child: SizedBox(
height: Get.height * .6,
width: Get.width,
child: buildImageWithBoundingBoxes(),
),
),
Positioned(
bottom: Get.height * .2,
left: Get.width * .2,
right: Get.width * .2,
child: MyElevatedButton(
title: 'Register'.tr,
onPressed: () async {
// registerCaptainController.addLisence();
// registerCaptainController.register();
registerCaptainController.addRegisrationCarForDriver(
carRegistrationRecognizerController.extracted['vin'],
carRegistrationRecognizerController.extracted['make'],
carRegistrationRecognizerController.extracted['model'],
carRegistrationRecognizerController.extracted['year'],
carRegistrationRecognizerController.extracted['color'],
carRegistrationRecognizerController.extracted['owner'],
carRegistrationRecognizerController
.extracted['expiration_date'],
carRegistrationRecognizerController
.extracted['registration_date'],
);
},
)),
],
isleading: true);
}
}
// @override
// Widget build(BuildContext context) {
// Get.find<ScanDocumentsByApi>().uploadImagePortrate();
// return MyScafolld(
// title: 'Car License Card'.tr,
// body: [
// Positioned(
// top: 3,
// left: Get.width * .2,
// right: Get.width * .2,
// child: MyElevatedButton(
// title: 'Take Picture Of ID Card'.tr,
// onPressed: () async {
// //0vQRyaYYDWpsv73A5CZOknseK7S2sgwE
// //3vQRyaYYSWpmv69A58ZOkxmeK6M1mgwEDlXrXlBl
// //0pALdqDDYHvzp73Q59SIgbzjG7Z2zkhJXr
// // String? visionApi = AK.serverPHP;
// await carRegistrationRecognizerController.scanText();
// },
// )),
// Positioned(
// top: 50,
// child: SizedBox(
// height: Get.height * .6,
// width: Get.width,
// child: buildImageWithBoundingBoxes(),
// ),
// ),
// Positioned(
// bottom: Get.height * .2,
// left: Get.width * .2,
// right: Get.width * .2,
// child: MyElevatedButton(
// title: 'Register'.tr,
// onPressed: () async {
// // registerCaptainController.addLisence();
// // registerCaptainController.register();
// registerCaptainController.addRegisrationCarForDriver(
// carRegistrationRecognizerController.extracted['vin'],
// carRegistrationRecognizerController.extracted['make'],
// carRegistrationRecognizerController.extracted['model'],
// carRegistrationRecognizerController.extracted['year'],
// carRegistrationRecognizerController.extracted['color'],
// carRegistrationRecognizerController.extracted['owner'],
// carRegistrationRecognizerController
// .extracted['expiration_date'],
// carRegistrationRecognizerController
// .extracted['registration_date'],
// );
// },
// )),
// ],
// isleading: true);
// }
// }
Widget buildImageWithBoundingBoxes() {
Get.put(CarRegistrationRecognizerController());
return GetBuilder<CarRegistrationRecognizerController>(
builder: (carRegistrationRecognizerController) =>
carRegistrationRecognizerController.image == null ||
carRegistrationRecognizerController.extracted.isEmpty
? Center(
child: Text(
'No image selected yet'.tr,
style: AppStyle.headTitle2,
))
: Column(
children: [
SizedBox(
width: Get.width * .8,
height: Get.width * .5,
child: Image.file(
File(carRegistrationRecognizerController
.croppedFile!.path),
// fit: BoxFit.fill,
)),
const SizedBox(
height: 20,
),
Container(
decoration: AppStyle.boxDecoration,
height: Get.width * .5,
width: Get.width * .9,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
'${'Made :'.tr}${carRegistrationRecognizerController.extracted['make']}',
style: AppStyle.title,
),
Text(
'${'model :'.tr}${carRegistrationRecognizerController.extracted['model']}',
style: AppStyle.title,
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
'${'VIN :'.tr}${carRegistrationRecognizerController.extracted['vin']}',
style: AppStyle.title,
),
Text(
'${'year :'.tr}${carRegistrationRecognizerController.extracted['year']}',
style: AppStyle.title,
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
children: [
Text(
'expiration date :${carRegistrationRecognizerController.extracted['expiration_date']}',
style: AppStyle.title,
),
Text(
'registration date :${carRegistrationRecognizerController.extracted['registration_date']}',
style: AppStyle.title,
),
],
),
Text(
'color :${carRegistrationRecognizerController.extracted['color']}',
style: AppStyle.title,
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
'owner :${carRegistrationRecognizerController.extracted['owner']}',
style: AppStyle.title,
),
],
),
],
),
)
],
));
}
// Widget buildImageWithBoundingBoxes() {
// Get.put(CarRegistrationRecognizerController());
// return GetBuilder<CarRegistrationRecognizerController>(
// builder: (carRegistrationRecognizerController) =>
// carRegistrationRecognizerController.image == null ||
// carRegistrationRecognizerController.extracted.isEmpty
// ? Center(
// child: Text(
// 'No image selected yet'.tr,
// style: AppStyle.headTitle2,
// ))
// : Column(
// children: [
// SizedBox(
// width: Get.width * .8,
// height: Get.width * .5,
// child: Image.file(
// File(carRegistrationRecognizerController
// .croppedFile!.path),
// // fit: BoxFit.fill,
// )),
// const SizedBox(
// height: 20,
// ),
// Container(
// decoration: AppStyle.boxDecoration,
// height: Get.width * .5,
// width: Get.width * .9,
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// children: [
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// children: [
// Text(
// '${'Made :'.tr}${carRegistrationRecognizerController.extracted['make']}',
// style: AppStyle.title,
// ),
// Text(
// '${'model :'.tr}${carRegistrationRecognizerController.extracted['model']}',
// style: AppStyle.title,
// ),
// ],
// ),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// children: [
// Text(
// '${'VIN :'.tr}${carRegistrationRecognizerController.extracted['vin']}',
// style: AppStyle.title,
// ),
// Text(
// '${'year :'.tr}${carRegistrationRecognizerController.extracted['year']}',
// style: AppStyle.title,
// ),
// ],
// ),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// children: [
// Column(
// children: [
// Text(
// 'expiration date :${carRegistrationRecognizerController.extracted['expiration_date']}',
// style: AppStyle.title,
// ),
// Text(
// 'registration date :${carRegistrationRecognizerController.extracted['registration_date']}',
// style: AppStyle.title,
// ),
// ],
// ),
// Text(
// 'color :${carRegistrationRecognizerController.extracted['color']}',
// style: AppStyle.title,
// ),
// ],
// ),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// children: [
// Text(
// 'owner :${carRegistrationRecognizerController.extracted['owner']}',
// style: AppStyle.title,
// ),
// ],
// ),
// ],
// ),
// )
// ],
// ));
// }

View File

@@ -3,7 +3,6 @@ import 'package:sefer_driver/controller/functions/gemeni.dart';
import 'package:sefer_driver/controller/functions/tts.dart';
import 'package:sefer_driver/views/widgets/elevated_btn.dart';
import 'package:sefer_driver/views/widgets/my_circular_indicator_timer.dart';
import 'package:sefer_driver/views/widgets/my_textField.dart';
import 'package:sefer_driver/views/widgets/mydialoug.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@@ -52,41 +51,70 @@ class EgyptCardAI extends StatelessWidget {
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
(controller.responseIdCardDriverEgyptBack.isNotEmpty &&
controller.responseIdCardDriverEgyptFront
.isNotEmpty &&
controller.responseIdEgyptFront.isNotEmpty &&
controller.responseIdEgyptBack.isNotEmpty &&
controller
.responseIdEgyptDriverLicense.isNotEmpty
// &&
// controller
// .responseCriminalRecordEgypt.isNotEmpty
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
(controller.responseIdCardDriverEgyptBack
.isNotEmpty &&
controller.responseIdCardDriverEgyptFront
.isNotEmpty &&
(controller
.responseIdEgyptFront.isNotEmpty ||
controller.responseNonIdCardFront
.isNotEmpty) &&
(controller
.responseIdEgyptBack.isNotEmpty ||
controller.responseNonIdCardBack
.isNotEmpty) &&
controller
.responseIdEgyptDriverLicense.isNotEmpty
// &&
// controller
// .responseCriminalRecordEgypt.isNotEmpty
)
? MyElevatedButton(
title: 'Next'.tr,
kolor: AppColor.greenColor,
onPressed: () {
controller.addDriverAndCarEgypt();
})
: const SizedBox(),
Row(
children: [
controller.isEgypt
? MyElevatedButton(
title: 'For Egypt'.tr,
onPressed: () {
controller.changeNationality();
})
: MyElevatedButton(
title: 'Non Egypt'.tr,
onPressed: () {
controller.changeNationality();
}),
],
)
? MyElevatedButton(
title: 'Next'.tr,
onPressed: () {
controller.addDriverAndCarEgypt();
})
: const SizedBox(),
],
),
SizedBox(
height:
(controller.responseIdCardDriverEgyptBack
.isNotEmpty &&
controller.responseIdCardDriverEgyptFront
.isNotEmpty &&
controller
.responseIdEgyptFront.isNotEmpty &&
controller
.responseIdEgyptBack.isNotEmpty &&
controller.responseIdEgyptDriverLicense
.isNotEmpty
// &&
// controller.responseCriminalRecordEgypt
// .isNotEmpty
)
? Get.height * .7
: Get.height * .85,
// (controller.responseIdCardDriverEgyptBack
// .isNotEmpty &&
// controller.responseIdCardDriverEgyptFront
// .isNotEmpty &&
// controller
// .responseIdEgyptFront.isNotEmpty &&
// controller
// .responseIdEgyptBack.isNotEmpty &&
// controller.responseIdEgyptDriverLicense
// .isNotEmpty
// &&
// controller.responseCriminalRecordEgypt
// .isNotEmpty
// )
// ?
Get.height * .7,
// : Get.height * .85,
child: ListView(
children: [
Padding(
@@ -109,8 +137,12 @@ class EgyptCardAI extends StatelessWidget {
egyptDriverLicense(),
egyptCarLicenceFront(),
egyptCarLicenceBack(),
egyptDriverIDFront(),
egyptDriverIDBack(),
controller.isEgypt
? egyptDriverIDFront()
: nonEgyptDriverIDFront(),
controller.isEgypt
? egyptDriverIDBack()
: nonEgyptDriverIDBack(),
// egyptCriminalRecord(),
],
),
@@ -498,6 +530,109 @@ class EgyptCardAI extends StatelessWidget {
);
}
GetBuilder<AI> nonEgyptDriverIDBack() {
return GetBuilder<AI>(
builder: (ai) {
if (ai.responseNonIdCardBack.isNotEmpty) {
final residencyExpiryDate =
ai.responseNonIdCardBack['residencyExpirationDate'];
final today = DateTime.now();
final residencyExpiryDateTime =
DateTime.tryParse(residencyExpiryDate);
final isExpired = residencyExpiryDateTime != null &&
residencyExpiryDateTime.isBefore(today);
return Card(
elevation: 4.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.0),
),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Non-Egyptian ID Back'.tr, style: AppStyle.title),
IconButton(
onPressed: () async {
await ai.allMethodForAI(
ai.prompts[7]['prompt'].toString(),
AppLink.uploadEgypt,
'non_id_back');
},
icon: const Icon(Icons.refresh),
),
],
),
const SizedBox(height: 8.0),
const Divider(color: AppColor.accentColor),
const SizedBox(height: 8.0),
Text(
'${'Country'.tr}: ${ai.responseNonIdCardBack['country']}',
style: AppStyle.title,
),
const SizedBox(height: 8.0),
Text(
'${'Residency Type'.tr}: ${ai.responseNonIdCardBack['residencyType']}',
),
const SizedBox(height: 8.0),
Text(
'${'Work Status'.tr}: ${ai.responseNonIdCardBack['workStatus']}',
),
const SizedBox(height: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Issue Date'.tr}: ${ai.responseNonIdCardBack['issueDate']}',
),
Text(
'${'Birth Date'.tr}: ${ai.responseNonIdCardBack['birthDate']}',
),
],
),
const SizedBox(height: 8.0),
Text(
'${'Residency Expiration Date'.tr}: ${ai.responseNonIdCardBack['residencyExpirationDate']}',
style: AppStyle.title.copyWith(
color: !isExpired
? AppColor.greenColor
: AppColor.redColor),
),
],
),
),
);
}
return Card(
child: InkWell(
onTap: () async {
await ai.allMethodForAI(ai.prompts[7]['prompt'].toString(),
AppLink.uploadEgypt, 'non_id_back');
},
child: Column(
children: [
Image.asset(
'assets/images/7.png',
height: Get.height * .25,
width: double.maxFinite,
fit: BoxFit.fitHeight,
),
Text(
'Capture Image of Non-Egyptian ID Back'.tr,
style: AppStyle.title,
),
],
),
),
);
},
);
}
GetBuilder<AI> egyptDriverIDFront() {
return GetBuilder<AI>(
builder: (ai) {
@@ -597,6 +732,105 @@ class EgyptCardAI extends StatelessWidget {
);
}
GetBuilder<AI> nonEgyptDriverIDFront() {
return GetBuilder<AI>(
builder: (ai) {
if (ai.responseNonIdCardFront.isNotEmpty) {
return Card(
elevation: 4.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.0),
),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Non-Egyptian ID Front'.tr, style: AppStyle.title),
IconButton(
onPressed: () async {
await ai.allMethodForAI(
ai.prompts[6]['prompt'].toString(),
AppLink.uploadEgypt,
'non_id_front');
},
icon: const Icon(Icons.refresh),
),
],
),
const SizedBox(height: 8.0),
const Divider(color: AppColor.accentColor),
const SizedBox(height: 8.0),
Text(
'${'Full Name'.tr}: ${ai.responseNonIdCardFront['full_name']}',
style: AppStyle.title,
),
const SizedBox(height: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Passport No'.tr}: ${ai.responseNonIdCardFront['passport_no']}',
),
Text(
'${'Card ID'.tr}: ${ai.responseNonIdCardFront['card_id']}',
),
],
),
const SizedBox(height: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Country'.tr}: ${ai.responseNonIdCardFront['country']}',
),
Text(
'${'Gender'.tr}: ${ai.responseNonIdCardFront['gender']}',
),
],
),
const SizedBox(height: 8.0),
Text(
'${'Birth Date'.tr}: ${ai.responseNonIdCardFront['birthdate']}',
),
const SizedBox(height: 8.0),
Text(
'${'Address'.tr}: ${ai.responseNonIdCardFront['address']}',
),
],
),
),
);
}
return Card(
child: InkWell(
onTap: () async {
await ai.allMethodForAI(ai.prompts[6]['prompt'].toString(),
AppLink.uploadEgypt, 'non_id_front');
},
child: Column(
children: [
Image.asset(
'assets/images/7.jpeg',
height: Get.height * .25,
width: double.maxFinite,
fit: BoxFit.fitHeight,
),
Text(
'Capture Image of Non-Egyptian ID Front'.tr,
style: AppStyle.title,
),
],
),
),
);
},
);
}
GetBuilder<AI> egyptCarLicenceFront() {
return GetBuilder<AI>(
builder: (ai) {

View File

@@ -165,9 +165,8 @@ class CameraWidgetCardId extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
MyElevatedButton(
title: 'Scan ID MklGoogle'.tr,
onPressed: () =>
cameraClassController.takePictureAndMLGoogleScan()),
title: 'Scan ID MklGoogle'.tr, onPressed: () {}),
// cameraClassController.takePictureAndMLGoogleScan()),
MyElevatedButton(
title: 'Scan ID Tesseract'.tr, onPressed: () {}),
],
@@ -283,9 +282,8 @@ class CameraWidgetPassPort extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
MyElevatedButton(
title: 'Scan ID MklGoogle'.tr,
onPressed: () =>
cameraClassController.takePictureAndMLGoogleScan()),
title: 'Scan ID MklGoogle'.tr, onPressed: () => {}),
// cameraClassController.takePictureAndMLGoogleScan()),
MyElevatedButton(
title: 'Scan ID Tesseract'.tr, onPressed: () {}),
],

View File

@@ -107,114 +107,210 @@ class HomeCaptain extends StatelessWidget {
left: Get.width * .1,
child: const ConnectWidget()),
Positioned(
top: 5,
right: Get.width * .05,
left: Get.width * .05,
child: GetBuilder<HomeCaptainController>(
builder: (homeCaptainController) {
top: 5,
right: Get.width * .05,
left: Get.width * .05,
child: GetBuilder<HomeCaptainController>(
builder: (homeCaptainController) {
return Container(
decoration: AppStyle.boxDecoration,
width: Get.width * .8,
height: 104,
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Entypo.wallet,
color: AppColor.greenColor,
decoration: BoxDecoration(
gradient: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Colors.white, Colors.white70],
),
borderRadius: BorderRadius.circular(15),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 2,
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
padding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
width: Get.width * .8,
height: 120,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: AppColor.greenColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(10),
),
Text(
' You Earn today is '.tr +
homeCaptainController.totalMoneyToday,
style: AppStyle.title,
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Entypo.wallet,
color: AppColor.yellowColor,
),
Text(
'${' You Have in'.tr} ${AppInformation.appName} ${homeCaptainController.totalMoneyInSEFER} ',
style: AppStyle.title,
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
'Total Budget is '.tr +
homeCaptainController.totalPoints,
style: AppStyle.title,
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: int.parse(
Get.find<HomeCaptainController>()
.countRideToday) <
5
? AppColor.accentColor
: int.parse(Get.find<
HomeCaptainController>()
.countRideToday) >
5 &&
int.parse(Get.find<
HomeCaptainController>()
.countRideToday) <
10
? AppColor.yellowColor
: AppColor.greenColor,
),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8, vertical: 2),
child: Text(
'Ride Today : '.tr +
Get.find<HomeCaptainController>()
.countRideToday,
style: AppStyle.title
.copyWith(color: AppColor.secondaryColor),
child: Row(
children: [
const Icon(
Entypo.wallet,
color: AppColor.greenColor,
size: 20,
),
),
const SizedBox(width: 8),
Text(
'${"Today".tr}: ${homeCaptainController.totalMoneyToday}',
style: AppStyle.title.copyWith(
color: AppColor.greenColor,
fontWeight: FontWeight.bold,
),
),
],
),
],
),
],
)));
})),
),
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: AppColor.yellowColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(10),
),
child: Row(
children: [
const Icon(
Entypo.wallet,
color: AppColor.yellowColor,
size: 20,
),
const SizedBox(width: 8),
Text(
'${AppInformation.appName}: ${homeCaptainController.totalMoneyInSEFER}',
style: AppStyle.title.copyWith(
color: AppColor.yellowColor,
fontWeight: FontWeight.bold,
),
),
],
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Total Points is'.tr}: ${homeCaptainController.totalPoints}',
style: AppStyle.title.copyWith(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 6),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: int.parse(homeCaptainController
.countRideToday) <
5
? AppColor.accentColor
: int.parse(homeCaptainController
.countRideToday) >
5 &&
int.parse(homeCaptainController
.countRideToday) <
10
? AppColor.yellowColor
: AppColor.greenColor,
),
child: Row(
children: [
const Icon(
Icons.directions_car_rounded,
color: Colors.white,
size: 18,
),
const SizedBox(width: 4),
Text(
'${"Ride Today : ".tr}: ${homeCaptainController.countRideToday}',
style: AppStyle.title.copyWith(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
],
),
),
],
),
],
),
);
},
),
),
Positioned(
bottom: 65,
right: Get.width * .1,
left: Get.width * .1,
child: GetBuilder<HomeCaptainController>(
builder: (homeCaptainController) => Container(
decoration: AppStyle.boxDecoration,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 2,
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
padding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Column(
children: [
Text(
'${'Active Duration:'.tr} ${homeCaptainController.stringActiveDuration} ',
style: AppStyle.title,
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.timer_outlined,
color: AppColor.greenColor),
const SizedBox(width: 8),
Text(
'Active Duration:'.tr,
style: AppStyle.title,
),
const SizedBox(width: 4),
Text(
homeCaptainController.stringActiveDuration,
style: AppStyle.title.copyWith(
fontWeight: FontWeight.bold,
color: AppColor.greenColor,
),
),
],
),
Text(
'${'Total Connection Duration:'.tr} ${homeCaptainController.totalDurationToday} ',
style: AppStyle.title,
const SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.access_time,
color: AppColor.accentColor),
const SizedBox(width: 8),
Text(
'Total Connection Duration:'.tr,
style: AppStyle.title,
),
const SizedBox(width: 4),
Text(
homeCaptainController.totalDurationToday,
style: AppStyle.title.copyWith(
fontWeight: FontWeight.bold,
color: AppColor.accentColor,
),
),
],
),
],
),
),
),
),
// Positioned(
), // Positioned(
// bottom: Get.height * .17,
// right: Get.width * .01,
// child: AnimatedContainer(

View File

@@ -23,80 +23,119 @@ class ConnectWidget extends StatelessWidget {
captainWalletController.getCaptainWalletFromBuyPoints();
return Center(
child: GetBuilder<HomeCaptainController>(
builder: (homeCaptainController) => int.parse(
homeCaptainController.countRefuse) >
3 ||
double.parse(captainWalletController.totalPoints) < -300
? CupertinoButton(
onPressed: () {
Get.defaultDialog(
// backgroundColor: CupertinoColors.destructiveRed,
barrierDismissible: false,
title: double.parse(captainWalletController.totalPoints) <
-300
? 'You dont have Points'.tr
: 'You Are Stopped For this Day !'.tr,
titleStyle: AppStyle.title,
content: Column(
children: [
IconButton(
onPressed: () async {
builder: (homeCaptainController) => double.parse(
captainWalletController.totalPoints) <
-300
? CupertinoButton(
onPressed: () {
Get.defaultDialog(
// backgroundColor: CupertinoColors.destructiveRed,
barrierDismissible: false,
title:
double.parse(captainWalletController.totalPoints) <
-300
? 'You dont have Points'.tr
: 'You Are Stopped For this Day !'.tr,
titleStyle: AppStyle.title,
content: Column(
children: [
IconButton(
onPressed: () async {
double.parse(captainWalletController
.totalPoints) <
-300
? await Get.find<TextToSpeechController>()
.speakText(
'You must be recharge your Account'
.tr)
: await Get.find<TextToSpeechController>()
.speakText(
'You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!'
.tr);
},
icon: const Icon(Icons.headphones),
),
Text(
double.parse(
captainWalletController.totalPoints) <
-300
? await Get.find<TextToSpeechController>()
.speakText(
'You must be recharge your Account'
.tr)
: await Get.find<TextToSpeechController>()
.speakText(
'You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!'
.tr);
},
icon: const Icon(Icons.headphones),
),
Text(
? 'You must be recharge your Account'.tr
: 'You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!'
.tr,
style: AppStyle.title,
),
],
),
confirm:
double.parse(captainWalletController.totalPoints) <
-300
? 'You must be recharge your Account'.tr
: 'You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!'
.tr,
style: AppStyle.title,
),
],
? MyElevatedButton(
title: 'Recharge my Account'.tr,
onPressed: () {
homeCaptainController
.goToWalletFromConnect();
})
: MyElevatedButton(
title: 'Ok , See you Tomorrow'.tr,
onPressed: () {
Get.back();
Get.back();
}));
},
color: CupertinoColors.destructiveRed,
child: Text(
'You are Stopped'.tr,
style: AppStyle.title,
),
)
: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: homeCaptainController.isActive
? [Colors.green.shade400, Colors.green.shade700]
: [Colors.grey.shade400, Colors.grey.shade700],
),
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: homeCaptainController.isActive
? Colors.green.withOpacity(0.3)
: Colors.grey.withOpacity(0.3),
spreadRadius: 1,
blurRadius: 8,
offset: const Offset(0, 2),
),
confirm:
double.parse(captainWalletController.totalPoints) <
-300
? MyElevatedButton(
title: 'Recharge my Account'.tr,
onPressed: () {
homeCaptainController
.goToWalletFromConnect();
})
: MyElevatedButton(
title: 'Ok , See you Tomorrow'.tr,
onPressed: () {
Get.back();
Get.back();
}));
},
color: CupertinoColors.destructiveRed,
child: Text(
'You are Stopped'.tr,
style: AppStyle.title,
),
)
: CupertinoButton(
onPressed: homeCaptainController.onButtonSelected,
color: homeCaptainController.isActive
? CupertinoColors.activeGreen
: CupertinoColors.inactiveGray,
child: Text(homeCaptainController.isActive
? 'Connected'.tr
: 'Not Connected'.tr),
),
),
],
),
child: CupertinoButton(
onPressed: homeCaptainController.onButtonSelected,
padding: const EdgeInsets.symmetric(
horizontal: 24, vertical: 12),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
homeCaptainController.isActive
? CupertinoIcons.check_mark_circled_solid
: CupertinoIcons.circle,
color: Colors.white,
size: 24,
),
const SizedBox(width: 8),
Text(
homeCaptainController.isActive
? 'Connected'.tr
: 'Not Connected'.tr,
style: const TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
],
),
),
)),
);
}
}

View File

@@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:slide_to_act/slide_to_act.dart';
import 'package:vibration/vibration.dart';
import '../../../../constant/colors.dart';
@@ -150,13 +151,30 @@ GetBuilder<MapDriverController> driverEndRideBar() {
// mapDriverController.remainingTimeTimerRideBegin <
// 60
// ?
MyElevatedButton(
title: 'End Ride'.tr,
onPressed: () {
SlideAction(
text: 'End Ride'.tr,
textStyle: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.white,
),
outerColor: AppColor.redColor,
innerColor: Colors.white,
sliderButtonIcon: const Icon(
Icons.arrow_forward,
color: AppColor.redColor,
),
onSubmit: () {
mapDriverController.finishRideFromDriver();
},
kolor: AppColor.redColor,
),
// MyElevatedButton(
// title: 'End Ride'.tr,
// onPressed: () {
// mapDriverController.finishRideFromDriver();
// },
// kolor: AppColor.redColor,
// ),
// : const SizedBox(),
Container(
decoration: AppStyle.boxDecoration1,