diff --git a/.env b/.env index 31cf9b8..8b68186 100644 --- a/.env +++ b/.env @@ -30,6 +30,5 @@ payMobApikey='MDrGqKEWS1rVqHvEPDvPjJ7vZDBExrO7S3BEBgrlfUwTA3i5RnP5ZnvoL3M2S9rEBg integrationIdPayMobWallet=0552352XrXlBl Ocp-Apim-Subscription-Key=21010e54b50f41a4904708c526e102df smsPasswordEgypt="E)Pu=an/@Z" - chatGPTkeySeferNew=sk-proj-6r2SrvboRE7hAIpnn8WmT3BlbkFJdPAOf7WOX8aV8CFFaiY5 -anthropicAIkeySeferNew=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 \ No newline at end of file +anthropicAIkeySeferNew=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 diff --git a/assets/images/6.png b/assets/images/6.png new file mode 100644 index 0000000..23df2c0 Binary files /dev/null and b/assets/images/6.png differ diff --git a/lib/constant/links.dart b/lib/constant/links.dart index f5ae72e..f242e84 100644 --- a/lib/constant/links.dart +++ b/lib/constant/links.dart @@ -188,6 +188,8 @@ class AppLink { static String loginCaptin = "$authCaptin/login.php"; static String signUpCaptin = "$authCaptin/register.php"; static String sendVerifyEmailCaptin = "$authCaptin/sendVerifyEmail.php"; + static String sendVerifyOtpMessage = "$server/auth/otpmessage.php"; + static String verifyOtpMessage = "$server/auth/verifyOtpMessage.php"; static String verifyEmailCaptin = "$authCaptin/verifyEmail.php"; static String removeUser = "$authCaptin/removeAccount.php"; static String deletecaptainAccounr = "$authCaptin/deletecaptainAccounr.php"; diff --git a/lib/controller/auth/captin/register_captin_controller.dart b/lib/controller/auth/captin/register_captin_controller.dart index fd1a94c..9226c84 100644 --- a/lib/controller/auth/captin/register_captin_controller.dart +++ b/lib/controller/auth/captin/register_captin_controller.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'dart:math'; import 'package:SEFER/controller/auth/captin/login_captin_controller.dart'; +import 'package:SEFER/views/auth/captin/register_captin.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:SEFER/constant/box_name.dart'; @@ -15,9 +16,11 @@ import 'package:SEFER/views/auth/captin/verify_email_captain.dart'; import '../../../views/auth/captin/ai_page.dart'; import '../../../views/auth/captin/car_license_page.dart'; import '../../../views/home/Captin/home_captain/home_captin.dart'; +import '../../functions/sms_egypt_controller.dart'; class RegisterCaptainController extends GetxController { final formKey = GlobalKey(); + final formKey3 = GlobalKey(); TextEditingController emailController = TextEditingController(); TextEditingController phoneController = TextEditingController(); @@ -27,6 +30,7 @@ class RegisterCaptainController extends GetxController { String birthDate = 'Birth Date'.tr; String gender = 'Male'.tr; bool isLoading = false; + bool isSent = false; late String name; late String licenseClass; late String documentNo; @@ -62,11 +66,51 @@ class RegisterCaptainController extends GetxController { ); } + @override + void onInit() { + // Get.put(SmsEgyptController()); + super.onInit(); + } + void changeGender(String value) { gender = value; update(); } + sendOtpMessage() async { + SmsEgyptController smsEgyptController = Get.put(SmsEgyptController()); + + int randomNumber = Random().nextInt(100000) + 1; + isLoading = true; + update(); + if (formKey3.currentState!.validate()) { + await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: { + 'phone_number': phoneController.text, + 'token_code': randomNumber.toString(), + }); + + await smsEgyptController.sendSmsEgypt( + phoneController.toString(), randomNumber.toString()); + isSent = true; + isLoading = false; + update(); + } + } + + verifySMSCode() async { + if (formKey3.currentState!.validate()) { + var res = await CRUD().post(link: AppLink.verifyOtpMessage, payload: { + 'phone_number': phoneController.text, + 'token_code': verifyCode.text.toString(), + }); + if (res != 'failure') { + // var dec = jsonDecode(res); + box.write(BoxName.phoneDriver, '+2${phoneController.text}'); + Get.to(const RegisterCaptin()); + } + } + } + sendVerifications() async { var res = await CRUD().post(link: AppLink.verifyEmail, payload: { 'email': emailController.text.isEmpty diff --git a/lib/controller/auth/google_sign.dart b/lib/controller/auth/google_sign.dart index 7fa4c77..72d99e0 100644 --- a/lib/controller/auth/google_sign.dart +++ b/lib/controller/auth/google_sign.dart @@ -1,5 +1,6 @@ import 'package:SEFER/constant/box_name.dart'; import 'package:SEFER/main.dart'; +import 'package:SEFER/views/auth/captin/cards_egypt/egypt_card_a_i.dart'; import 'package:get/get.dart'; import 'package:google_sign_in/google_sign_in.dart'; @@ -13,11 +14,18 @@ class GoogleSignInHelper { ], ); + // Method to handle Google Sign-In static Future signIn() async { try { final GoogleSignInAccount? googleUser = await _googleSignIn.signIn(); - getDriverInfo(); - Get.to(() => AiPage()); + if (googleUser != null) { + await _handleSignUp(googleUser); + if (box.read(BoxName.countryCode) == 'Egypt') { + Get.to(() => EgyptCardAI()); + } else if (box.read(BoxName.countryCode) == 'Jordan') { + Get.to(() => AiPage()); + } + } return googleUser; } catch (error) { print('Google Sign-In error: $error'); @@ -25,25 +33,50 @@ class GoogleSignInHelper { } } + // Method to handle Google Sign-Out static Future signOut() async { try { await _googleSignIn.signOut(); + await _handleSignOut(); + print('User signed out.'); } catch (error) { print('Google Sign-Out error: $error'); } } + // Method to get the current signed-in user static GoogleSignInAccount? getCurrentUser() { return _googleSignIn.currentUser; } - static String? getDriverInfo() { - final GoogleSignInAccount? user = _googleSignIn.currentUser; - box.write(BoxName.driverID, user!.id); + // Method to handle sign-up process + static Future _handleSignUp(GoogleSignInAccount user) async { + // Store driver information + box.write(BoxName.driverID, user.id); box.write(BoxName.emailDriver, user.email); box.write(BoxName.nameDriver, user.displayName); box.write(BoxName.driverPhotoUrl, user.photoUrl); - print('emailDriver =${box.read(BoxName.emailDriver)}'); - return user.displayName; + + // Perform any additional sign-up tasks or API calls here + // For example, you can send the user data to your server for registration + + print('driverID = ${box.read(BoxName.driverID)}'); + print('emailDriver = ${box.read(BoxName.emailDriver)}'); + print('nameDriver = ${box.read(BoxName.nameDriver)}'); + print('driverPhotoUrl = ${box.read(BoxName.driverPhotoUrl)}'); + } + + // Method to handle sign-out process + static Future _handleSignOut() async { + // Clear stored driver information + box.remove(BoxName.driverID); + box.remove(BoxName.emailDriver); + box.remove(BoxName.nameDriver); + box.remove(BoxName.driverPhotoUrl); + + // Perform any additional sign-out tasks or API calls here + // For example, you can notify your server about the user sign-out + + print('User data cleared.'); } } diff --git a/lib/controller/functions/crud.dart b/lib/controller/functions/crud.dart index 77aeec2..ef73d36 100644 --- a/lib/controller/functions/crud.dart +++ b/lib/controller/functions/crud.dart @@ -7,6 +7,7 @@ import 'package:http/http.dart' as http; import 'package:SEFER/env/env.dart'; import '../../constant/api_key.dart'; +import '../../constant/colors.dart'; import 'gemeni.dart'; import 'llama_ai.dart'; import 'upload_image.dart'; @@ -246,6 +247,10 @@ class CRUD { if (jsonData['status'] == 'success') { return response.body; } else { + String errorMessage = jsonData['message']; + Get.snackbar('Erroe'.tr, errorMessage.tr, + backgroundColor: AppColor.redColor); + print(errorMessage.tr); return (jsonData['status']); } } else { diff --git a/lib/controller/functions/gemeni.dart b/lib/controller/functions/gemeni.dart index b9e47af..cf0599a 100644 --- a/lib/controller/functions/gemeni.dart +++ b/lib/controller/functions/gemeni.dart @@ -1,6 +1,11 @@ import 'dart:convert'; import 'dart:io'; +import 'package:SEFER/constant/box_name.dart'; +import 'package:SEFER/constant/links.dart'; +import 'package:SEFER/constant/style.dart'; import 'package:SEFER/controller/functions/crud.dart'; +import 'package:SEFER/main.dart'; +import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:image_cropper/image_cropper.dart'; import 'package:image_picker/image_picker.dart'; @@ -10,17 +15,270 @@ import 'package:path_provider/path_provider.dart'; import '../../constant/api_key.dart'; import '../../constant/colors.dart'; +import 'tts.dart'; import 'upload_image.dart'; class AI extends GetxController { + bool approved = false; + + void setApproved() { + approved = true; + update(); + } + + final today = DateTime.now(); + + Future addDriverAndCarEgypt() async { + final expiryDate = responseIdEgyptDriverLicense['expiry_date']; + final expiryDateTime = DateTime.tryParse(expiryDate); + final isExpired = expiryDateTime != null && expiryDateTime.isBefore(today); + + final taxExpiryDate = responseIdCardDriverEgyptBack['tax_expiry']; + + // Get the inspection date from the response + final inspectionDate = responseIdCardDriverEgyptBack['inspection_date']; + + // Try parsing the tax expiry date. If it fails, set it to null. + final taxExpiryDateTime = DateTime.tryParse(taxExpiryDate ?? ''); + final isExpiredCar = + taxExpiryDateTime != null && taxExpiryDateTime.isBefore(today); + + // Check if the inspection date is before today + final inspectionDateTime = DateTime(int.parse(inspectionDate ?? ''), 1, 1); + final isInspectionExpired = inspectionDateTime.isBefore(today); + + if (isExpiredCar || isInspectionExpired) { + Get.defaultDialog( + title: 'Expired Driver’s License'.tr, + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon(Icons.warning, size: 48, color: Colors.red), + const SizedBox(height: 16), + Text( + 'Your driver’s license and/or car tax has expired. Please renew them before proceeding.' + .tr, + textAlign: TextAlign.center, + style: AppStyle.title, + ), + const SizedBox(height: 16), + IconButton( + onPressed: () async { + await Get.find().speakText( + 'Your driver’s license and/or car tax has expired. Please renew them before proceeding.' + .tr, + ); + }, + icon: const Icon(Icons.volume_up), + ), + ], + ), + actions: [ + TextButton( + onPressed: () { + Get.back(); + }, + child: const Text('OK'), + ), + ], + ); + } else if (isExpired) { + Get.defaultDialog( + title: 'Expired Driver’s License'.tr, + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon(Icons.warning, size: 48, color: Colors.red), + const SizedBox(height: 16), + Text( + 'Your driver’s license has expired. Please renew it before proceeding.' + .tr, + textAlign: TextAlign.center, + style: AppStyle.title, + ), + const SizedBox(height: 16), + IconButton( + onPressed: () async { + await Get.find().speakText( + 'Your driver’s license has expired. Please renew it before proceeding.' + .tr, + ); + }, + icon: const Icon(Icons.volume_up), + ), + ], + ), + actions: [ + TextButton( + onPressed: () { + Get.back(); + }, + child: const Text('OK'), + ), + ], + ); + } else if (responseIdEgyptDriverLicense['national_number'] != + responseIdEgyptBack['nationalID']) { + Get.defaultDialog( + barrierDismissible: false, + title: 'ID Mismatch', + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon(Icons.warning, size: 48, color: Colors.red), + const SizedBox(height: 16), + Text( + 'The national number on your driver’s license does not match the one on your ID document. Please verify and provide the correct documents.' + .tr, + textAlign: TextAlign.center, + style: AppStyle.title, + ), + const SizedBox(height: 16), + IconButton( + onPressed: () async { + await Get.find().speakText( + 'The national number on your driver’s license does not match the one on your ID document. Please verify and provide the correct documents.', + ); + }, + icon: const Icon(Icons.volume_up), + ), + ], + ), + actions: [ + TextButton( + onPressed: () { + Get.back(); + }, + child: const Text('OK'), + ), + ], + ); + } else if (responseCriminalRecordEgypt['FullName'] != + responseIdEgyptDriverLicense['name_arabic']) { + Get.defaultDialog( + barrierDismissible: false, + title: 'Criminal Record Mismatch', + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon(Icons.warning, size: 48, color: Colors.red), + const SizedBox(height: 16), + Text( + 'The full name on your criminal record does not match the one on your driver’s license. Please verify and provide the correct documents.' + .tr, + textAlign: TextAlign.center, + style: AppStyle.title, + ), + const SizedBox(height: 16), + IconButton( + onPressed: () async { + await Get.find().speakText( + 'The full name on your criminal record does not match the one on your driver’s license. Please verify and provide the correct documents.' + .tr, + ); + }, + icon: const Icon(Icons.volume_up), + ), + ], + ), + actions: [ + TextButton( + onPressed: () { + Get.back(); + }, + child: const Text('OK'), + ), + ], + ); + } else { + isLoading = true; + update(); + await addDriverEgypt(); + await addRegistrationCarEgypt(); + isLoading = false; + update(); + } + } + + Future addDriverEgypt() async { + try { + var res = await CRUD().post(link: AppLink.signUpCaptin, payload: { + 'first_name': responseIdEgyptDriverLicense['firstName'], + 'last_name': responseIdEgyptDriverLicense['lastName'], + 'email': box.read(BoxName.emailDriver), + 'phone': '78787', //todo add phone //box.read(BoxName.phoneDriver), + 'driverId': box.read(BoxName.driverID), + 'password': '123456', // todo check + 'gender': responseIdEgyptBack['gender'] == 'ذكر' ? 'Male' : 'Female', + 'license_type': responseIdEgyptDriverLicense['license_type'], + 'national_number': responseIdEgyptBack['nationalID'], + 'name_arabic': responseIdEgyptDriverLicense['name_arabic'], + 'name_english': responseIdEgyptDriverLicense['name_english'], + 'issue_date': responseIdEgyptDriverLicense['issue_date'], + 'expiry_date': responseIdEgyptDriverLicense['expiry_date'], + 'license_categories': + responseIdEgyptDriverLicense['license_categories'], + 'address': responseIdEgyptFront['address'], + 'card_id': responseIdEgyptFront['card_id'], + 'occupation': responseIdEgyptBack['occupation'], + 'education': responseIdEgyptBack['occupation'], + 'licenseIssueDate': responseIdEgyptDriverLicense['issue_date'], + 'religion': responseIdEgyptBack['religion'], + 'status': responseIdEgyptBack['fullName'], + 'birthdate': responseIdEgyptFront['dob'] + '-01-01', + 'maritalStatus': responseIdEgyptBack['maritalStatus'], + 'site': responseIdEgyptDriverLicense['address'], + 'employmentType': responseIdEgyptDriverLicense['employmentType'], + }); + var status = jsonDecode(res); + if (status == 'success') { + Get.snackbar('Success', 'message', + backgroundColor: AppColor.greenColor); + } + } catch (e) { + print('error is $e'); + } + } + + Future addRegistrationCarEgypt() async { + try { + var res = await CRUD().post(link: AppLink.addRegisrationCar, payload: { + 'driverID': box.read(BoxName.driverID), + 'vin': responseIdCardDriverEgyptBack['chassis'].toString(), + 'car_plate': responseIdCardDriverEgyptFront['car_plate'].toString(), + 'make': responseIdCardDriverEgyptBack['make'].toString(), + 'model': responseIdCardDriverEgyptBack['model'], + 'year': responseIdCardDriverEgyptBack['year'].toString(), + 'expiration_date': + responseIdCardDriverEgyptFront['LicenseExpirationDate'].toString(), + 'color': responseIdCardDriverEgyptBack['color'], + 'owner': responseIdCardDriverEgyptFront['owner'], + 'color_hex': responseIdCardDriverEgyptBack['color_hex'].toString(), + 'address': responseIdCardDriverEgyptFront['address'].toString(), + 'displacement': responseIdCardDriverEgyptBack['engine'].toString(), + 'fuel': responseIdCardDriverEgyptBack['fuel'].toString(), + 'registration_date': + '${responseIdCardDriverEgyptBack['inspection_date']}-01-01', + }); + var status = jsonDecode(res); + if (status == 'success') { + Get.snackbar('Success', 'message', + backgroundColor: AppColor.greenColor); + } + } catch (e) { + print('error is $e'); + } + } + final picker = ImagePicker(); Map responseMap = {}; - Map responseCarLicenseMap = {}; + Map responseCarLicenseMapJordan = {}; Map responseBackCarLicenseMap = {}; Map responseIdCardMap = {}; Map responseIdCardDriverEgyptBack = {}; Map responseIdCardDriverEgyptFront = {}; Map responseIdEgyptFront = {}; + Map responseCriminalRecordEgypt = {}; Map responseIdEgyptBack = {}; Map responseIdEgyptDriverLicense = {}; String? responseIdCardDriverEgypt1; @@ -87,7 +345,7 @@ class AI extends GetxController { var json = jsonDecode(extractedString); var textValues = CRUD().extractTextFromLines(json); print(textValues); - // await Get.put(AI()).geminiAiExtraction(prompt, textValues); + // await Get.put(AI()).geminiAiExtraction(prompt, textValues, imagePath); await Get.put(AI()).anthropicAI(textValues, prompt, imagePath); isLoading = false; update(); @@ -238,6 +496,10 @@ class AI extends GetxController { responseIdEgyptDriverLicense = jsonDecode(responseData['content'][0]['text']); print(responseIdEgyptDriverLicense); + } else if (idType == 'criminalRecord') { + responseCriminalRecordEgypt = + jsonDecode(responseData['content'][0]['text']); + print(responseCriminalRecordEgypt); } update(); @@ -246,7 +508,7 @@ class AI extends GetxController { return responseIdCardDriverEgyptBack.toString(); } - Future geminiAiExtraction(String prompt, payload) async { + Future geminiAiExtraction(String prompt, payload, String idType) async { var requestBody = jsonEncode({ "contents": [ { @@ -309,11 +571,28 @@ class AI extends GetxController { // Convert the JSON object to a String jsonString = jsonEncode(json.decode(jsonString)); - responseIdCardDriverEgyptBack = jsonDecode(jsonString); - print(responseIdCardDriverEgyptBack); + if (idType == 'car_back') { + responseIdCardDriverEgyptBack = jsonDecode(jsonString); + print(responseIdCardDriverEgyptBack); + } else if (idType == 'car_front') { + responseIdCardDriverEgyptFront = jsonDecode(jsonString); + print(responseIdCardDriverEgyptFront); + } else if (idType == 'id_front') { + responseIdEgyptFront = jsonDecode(jsonString); + print(responseIdEgyptFront); + } else if (idType == 'id_back') { + responseIdEgyptBack = jsonDecode(jsonString); + print(responseIdEgyptBack); + } else if (idType == 'driver_license') { + responseIdEgyptDriverLicense = jsonDecode(jsonString); + print(responseIdEgyptDriverLicense); + } + update(); } else { print("JSON string not found"); + Get.snackbar('Error', "JSON string not found", + backgroundColor: AppColor.redColor); } // Rest of your code... @@ -503,10 +782,10 @@ Output the extracted information in the following JSON format''', if (jsonString != null) { // Convert the JSON object to a String jsonString = jsonEncode(json.decode(jsonString)); - responseCarLicenseMap = jsonDecode(jsonString); + responseCarLicenseMapJordan = jsonDecode(jsonString); print(jsonString); - print(responseCarLicenseMap); - print(responseCarLicenseMap['plate_number']); + print(responseCarLicenseMapJordan); + print(responseCarLicenseMapJordan['plate_number']); } else { print("JSON string not found"); } @@ -604,10 +883,10 @@ Output the extracted information in the following JSON format''', if (jsonString != null) { // Convert the JSON object to a String jsonString = jsonEncode(json.decode(jsonString)); - responseCarLicenseMap = jsonDecode(jsonString); + responseCarLicenseMapJordan = jsonDecode(jsonString); print(jsonString); - print(responseCarLicenseMap); - print(responseCarLicenseMap['plate_number']); + print(responseCarLicenseMapJordan); + print(responseCarLicenseMapJordan['plate_number']); } else { print("JSON string not found"); } @@ -714,10 +993,10 @@ Output the extracted information in the following JSON formate and make date for if (jsonString != null) { // Convert the JSON object to a String jsonString = jsonEncode(json.decode(jsonString)); - responseCarLicenseMap = jsonDecode(jsonString); + responseCarLicenseMapJordan = jsonDecode(jsonString); print(jsonString); - print(responseCarLicenseMap); - print(responseCarLicenseMap['plate_number']); + print(responseCarLicenseMapJordan); + print(responseCarLicenseMapJordan['plate_number']); } else { print("JSON string not found"); } diff --git a/lib/controller/functions/sms_egypt.dart b/lib/controller/functions/sms_egypt_controller.dart similarity index 77% rename from lib/controller/functions/sms_egypt.dart rename to lib/controller/functions/sms_egypt_controller.dart index e13de95..87139e2 100644 --- a/lib/controller/functions/sms_egypt.dart +++ b/lib/controller/functions/sms_egypt_controller.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:SEFER/constant/api_key.dart'; import 'package:SEFER/constant/box_name.dart'; import 'package:SEFER/constant/info.dart'; @@ -7,22 +9,28 @@ import 'package:SEFER/views/widgets/elevated_btn.dart'; import 'package:get/get.dart'; import 'package:http/http.dart' as http; -class SmsEgypt extends GetxController { +class SmsEgyptController extends GetxController { var headers = {'Content-Type': 'application/json'}; - Future sendSmsEgypt(String phone, otp) async { + Future sendSmsEgypt(String phone, otp) async { + var body = jsonEncode({ + "username": AppInformation.appName, + "password": AK.smsPassword, + "message": "${AppInformation.appName} app code is $otp\ncopy it to app", + "language": box.read(BoxName.lang) == 'en' ? "e" : 'r', + "sender": "Kazumi", // todo add sefer sender name + "receiver": "2$phone" + }); + var res = await http.post( Uri.parse(AppLink.sendSms), - body: { - "username": AppInformation.appName, - "password": AK.smsPassword, - "message": "${AppInformation.appName} app code is $otp\ncopy it to app", - "language": box.read(BoxName.lang) == 'en' ? "e" : 'r', - "sender": "Kazumi", // todo add sefer sender name - "receiver": "2$phone" - }, + body: body, headers: headers, ); + + print(res.reasonPhrase); + print(res.request); + print(res.body); if (res.statusCode == 200) { Get.defaultDialog( title: 'You will recieve code in sms message'.tr, diff --git a/lib/controller/functions/tts.dart b/lib/controller/functions/tts.dart index d766400..55fb9a7 100644 --- a/lib/controller/functions/tts.dart +++ b/lib/controller/functions/tts.dart @@ -6,7 +6,7 @@ import 'package:get/get.dart'; class TextToSpeechController extends GetxController { final flutterTts = FlutterTts(); - + bool isComplete = false; // Initialize TTS in initState @override void onInit() { @@ -41,6 +41,8 @@ class TextToSpeechController extends GetxController { if (result == 1) { // TTS operation has started // You can perform additional operations here, if needed + isComplete = true; + update(); } } catch (error) { // Handle error gracefully, e.g., show a message diff --git a/lib/controller/home/splash_screen_controlle.dart b/lib/controller/home/splash_screen_controlle.dart index 266ddaa..aa4d511 100644 --- a/lib/controller/home/splash_screen_controlle.dart +++ b/lib/controller/home/splash_screen_controlle.dart @@ -9,6 +9,7 @@ import 'package:SEFER/views/auth/login_page.dart'; import '../../constant/box_name.dart'; import '../../main.dart'; import '../../onbording_page.dart'; +import '../../views/auth/captin/cards_egypt/sms_signup.dart'; import '../../views/auth/captin/login_captin.dart'; import '../../views/home/Captin/home_captain/home_captin.dart'; @@ -50,7 +51,7 @@ class SplashScreenController extends GetxController box.read(BoxName.onBoarding) == null ? Get.off(() => OnBoardingPage()) : box.read(BoxName.emailDriver) != null - ? Get.off(() => RegisterCaptin()) + ? Get.off(() => SmsSignupEgypt()) : Get.off(() => LoginCaptin()); }); } diff --git a/lib/controller/local/translations.dart b/lib/controller/local/translations.dart index a7eefee..d29b62b 100644 --- a/lib/controller/local/translations.dart +++ b/lib/controller/local/translations.dart @@ -4,6 +4,70 @@ class MyTranslation extends Translations { @override Map> get keys => { "ar": { + 'You will recieve code in sms message': '', + 'Please enter': '', + 'We need your phone number to contact you and to help you receive orders.': + "نحتاج إلى رقم هاتفك للتواصل معك ولمساعدتك في تلقي الطلبات.", + 'The full name on your criminal record does not match the one on your driver’s license. Please verify and provide the correct documents.': + 'الاسم الكامل في سجلك الجنائي لا يتطابق مع الاسم الموجود في رخصة القيادة الخاصة بك. يرجى التحقق وتقديم الوثائق الصحيحة.', + "The national number on your driver’s license does not match the one on your ID document. Please verify and provide the correct documents.": + "الرقم الوطني على رخصة القيادة الخاصة بك لا يتطابق مع الرقم الموجود على وثيقة الهوية الخاصة بك. يرجى التحقق وتقديم الوثائق الصحيحة.", + "Capture an Image of Your Criminal Record": + "التقط صورة لسجلك الجنائي", + "IssueDate": "تاريخ الإصدار", + "Capture an Image of Your car license front ": + "التقط صورة للواجهة الأمامية لرخصة سيارتك", + "Capture an Image of Your ID Document front": + "التقط صورة للواجهة الأمامية لوثيقة هويتك", + "NationalID": "الرقم القومي", + "FullName": "الاسم الكامل", + "InspectionResult": "نتيجة الفحص", + "Criminal Record": "السجل الجنائي", + "The email or phone number is already registered.": + "البريد الإلكتروني أو رقم الهاتف مسجل بالفعل.", + 'To become a ride-sharing driver on the Sefer app, you need to upload your driver\'s license, ID document, and car registration document. Our AI system will instantly review and verify their authenticity in just 2-3 minutes. If your documents are approved, you can start working as a driver on the Sefer app. Please note, submitting fraudulent documents is a serious offense and may result in immediate termination and legal consequences.': + 'لِتُصْبِحَ سَائِقَاً لِلرُّكوبِ المُشْتَرَكِ عَلَى تَطْبِيق سَفَر، يَجِبُ عَلَيْكَ تَحْمِيل رُخْصَةِ القِيَادَةِ، وَثِيقَةِ الهُوِيَّةِ، وَوَثِيقَةَ تَسْجِيل السَّيَّارَةِ. سَيَقُومُ نِظَامُ الذَّكَاءِ الاِصْطِنَاعِيِّ لَدَيْنَا بِمُرَاجَعَةِ وَتَحْقِيقِ صِحَّةِ الوَثَائِقِ فِي غُضُونِ ٢-٣ دَقَائِقَ فَقَطْ. إِذَا تَمَّتْ المُوَافَقَةُ عَلَى وَثَائِقِكَ، يُمْكِنُكَ البَدْءُ فِي العَمَلِ كَسَائِقٍ عَلَى تَطْبِيق سَفَر. يُرْجَى مُلَاحَظَةُ، تَقْدِيمُ وَثَائِقَ مُزَورَةٍ يُعَدُّ جَرِيمَةً خَطِيرَةً وَقَدْ يَتَرَتَّبُ عَلَيْهِ اِنهَاءُ الحِسَابِ فَوْرِيَّاً وَعَوَاقِبُ قَانُونِيَّة.', + "Documents check": "فحص الوثائق", + "Driver's License": "رخصة القيادة", + "License Type": "نوع الرخصة", + "National Number": "الرقم الوطني", + "Name (Arabic)": "الاسم بالعربي", + "Name (English)": "الاسم بالإنجليزية", + "Address": "العنوان", + "Issue Date": "تاريخ الإصدار", + "Expiry Date": "تاريخ الانتهاء", + "License Categories": "فئات الرخصة", + "driver_license": "رخصة القيادة", + "Capture an Image of Your Driver License": "التقط صورة لرخصة قيادتك", + "ID Documents Back": "الوجه الخلفي لوثائق الهوية", + "National ID": "البطاقة الوطنية", + "Occupation": "المهنة", + "Gender": "الجنس", + "Religion": "الديانة", + "Marital Status": "الحالة الاجتماعية", + "Full Name (Marital)": "الاسم الكامل (حسب الحالة الاجتماعية)", + "Expiration Date": "تاريخ الانتهاء", + "Capture an Image of Your ID Document Back": + "التقط صورة للوجه الخلفي لوثيقة الهوية الخاصة بك", + "ID Documents Front": "الوجه الأمامي لوثائق الهوية", + "First Name": "الاسم الأول", + "CardID": "رقم البطاقة", + "Full Name": "الاسم الكامل", + "Vehicle Details Front": "تفاصيل المركبة ‏الوجه الأمامية", + "Plate Number": "رقم اللوحة", + "Owner Name": "اسم المالك", + "Vehicle Details Back": "تفاصيل المركبة ‏الوجه الخلفي", + "Make": "المصنع", + "Model": "الطراز", + "Year": "السنة", + "Chassis": "الشاسيه", + "Color": "اللون", + "Displacement": "السعة", + "Fuel": "الوقود", + "Tax Expiry Date": "تاريخ انتهاء الضريبة", + "Inspection Date": "تاريخ الفحص", + "Capture an Image of Your car license back": + "التقط صورة للوجه الخلفي لرخصة سيارتك", 'Capture an Image of Your Driver’s License': 'التقط صورة لرخصة قيادتك', 'Sign in with Google for easier email and name entry': diff --git a/lib/views/auth/captin/ai_page.dart b/lib/views/auth/captin/ai_page.dart index b36697c..10af248 100644 --- a/lib/views/auth/captin/ai_page.dart +++ b/lib/views/auth/captin/ai_page.dart @@ -33,11 +33,11 @@ class AiPage extends StatelessWidget { padding: const EdgeInsets.all(8.0), child: ListView( children: [ - egyptDriverLicense(), - egyptCarLicenceFront(), - egyptCarLicenceBack(), - egyptDriverIDFront(), - egyptDriverIDBack(), + // egyptDriverLicense(), + // egyptCarLicenceFront(), + // egyptCarLicenceBack(), + // egyptDriverIDFront(), + // egyptDriverIDBack(), ], ), ); @@ -46,506 +46,6 @@ class AiPage extends StatelessWidget { isleading: true); } - GetBuilder egyptDriverLicense() { - return GetBuilder( - builder: (ai) { - if (ai.responseIdEgyptDriverLicense.isNotEmpty) { - final expiryDate = ai.responseIdEgyptDriverLicense['expiry_date']; - - // Check if the expiry date is before today - final today = DateTime.now(); - - // Try parsing the expiry date. If it fails, set it to null. - final expiryDateTime = DateTime.tryParse(expiryDate); - final isExpired = - expiryDateTime != null && expiryDateTime.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: [ - Text('Driver\'s License'.tr, style: AppStyle.headTitle2), - const SizedBox(height: 8.0), - const Divider(color: AppColor.accentColor), - const SizedBox(height: 8.0), - Text( - '${'License Type'.tr}: ${ai.responseIdEgyptDriverLicense['license_type']}', - style: AppStyle.title, - ), - const SizedBox(height: 8.0), - Text( - '${'National Number'.tr}: ${ai.responseIdEgyptDriverLicense['national_number']}', - style: AppStyle.title.copyWith( - color: ai.responseIdEgyptDriverLicense[ - 'national_number'] == - ai.responseIdEgyptBack['nationalID'] - ? AppColor.greenColor - : AppColor.redColor), - ), - const SizedBox(height: 8.0), - Text( - '${'Name (Arabic)'.tr}: ${ai.responseIdEgyptDriverLicense['name_arabic']}', - ), - const SizedBox(height: 8.0), - Text( - '${'Name (English)'.tr}: ${ai.responseIdEgyptDriverLicense['name_english']}', - ), - const SizedBox(height: 8.0), - Text( - '${'Address'.tr}: ${ai.responseIdEgyptDriverLicense['address']}', - ), - const SizedBox(height: 8.0), - Text( - '${'Issue Date'.tr}: ${ai.responseIdEgyptDriverLicense['issue_date']}', - ), - const SizedBox(height: 8.0), - Text( - '${'Expiry Date'.tr}: ${ai.responseIdEgyptDriverLicense['expiry_date']}', - style: AppStyle.title.copyWith( - color: - !isExpired ? AppColor.greenColor : AppColor.redColor, - ), - ), - const SizedBox(height: 8.0), - Text( - '${'License Categories'.tr}: ${ai.responseIdEgyptDriverLicense['license_categories']}', - ), - ], - ), - ), - ); - } - return Card( - child: InkWell( - onTap: () async { - await ai.allMethodForAI( - '''Write a JSON object from the following information extracted from the provided Arabic text:license_type,national_number,name_arabic,name_english,address,issue_date,expiry_date,license_categories.and (date formate year-month-day in latin numbers) ''', - AppLink.uploadEgypt, - 'driver_license'); //egypt - }, - child: Column( - children: [ - Image.asset( - 'assets/images/5.png', - height: Get.height * .25, - width: double.maxFinite, - fit: BoxFit.fitHeight, - ), - Text( - 'Capture an Image of Your Driver License'.tr, - style: AppStyle.title, - ), - ], - ), - ), - ); - }, - ); - } - - GetBuilder egyptDriverIDBack() { - return GetBuilder( - builder: (ai) { - if (ai.responseIdEgyptBack.isNotEmpty) { - final taxExpiryDate = ai.responseIdEgyptBack['expirationDate']; - - // Check if the tax expiry date is before today - final today = DateTime.now(); - - // Try parsing the tax expiry date. If it fails, set it to null. - final taxExpiryDateTime = DateTime.tryParse(taxExpiryDate); - final isExpired = - taxExpiryDateTime != null && taxExpiryDateTime.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: [ - Text('ID Documents Back'.tr, style: AppStyle.headTitle2), - const SizedBox(height: 8.0), - const Divider(color: AppColor.accentColor), - const SizedBox(height: 8.0), - // Assuming these keys exist in ai.responseIdEgyptFront - Text( - '${'National ID'.tr}: ${ai.responseIdEgyptBack['nationalID']}', - style: AppStyle.title), - - const SizedBox(height: 8.0), - Text( - '${'Occupation'.tr}: ${ai.responseIdEgyptBack['occupation']}', // Assuming 'occupation' exists - ), - const SizedBox(height: 8.0), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '${'Issue Date'.tr}: ${ai.responseIdEgyptBack['issueDate']}', // Assuming 'issueDate' exists - ), - Text( - '${'Gender'.tr}: ${ai.responseIdEgyptBack['gender']}', // Assuming 'gender' exists - ), - ], - ), - const SizedBox(height: 8.0), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '${'Religion'.tr}: ${ai.responseIdEgyptBack['religion']}', // Assuming 'religion' exists - ), - Text( - '${'Marital Status'.tr}: ${ai.responseIdEgyptBack['maritalStatus']}', // Assuming 'maritalStatus' exists - ), - ], - ), - const SizedBox(height: 8.0), - Text( - '${'Full Name (Marital)'.tr}: ${ai.responseIdEgyptBack['fullNameMaritial']}', // Assuming 'fullNameMaritial' exists - ), - const SizedBox(height: 8.0), - Text( - '${'Expiration Date'.tr}: ${ai.responseIdEgyptBack['expirationDate']}', // Assuming 'expirationDate' exists - style: AppStyle.title.copyWith( - color: !isExpired - ? AppColor.greenColor - : AppColor.redColor), - ), - ], - ), - ), - ); - } - return Card( - child: InkWell( - onTap: () async { - await ai.allMethodForAI( - '''Write a JSON from the following information extracted from the provided Arabic text:nationalID,issueDate,occupation,gender,religion,maritalStatus,fullNameMaritial if(أعزب)=none ,expirationDate.and (date formate year-month-day in latin numbers) ''', - AppLink.uploadEgypt, - 'id_back'); //egypt - }, - child: Column( - children: [ - Image.asset( - 'assets/images/2.png', - height: Get.height * .25, - width: double.maxFinite, - fit: BoxFit.fitHeight, - ), - Text( - 'Capture an Image of Your ID Document Back'.tr, - style: AppStyle.title, - ), - ], - ), - ), - ); - }, - ); - } - - GetBuilder egyptDriverIDFront() { - return GetBuilder( - builder: (ai) { - if (ai.responseIdEgyptFront.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: [ - Text('ID Documents Front'.tr, style: AppStyle.headTitle2), - const SizedBox(height: 8.0), - const Divider(color: AppColor.accentColor), - const SizedBox(height: 8.0), - // Removed Make, Model, etc. as they are not available - - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '${'First Name'.tr}: ${ai.responseIdEgyptFront['first_name']}', - ), - Text( - '${'CardID'.tr}: ${ai.responseIdEgyptFront['card_id']}', - ), - ], - ), - const SizedBox(height: 8.0), - Text( - '${'Full Name'.tr}: ${ai.responseIdEgyptFront['full_name']}', - ), - const SizedBox(height: 8.0), - Text( - '${'Address'.tr}: ${ai.responseIdEgyptFront['address']}', - ), - const SizedBox(height: 8.0), - Text( - '${'National Number'.tr}: ${ai.responseIdEgyptFront['national_number']}', - ), - const SizedBox(height: 8.0), - - // Removed Inspection Date as it's not available - ], - ), - ), - ); - } - return Card( - child: InkWell( - onTap: () async { - await ai.allMethodForAI( - '''Write a JSON object from the following information extracted from the provided Arabic text:first_name: The word next to "بطاقة تحقيق الشخصية" (National Identification Card).full_name: The full name on the next line after the first name.address: The complete address spanning the next two lines.national_number: The Arabic numeral representing the National ID number before the last line.card_id: The card ID in English on the last line ''', - AppLink.uploadEgypt, - 'id_front'); //egypt - }, - child: Column( - children: [ - Image.asset( - 'assets/images/1.png', - height: Get.height * .25, - width: double.maxFinite, - fit: BoxFit.fitHeight, - ), - Text( - 'Capture an Image of Your ID Document front'.tr, - style: AppStyle.title, - ), - ], - ), - ), - ); - }, - ); - } - - GetBuilder egyptCarLicenceFront() { - return GetBuilder( - builder: (ai) { - if (ai.responseIdCardDriverEgyptFront.isNotEmpty) { - // No need to access ai.responseIdCardDriverEgyptBack anymore - final licenseExpiryDate = DateTime.parse( - ai.responseIdCardDriverEgyptFront['LicenseExpirationDate']); - - // Check if license has expired - final today = DateTime.now(); - final isLicenseExpired = licenseExpiryDate.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: [ - Text('Vehicle Details Front'.tr, style: AppStyle.headTitle2), - const SizedBox(height: 8.0), - const Divider(color: AppColor.accentColor), - const SizedBox(height: 8.0), - // Removed Make, Model, etc. as they are not available - - Text( - '${'Plate Number'.tr}: ${ai.responseIdCardDriverEgyptFront['car_plate']}', - ), - const SizedBox(height: 8.0), - Text( - '${'Owner Name'.tr}: ${ai.responseIdCardDriverEgyptFront['owner']}', - ), - const SizedBox(height: 8.0), - Text( - '${'Address'.tr}: ${ai.responseIdCardDriverEgyptFront['address']}', - ), - const SizedBox(height: 8.0), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '${'License Expiry Date'.tr}: ${licenseExpiryDate.toString().substring(0, 10)}', - style: TextStyle( - color: isLicenseExpired ? Colors.red : Colors.green, - ), - ), - // Removed Fuel as it's not available - ], - ), - // Removed Inspection Date as it's not available - ], - ), - ), - ); - } - return Card( - child: InkWell( - onTap: () async { - ai.allMethodForAI( - 'extract all fields as json for keys[LicenseExpirationDate,car_plate,owner,address] replace | by space,and date formate year-month-day', - AppLink.uploadEgypt, - 'car_front'); - }, - child: Column( - children: [ - Image.asset( - 'assets/images/3.png', - height: Get.height * .25, - width: double.maxFinite, - fit: BoxFit.fitHeight, - ), - Text( - 'Capture an Image of Your car license front '.tr, - style: AppStyle.title, - ), - ], - ), - ), - ); - }, - ); - } - - GetBuilder egyptCarLicenceBack() { - return GetBuilder( - builder: (ai) { - if (ai.responseIdCardDriverEgyptBack.isNotEmpty) { - // print(ai.responseIdCardDriverEgyptBack); - - // Get the tax expiry date from the response - final taxExpiryDate = ai.responseIdCardDriverEgyptBack['tax_expiry']; - - // Get the inspection date from the response - final inspectionDate = - ai.responseIdCardDriverEgyptBack['inspection_date']; - - // Check if the tax expiry date is before today - final today = DateTime.now(); - - // Try parsing the tax expiry date. If it fails, set it to null. - final taxExpiryDateTime = DateTime.tryParse(taxExpiryDate); - final isExpired = - taxExpiryDateTime != null && taxExpiryDateTime.isBefore(today); - - // Check if the inspection date is before today - final inspectionDateTime = DateTime(int.parse(inspectionDate), 1, 1); - final isInspectionExpired = inspectionDateTime.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: [ - Text('Vehicle Details Back'.tr, style: AppStyle.headTitle2), - const SizedBox(height: 8.0), - const Divider(color: AppColor.accentColor), - const SizedBox(height: 8.0), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '${'Make'.tr}: ${ai.responseIdCardDriverEgyptBack['make']}'), - Text( - '${'Model'.tr}: ${ai.responseIdCardDriverEgyptBack['model']}'), - ], - ), - const SizedBox(height: 8.0), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '${'Year'.tr}: ${ai.responseIdCardDriverEgyptBack['year']}'), - Text( - '${'Chassis'.tr}: ${ai.responseIdCardDriverEgyptBack['chassis']}'), - ], - ), - const SizedBox(height: 8.0), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '${'Color'.tr}: ${ai.responseIdCardDriverEgyptBack['color']}'), - Text( - '${'Displacement'.tr}: ${ai.responseIdCardDriverEgyptBack['displacement']} cc'), - ], - ), - const SizedBox(height: 8.0), - Text( - '${'Fuel'.tr}: ${ai.responseIdCardDriverEgyptBack['fuel']}'), - const SizedBox(height: 8.0), - Text( - '${'Tax Expiry Date'.tr}: ${taxExpiryDateTime != null ? taxExpiryDate : 'N/A'}', - style: TextStyle( - color: isExpired ? Colors.red : Colors.green, - ), - ), - const SizedBox(height: 8.0), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '${'Inspection Date'.tr}: $inspectionDate', - style: TextStyle( - color: - isInspectionExpired ? Colors.red : Colors.green, - ), - ), - // Text( - // '${'Cylinders'.tr}: ${ai.responseIdCardDriverEgypt['cylinders']}'), - ], - ), - ], - ), - ), - ); - } - return Card( - child: InkWell( - onTap: () async { - ai.allMethodForAI( - 'this extracted car license analyze it to get Json just without any text for keys[make, year, chassis, model, engine, displacement, cylinders, fuel, color, inspection_date,assurnceNumber, tax_expiry,make date format year-month-day', - AppLink.uploadEgypt, - 'car_back'); - }, - child: Column( - children: [ - Image.asset( - 'assets/images/4.png', - height: Get.height * .25, - width: double.maxFinite, - fit: BoxFit.fitHeight, - ), - Text( - 'Capture an Image of Your car license back'.tr, - style: AppStyle.title, - ), - ], - ), - ), - ); - }, - ); - } - GetBuilder egyptDriverLicenseWidget() { return GetBuilder( builder: (contentController) => contentController.responseMap.isNotEmpty @@ -692,7 +192,7 @@ class AiPage extends StatelessWidget { const SizedBox( height: 10, ), - contentController.responseCarLicenseMap.isNotEmpty + contentController.responseCarLicenseMapJordan.isNotEmpty ? Container( decoration: AppStyle.boxDecoration, // height: Get.height * .3, @@ -700,35 +200,36 @@ class AiPage extends StatelessWidget { child: Column( children: [ Text( - '${'Name'.tr} ${contentController.responseCarLicenseMap['name']}', + '${'Name'.tr} ${contentController.responseCarLicenseMapJordan['name']}', style: AppStyle.title, ), Text( - '${'Address'.tr} ${contentController.responseCarLicenseMap['address']}', + '${'Address'.tr} ${contentController.responseCarLicenseMapJordan['address']}', style: AppStyle.title, ), Text( - '${'Car Kind'.tr} ${contentController.responseCarLicenseMap['car_kind']}', + '${'Car Kind'.tr} ${contentController.responseCarLicenseMapJordan['car_kind']}', style: AppStyle.title, ), Text( - '${'Color'.tr} ${contentController.responseCarLicenseMap['car_color']}', + '${'Color'.tr} ${contentController.responseCarLicenseMapJordan['car_color']}', style: AppStyle.title, ), Text( - '${'Year'.tr} ${contentController.responseCarLicenseMap['car_year']}', + '${'Year'.tr} ${contentController.responseCarLicenseMapJordan['car_year']}', style: AppStyle.title, ), Text( - '${'Car Plate'.tr} ${contentController.responseCarLicenseMap['car_plate']}', + '${'Car Plate'.tr} ${contentController.responseCarLicenseMapJordan['car_plate']}', style: AppStyle.title, ), Text( - '${'Car Expire'.tr} ${contentController.responseCarLicenseMap['expire_date_of_license']}', + '${'Car Expire'.tr} ${contentController.responseCarLicenseMapJordan['expire_date_of_license']}', style: contentController - .responseCarLicenseMap.isNotEmpty + .responseCarLicenseMapJordan + .isNotEmpty ? DateTime.parse(contentController - .responseCarLicenseMap[ + .responseCarLicenseMapJordan[ 'expire_date_of_license'] .toString()) .isBefore(contentController.now) @@ -1003,7 +504,8 @@ Output the extracted information in the following JSON formate and make date for const SizedBox( height: 10, ), - contentController.responseCarLicenseMap.isNotEmpty + contentController + .responseCarLicenseMapJordan.isNotEmpty ? Container( decoration: AppStyle.boxDecoration, // height: Get.height * .3, @@ -1011,36 +513,36 @@ Output the extracted information in the following JSON formate and make date for child: Column( children: [ Text( - '${'Name'.tr} ${contentController.responseCarLicenseMap['name']}', + '${'Name'.tr} ${contentController.responseCarLicenseMapJordan['name']}', style: AppStyle.title, ), Text( - '${'Address'.tr} ${contentController.responseCarLicenseMap['address']}', + '${'Address'.tr} ${contentController.responseCarLicenseMapJordan['address']}', style: AppStyle.title, ), Text( - '${'Car Kind'.tr} ${contentController.responseCarLicenseMap['car_kind']}', + '${'Car Kind'.tr} ${contentController.responseCarLicenseMapJordan['car_kind']}', style: AppStyle.title, ), Text( - '${'Color'.tr} ${contentController.responseCarLicenseMap['car_color']}', + '${'Color'.tr} ${contentController.responseCarLicenseMapJordan['car_color']}', style: AppStyle.title, ), Text( - '${'Year'.tr} ${contentController.responseCarLicenseMap['car_year']}', + '${'Year'.tr} ${contentController.responseCarLicenseMapJordan['car_year']}', style: AppStyle.title, ), Text( - '${'Car Plate'.tr} ${contentController.responseCarLicenseMap['car_plate']}', + '${'Car Plate'.tr} ${contentController.responseCarLicenseMapJordan['car_plate']}', style: AppStyle.title, ), Text( - '${'ُExpire Date'.tr} ${contentController.responseCarLicenseMap['expire_date_of_license']}', + '${'ُExpire Date'.tr} ${contentController.responseCarLicenseMapJordan['expire_date_of_license']}', style: contentController - .responseCarLicenseMap + .responseCarLicenseMapJordan .isNotEmpty ? DateTime.parse(contentController - .responseCarLicenseMap[ + .responseCarLicenseMapJordan[ 'expire_date_of_license'] .toString()) .isBefore( diff --git a/lib/views/auth/captin/cards/egypt_card.dart b/lib/views/auth/captin/cards/egypt_card.dart deleted file mode 100644 index 204a9cb..0000000 --- a/lib/views/auth/captin/cards/egypt_card.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:SEFER/controller/functions/gemeni.dart'; -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -class EgyptCard extends StatelessWidget { - const EgyptCard({super.key}); - - @override - Widget build(BuildContext context) { - Get.put(AI()); - return Scaffold( - appBar: AppBar( - title: const Text('Egypt Card'), - ), - body: GetBuilder(builder: (controller) { - return Center( - child: Container( - child: Text( - controller.responseIdCardDriverEgyptBack['firstName'].toString()), - )); - }), - ); - } -} diff --git a/lib/views/auth/captin/cards_egypt/egypt_card_a_i.dart b/lib/views/auth/captin/cards_egypt/egypt_card_a_i.dart new file mode 100644 index 0000000..c3543ec --- /dev/null +++ b/lib/views/auth/captin/cards_egypt/egypt_card_a_i.dart @@ -0,0 +1,856 @@ +import 'package:SEFER/controller/functions/gemeni.dart'; +import 'package:SEFER/controller/functions/tts.dart'; +import 'package:SEFER/views/widgets/elevated_btn.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:get/get.dart'; + +import '../../../../constant/colors.dart'; +import '../../../../constant/links.dart'; +import '../../../../constant/style.dart'; +import '../../../widgets/my_scafold.dart'; +import '../../../widgets/mycircular.dart'; + +class EgyptCardAI extends StatelessWidget { + EgyptCardAI({super.key}); + TextToSpeechController textToSpeechController = + Get.put(TextToSpeechController()); + @override + Widget build(BuildContext context) { + Get.put(AI()); + // String text = ''; + + return MyScafolld( + title: 'Documents check'.tr, + body: [ + GetBuilder(builder: (controller) { + return controller.isLoading + ? const MyCircularProgressIndicator() + : Padding( + 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) + ? 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, + child: ListView( + children: [ + egyptDriverLicense(), + egyptCarLicenceFront(), + egyptCarLicenceBack(), + egyptDriverIDFront(), + egyptDriverIDBack(), + egyptCriminalRecord(), + ], + ), + ), + ], + ), + ); + }), + Positioned( + top: 30, + bottom: 30, + right: 30, + left: 30, + child: GetBuilder(builder: (controller) { + print(controller.approved); + return controller.approved == false + ? Container( + decoration: AppStyle.boxDecoration1, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Text( + 'Approve Driver Documents', + style: AppStyle.title, + ), + const SizedBox(height: 8), + Text( + 'To become a ride-sharing driver on the Sefer app, you need to upload your driver\'s license, ID document, and car registration document. Our AI system will instantly review and verify their authenticity in just 2-3 minutes. If your documents are approved, you can start working as a driver on the Sefer app. Please note, submitting fraudulent documents is a serious offense and may result in immediate termination and legal consequences.' + .tr, + style: AppStyle.title, + textAlign: TextAlign.center, + ), + const SizedBox(height: 8), + Container( + decoration: AppStyle.boxDecoration1, + child: TextButton.icon( + onPressed: () async { + await textToSpeechController.speakText( + 'To become a ride-sharing driver on the Sefer app, you need to upload your driver\'s license, ID document, and car registration document. Our AI system will instantly review and verify their authenticity in just 2-3 minutes. If your documents are approved, you can start working as a driver on the Sefer app. Please note, submitting fraudulent documents is a serious offense and may result in immediate termination and legal consequences.' + .tr); + }, + icon: const Icon( + Icons.headphones, + size: 50, + ), + label: Text( + 'Press to hear'.tr, + style: AppStyle.title, + ), + ), + ), + const SizedBox(height: 8), + GetBuilder( + builder: (textToSpeechController) { + return textToSpeechController.isComplete + ? Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + MyElevatedButton( + title: 'OK'.tr, + kolor: AppColor.greenColor, + onPressed: () { + controller.setApproved(); + }), + MyElevatedButton( + title: 'cancel'.tr, + kolor: AppColor.redColor, + onPressed: () { + Get.defaultDialog( + title: + 'You will cancel registeration' + .tr, + middleText: '', + content: IconButton( + onPressed: () async { + await textToSpeechController + .speakText( + 'You will cancel registeration' + .tr); + }, + icon: const Icon( + Icons.headphones), + ), + confirm: MyElevatedButton( + title: 'OK'.tr, + kolor: AppColor.redColor, + onPressed: () { + Get.back(); + Get.back(); + }), + cancel: MyElevatedButton( + title: 'Cancel'.tr, + kolor: + AppColor.greenColor, + onPressed: () { + Get.back(); + })); + }), + ], + ) + : const SizedBox(); + }) + ], + ), + ), + ) + : const SizedBox(); + }), + ) + ], + isleading: true); + } + + GetBuilder egyptDriverLicense() { + return GetBuilder( + builder: (ai) { + if (ai.responseIdEgyptDriverLicense.isNotEmpty) { + final expiryDate = ai.responseIdEgyptDriverLicense['expiry_date']; + + // Check if the expiry date is before today + final today = DateTime.now(); + + // Try parsing the expiry date. If it fails, set it to null. + final expiryDateTime = DateTime.tryParse(expiryDate); + final isExpired = + expiryDateTime != null && expiryDateTime.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('Driver\'s License'.tr, style: AppStyle.headTitle2), + IconButton( + onPressed: () async { + await ai.allMethodForAI( + '''Write a JSON object from the following information extracted from the provided Arabic text:license_type,national_number,name_arabic,name_english,firstName,lastName,address,issue_date,expiry_date,employmentType,license_categories.and (date formate year-month-day in latin numbers) ''', + AppLink.uploadEgypt, + 'driver_license'); //egypt + }, + icon: const Icon(Icons.refresh), + ), + ], + ), + const SizedBox(height: 8.0), + const Divider(color: AppColor.accentColor), + const SizedBox(height: 8.0), + Text( + '${'License Type'.tr}: ${ai.responseIdEgyptDriverLicense['license_type']}', + style: AppStyle.title, + ), + const SizedBox(height: 8.0), + Text( + '${'National Number'.tr}: ${ai.responseIdEgyptDriverLicense['national_number']}', + style: AppStyle.title.copyWith( + color: ai.responseIdEgyptDriverLicense[ + 'national_number'] == + ai.responseIdEgyptBack['nationalID'] + ? AppColor.greenColor + : AppColor.redColor), + ), + const SizedBox(height: 8.0), + Text( + '${'Name (Arabic)'.tr}: ${ai.responseIdEgyptDriverLicense['name_arabic']}', + ), + const SizedBox(height: 8.0), + Text( + '${'Name (English)'.tr}: ${ai.responseIdEgyptDriverLicense['name_english']}', + ), + const SizedBox(height: 8.0), + Text( + '${'Address'.tr}: ${ai.responseIdEgyptDriverLicense['address']}', + ), + const SizedBox(height: 8.0), + Text( + '${'Issue Date'.tr}: ${ai.responseIdEgyptDriverLicense['issue_date']}', + ), + const SizedBox(height: 8.0), + Text( + '${'Expiry Date'.tr}: ${ai.responseIdEgyptDriverLicense['expiry_date']}', + style: AppStyle.title.copyWith( + color: + !isExpired ? AppColor.greenColor : AppColor.redColor, + ), + ), + const SizedBox(height: 8.0), + Text( + '${'License Categories'.tr}: ${ai.responseIdEgyptDriverLicense['license_categories']}', + ), + ], + ), + ), + ); + } + return Card( + child: InkWell( + onTap: () async { + await ai.allMethodForAI( + '''Write a JSON object from the following information extracted from the provided Arabic text:license_type,national_number,name_arabic,name_english,firstName,lastName,address,issue_date,expiry_date,employmentType,license_categories.and (date formate year-month-day in latin numbers) ''', + AppLink.uploadEgypt, + 'driver_license'); //egypt + }, + child: Column( + children: [ + Image.asset( + 'assets/images/5.png', + height: Get.height * .25, + width: double.maxFinite, + fit: BoxFit.fitHeight, + ), + Text( + 'Capture an Image of Your Driver License'.tr, + style: AppStyle.title, + ), + ], + ), + ), + ); + }, + ); + } + + GetBuilder egyptDriverIDBack() { + return GetBuilder( + builder: (ai) { + if (ai.responseIdEgyptBack.isNotEmpty) { + final taxExpiryDate = ai.responseIdEgyptBack['expirationDate']; + + // Check if the tax expiry date is before today + final today = DateTime.now(); + + // Try parsing the tax expiry date. If it fails, set it to null. + final taxExpiryDateTime = DateTime.tryParse(taxExpiryDate); + final isExpired = + taxExpiryDateTime != null && taxExpiryDateTime.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('ID Documents Back'.tr, style: AppStyle.headTitle2), + IconButton( + onPressed: () async { + await ai.allMethodForAI( + '''Write a JSON from the following information extracted from the provided Arabic text:nationalID,issueDate,occupation,gender,religion,maritalStatus,fullNameMaritial if(أعزب)=none ,expirationDate.and (date formate year-month-day in latin numbers) ''', + AppLink.uploadEgypt, + 'id_back'); //egypt + }, + icon: const Icon(Icons.refresh), + ), + ], + ), + const SizedBox(height: 8.0), + const Divider(color: AppColor.accentColor), + const SizedBox(height: 8.0), + // Assuming these keys exist in ai.responseIdEgyptFront + Text( + '${'National ID'.tr}: ${ai.responseIdEgyptBack['nationalID']}', + style: AppStyle.title.copyWith( + color: ai.responseIdEgyptDriverLicense[ + 'national_number'] == + ai.responseIdEgyptBack['nationalID'] + ? AppColor.greenColor + : AppColor.redColor), + ), + + const SizedBox(height: 8.0), + Text( + '${'Occupation'.tr}: ${ai.responseIdEgyptBack['occupation']}', // Assuming 'occupation' exists + ), + const SizedBox(height: 8.0), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '${'Issue Date'.tr}: ${ai.responseIdEgyptBack['issueDate']}', // Assuming 'issueDate' exists + ), + Text( + '${'Gender'.tr}: ${ai.responseIdEgyptBack['gender']}', // Assuming 'gender' exists + ), + ], + ), + const SizedBox(height: 8.0), + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // '${'Religion'.tr}: ${ai.responseIdEgyptBack['religion']}', // Assuming 'religion' exists + // ), + // Text( + // '${'Marital Status'.tr}: ${ai.responseIdEgyptBack['maritalStatus']}', // Assuming 'maritalStatus' exists + // ), + // ], + // ), + // const SizedBox(height: 8.0), + // Text( + // '${'Full Name (Marital)'.tr}: ${ai.responseIdEgyptBack['fullNameMaritial']}', // Assuming 'fullNameMaritial' exists + // ), + // const SizedBox(height: 8.0), + Text( + '${'Expiration Date'.tr}: ${ai.responseIdEgyptBack['expirationDate']}', // Assuming 'expirationDate' exists + style: AppStyle.title.copyWith( + color: !isExpired + ? AppColor.greenColor + : AppColor.redColor), + ), + ], + ), + ), + ); + } + return Card( + child: InkWell( + onTap: () async { + await ai.allMethodForAI( + '''Write a JSON from the following information extracted from the provided Arabic text:nationalID,issueDate,occupation,gender,religion,maritalStatus,fullNameMaritial if(أعزب)=none ,expirationDate.and (date formate year-month-day in latin numbers) ''', + AppLink.uploadEgypt, + 'id_back'); //egypt + }, + child: Column( + children: [ + Image.asset( + 'assets/images/2.png', + height: Get.height * .25, + width: double.maxFinite, + fit: BoxFit.fitHeight, + ), + Text( + 'Capture an Image of Your ID Document Back'.tr, + style: AppStyle.title, + ), + ], + ), + ), + ); + }, + ); + } + + GetBuilder egyptDriverIDFront() { + return GetBuilder( + builder: (ai) { + if (ai.responseIdEgyptFront.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('ID Documents Front'.tr, style: AppStyle.headTitle2), + IconButton( + onPressed: () async { + await ai.allMethodForAI( + '''Write a JSON object from the following information extracted from the provided Arabic text:first_name: The word next to "بطاقة تحقيق الشخصية" (National Identification Card).full_name: The full name on the next line after the first name.address: The complete address spanning the next two lines.national_number: The Arabic numeral representing the National ID number before the last line.card_id: The card ID in English on the last line and dob for date in year note month just year of born in latin char ''', + AppLink.uploadEgypt, + 'id_front'); //egypt + }, + icon: const Icon(Icons.refresh), + ), + ], + ), + const SizedBox(height: 8.0), + const Divider(color: AppColor.accentColor), + const SizedBox(height: 8.0), + // Removed Make, Model, etc. as they are not available + + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '${'First Name'.tr}: ${ai.responseIdEgyptFront['first_name']}', + ), + Text( + '${'CardID'.tr}: ${ai.responseIdEgyptFront['card_id']}', + ), + ], + ), + const SizedBox(height: 8.0), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '${'Full Name'.tr}: ${ai.responseIdEgyptFront['full_name']}', + ), + Text( + '${'DOB'.tr}: ${ai.responseIdEgyptFront['dob']}', + ), + ], + ), + const SizedBox(height: 8.0), + Text( + '${'Address'.tr}: ${ai.responseIdEgyptFront['address']}', + ), + const SizedBox(height: 8.0), + // Text( + // '${'National Number'.tr}: ${ai.responseIdEgyptFront['national_number']}', + // ), + // const SizedBox(height: 8.0), + + // Removed Inspection Date as it's not available + ], + ), + ), + ); + } + return Card( + child: InkWell( + onTap: () async { + await ai.allMethodForAI( + '''Write a JSON object from the following information extracted from the provided Arabic text:first_name: The word next to "بطاقة تحقيق الشخصية" (National Identification Card).full_name: The full name on the next line after the first name.address: The complete address spanning the next two lines.national_number: The Arabic numeral representing the National ID number before the last line.card_id: The card ID in English on the last line and dob for date in year note month just year of born in latin char ''', + AppLink.uploadEgypt, + 'id_front'); //egypt + }, + child: Column( + children: [ + Image.asset( + 'assets/images/1.png', + height: Get.height * .25, + width: double.maxFinite, + fit: BoxFit.fitHeight, + ), + Text( + 'Capture an Image of Your ID Document front'.tr, + style: AppStyle.title, + ), + ], + ), + ), + ); + }, + ); + } + + GetBuilder egyptCarLicenceFront() { + return GetBuilder( + builder: (ai) { + if (ai.responseIdCardDriverEgyptFront.isNotEmpty) { + // No need to access ai.responseIdCardDriverEgyptBack anymore + final licenseExpiryDate = DateTime.parse( + ai.responseIdCardDriverEgyptFront['LicenseExpirationDate']); + + // Check if license has expired + final today = DateTime.now(); + final isLicenseExpired = licenseExpiryDate.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( + children: [ + Text('Vehicle Details Front'.tr, + style: AppStyle.headTitle2), + IconButton( + onPressed: () async { + ai.allMethodForAI( + 'extract all fields as json for keys[LicenseExpirationDate,car_plate,owner,address] replace | by space,and date formate year-month-day', + AppLink.uploadEgypt, + 'car_front'); + }, + icon: const Icon(Icons.refresh), + ), + ], + ), + const SizedBox(height: 8.0), + const Divider(color: AppColor.accentColor), + const SizedBox(height: 8.0), + // Removed Make, Model, etc. as they are not available + + Text( + '${'Plate Number'.tr}: ${ai.responseIdCardDriverEgyptFront['car_plate']}', + ), + const SizedBox(height: 8.0), + Text( + '${'Owner Name'.tr}: ${ai.responseIdCardDriverEgyptFront['owner']}', + ), + const SizedBox(height: 8.0), + Text( + '${'Address'.tr}: ${ai.responseIdCardDriverEgyptFront['address']}', + ), + const SizedBox(height: 8.0), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '${'License Expiry Date'.tr}: ${licenseExpiryDate.toString().substring(0, 10)}', + style: TextStyle( + color: isLicenseExpired ? Colors.red : Colors.green, + ), + ), + // Removed Fuel as it's not available + ], + ), + // Removed Inspection Date as it's not available + ], + ), + ), + ); + } + return Card( + child: InkWell( + onTap: () async { + ai.allMethodForAI( + 'extract all fields as json for keys[LicenseExpirationDate,car_plate,owner,address] replace | by space,and date formate year-month-day', + AppLink.uploadEgypt, + 'car_front'); + }, + child: Column( + children: [ + Image.asset( + 'assets/images/3.png', + height: Get.height * .25, + width: double.maxFinite, + fit: BoxFit.fitHeight, + ), + Text( + 'Capture an Image of Your car license front '.tr, + style: AppStyle.title, + ), + ], + ), + ), + ); + }, + ); + } + + GetBuilder egyptCarLicenceBack() { + return GetBuilder( + builder: (ai) { + if (ai.responseIdCardDriverEgyptBack.isNotEmpty) { + // print(ai.responseIdCardDriverEgyptBack); + + // Get the tax expiry date from the response + final taxExpiryDate = ai.responseIdCardDriverEgyptBack['tax_expiry']; + + // Get the inspection date from the response + final inspectionDate = + ai.responseIdCardDriverEgyptBack['inspection_date']; + + // Check if the tax expiry date is before today + final today = DateTime.now(); + + // Try parsing the tax expiry date. If it fails, set it to null. + final taxExpiryDateTime = DateTime.tryParse(taxExpiryDate ?? ''); + final isExpired = + taxExpiryDateTime != null && taxExpiryDateTime.isBefore(today); + + // Check if the inspection date is before today + final inspectionDateTime = + DateTime(int.parse(inspectionDate ?? ''), 1, 1); + final isInspectionExpired = inspectionDateTime.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('Vehicle Details Back'.tr, + style: AppStyle.headTitle2), + IconButton( + onPressed: () async { + ai.allMethodForAI( + 'for this this extracted car license analyze it to get Json just without any text for keys[make, year, chassis, model, engine, displacement, cylinders, fuel, color,and color_hex (for color) inspection_date,assurnceNumber, tax_expiry,make date format year-month-day get hex color form color name provided', + AppLink.uploadEgypt, + 'car_back'); + }, + icon: const Icon(Icons.refresh), + ), + ], + ), + const SizedBox(height: 8.0), + const Divider(color: AppColor.accentColor), + const SizedBox(height: 8.0), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '${'Make'.tr}: ${ai.responseIdCardDriverEgyptBack['make']}'), + Text( + '${'Model'.tr}: ${ai.responseIdCardDriverEgyptBack['model']}'), + ], + ), + const SizedBox(height: 8.0), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '${'Year'.tr}: ${ai.responseIdCardDriverEgyptBack['year']}'), + Text( + '${'Chassis'.tr}: ${ai.responseIdCardDriverEgyptBack['chassis']}'), + ], + ), + const SizedBox(height: 8.0), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '${'Color'.tr}: ${ai.responseIdCardDriverEgyptBack['color']}'), + Text( + '${'Displacement'.tr}: ${ai.responseIdCardDriverEgyptBack['displacement']} cc'), + ], + ), + const SizedBox(height: 8.0), + Text( + '${'Fuel'.tr}: ${ai.responseIdCardDriverEgyptBack['fuel']}'), + const SizedBox(height: 8.0), + if (taxExpiryDateTime != null) + Text( + '${'Tax Expiry Date'.tr}: $taxExpiryDate', + style: TextStyle( + color: isExpired ? Colors.red : Colors.green, + ), + ), + const SizedBox(height: 8.0), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '${'Inspection Date'.tr}: $inspectionDate', + style: TextStyle( + color: + isInspectionExpired ? Colors.red : Colors.green, + ), + ), + ], + ), + ], + ), + ), + ); + } + return Card( + child: InkWell( + onTap: () async { + ai.allMethodForAI( + 'this extracted car license analyze it to get Json just without any text for keys[make, year, chassis, model, engine, displacement, cylinders, fuel, color,and color_hex from color inspection_date,assurnceNumber, tax_expiry,make date format year-month-day', + AppLink.uploadEgypt, + 'car_back'); + }, + child: Column( + children: [ + Image.asset( + 'assets/images/4.png', + height: Get.height * .25, + width: double.maxFinite, + fit: BoxFit.fitHeight, + ), + Text( + 'Capture an Image of Your car license back'.tr, + style: AppStyle.title, + ), + ], + ), + ), + ); + }, + ); + } + + GetBuilder egyptCriminalRecord() { + return GetBuilder( + builder: (ai) { + if (ai.responseCriminalRecordEgypt.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('Criminal Record'.tr, style: AppStyle.headTitle2), + IconButton( + onPressed: () async { + await ai.allMethodForAI( + 'Write a JSON object from the following information extracted from the provided Arabic text:["InspectionResult": ,"NationalID","FullName","IssueDate"]make date format year-month-day ,and add spaces in text', + AppLink.uploadEgypt, + 'criminalRecord', + ); + }, + icon: const Icon(Icons.refresh), + ), + ], + ), + const SizedBox(height: 8.0), + const Divider(color: AppColor.accentColor), + const SizedBox(height: 8.0), + Text( + '${'InspectionResult'.tr}: ${ai.responseCriminalRecordEgypt['InspectionResult']}'), + const SizedBox(height: 8.0), + Text( + '${'FullName'.tr}: ${ai.responseCriminalRecordEgypt['FullName']}', + style: AppStyle.title.copyWith( + color: ai.responseCriminalRecordEgypt['FullName'] == + ai.responseIdEgyptDriverLicense['name_arabic'] + ? AppColor.greenColor + : AppColor.redColor), + ), + const SizedBox(height: 8.0), + Text( + '${'NationalID'.tr}: ${ai.responseCriminalRecordEgypt['NationalID']}'), + const SizedBox(height: 8.0), + Text( + '${'IssueDate'.tr}: ${ai.responseCriminalRecordEgypt['IssueDate']}'), + ], + ), + ), + ); + } + return Card( + child: InkWell( + onTap: () async { + await ai.allMethodForAI( + 'Write a JSON object from the following information extracted from the provided Arabic text:["InspectionResult": ,"NationalID","FullName","IssueDate"]make date format year-month-day ,and add spaces in text', + AppLink.uploadEgypt, + 'criminalRecord', + ); + }, + child: Column( + children: [ + Image.asset( + 'assets/images/6.png', + height: Get.height * .25, + width: double.maxFinite, + fit: BoxFit.fitHeight, + ), + Text( + 'Capture an Image of Your Criminal Record'.tr, + style: AppStyle.title, + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/lib/views/auth/captin/cards/gemini_egypt.dart b/lib/views/auth/captin/cards_egypt/gemini_egypt.dart similarity index 100% rename from lib/views/auth/captin/cards/gemini_egypt.dart rename to lib/views/auth/captin/cards_egypt/gemini_egypt.dart diff --git a/lib/views/auth/captin/cards_egypt/sms_signup.dart b/lib/views/auth/captin/cards_egypt/sms_signup.dart new file mode 100644 index 0000000..3ae2b13 --- /dev/null +++ b/lib/views/auth/captin/cards_egypt/sms_signup.dart @@ -0,0 +1,106 @@ +import 'package:SEFER/constant/style.dart'; +import 'package:SEFER/controller/auth/captin/register_captin_controller.dart'; +import 'package:SEFER/views/widgets/elevated_btn.dart'; +import 'package:SEFER/views/widgets/my_scafold.dart'; +import 'package:SEFER/views/widgets/my_textField.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class SmsSignupEgypt extends StatelessWidget { + SmsSignupEgypt({super.key}); + + @override + Widget build(BuildContext context) { + Get.put(RegisterCaptainController()); + return MyScafolld( + title: 'Phone Check'.tr, + body: [ + GetBuilder( + builder: (registerCaptainController) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // Logo at the top + Padding( + padding: const EdgeInsets.only(bottom: 20.0), + child: Image.asset( + 'assets/images/logo.png', // Make sure you have a logo image in your assets folder + height: 100, + ), + ), + // Message to the driver + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), + child: Text( + 'We need your phone number to contact you and to help you receive orders.' + .tr, + textAlign: TextAlign.center, + style: AppStyle.title, + ), + ), + // Enter phone number text + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), + child: Text( + 'Enter your phone number'.tr, + textAlign: TextAlign.center, + style: AppStyle.title, + ), + ), + // Phone number input field + Padding( + padding: const EdgeInsets.all(16.0), + child: !registerCaptainController.isSent + ? Form( + key: registerCaptainController.formKey3, + child: MyTextForm( + controller: + registerCaptainController.phoneController, + label: 'Enter your phone number'.tr, + hint: 'Enter your phone number'.tr, + type: TextInputType.phone), + ) + : Container( + decoration: AppStyle.boxDecoration1, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + registerCaptainController.phoneController.text, + style: AppStyle.title, + ), + ), + )), + const SizedBox( + height: 10, + ), + Padding( + padding: const EdgeInsets.all(16.0), + child: registerCaptainController.isSent + ? Form( + key: registerCaptainController.formKey3, + child: MyTextForm( + controller: registerCaptainController.verifyCode, + label: '5 digit'.tr, + hint: '5 digit'.tr, + type: TextInputType.number), + ) + : const SizedBox()), + // Submit button + MyElevatedButton( + onPressed: () async { + !registerCaptainController.isSent + ? await registerCaptainController.sendOtpMessage() + : await registerCaptainController.verifySMSCode(); + }, + title: 'Submit'.tr, + ), + ], + ); + }), + ], + isleading: false, + ); + } +} diff --git a/lib/views/widgets/my_textField.dart b/lib/views/widgets/my_textField.dart index 54f2bf0..49e3371 100644 --- a/lib/views/widgets/my_textField.dart +++ b/lib/views/widgets/my_textField.dart @@ -1,3 +1,5 @@ +import 'package:SEFER/constant/box_name.dart'; +import 'package:SEFER/main.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:get_storage/get_storage.dart'; @@ -43,7 +45,7 @@ class MyTextForm extends StatelessWidget { ), validator: (value) { if (value!.isEmpty) { - return 'Please enter $label.'.tr; + return '${'Please enter'.tr} $label.'.tr; } if (type == TextInputType.emailAddress) { @@ -51,7 +53,11 @@ class MyTextForm extends StatelessWidget { return 'Please enter a valid email.'.tr; } } else if (type == TextInputType.phone) { - if (value.length != 10) { + if (box.read(BoxName.countryCode) == 'Egypt') { + if (value.length != 11) { + return 'Please enter a valid phone number.'.tr; + } + } else if (value.length != 10) { return 'Please enter a valid phone number.'.tr; } }