This commit is contained in:
Hamza-Ayed
2024-07-16 18:13:40 +03:00
parent 4ffaa591fa
commit e6305f4ddc
9 changed files with 246 additions and 140 deletions

View File

@@ -1,13 +1,10 @@
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/controller/functions/crud.dart';
import 'package:SEFER/controller/functions/gemeni.dart';
import 'package:SEFER/controller/functions/tts.dart';
import 'package:SEFER/main.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:SEFER/views/widgets/my_textField.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:webview_flutter/webview_flutter.dart';
import '../../../../constant/colors.dart';
import '../../../../constant/links.dart';
import '../../../../constant/style.dart';
@@ -114,102 +111,153 @@ class EgyptCardAI extends StatelessWidget {
right: 30,
left: 30,
child: GetBuilder<AI>(builder: (controller) {
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'.tr,
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,
return controller.isInviteDriverFound == false
? Padding(
padding: const EdgeInsets.symmetric(vertical: 60),
child: Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
"Do you have an invitation code from another driver?"
.tr,
style: AppStyle.title,
textAlign: TextAlign.center,
),
const SizedBox(
height: 30,
),
Form(
key: controller.formKey,
child: MyTextForm(
controller:
controller.invitationCodeController,
label: "Paste the code here".tr,
hint: "Paste the code here".tr,
type: TextInputType.name,
),
),
),
const SizedBox(height: 8),
GetBuilder<TextToSpeechController>(
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(
height: 30,
),
MyElevatedButton(
title: 'Ok'.tr,
onPressed: () async {
controller
.updateInvitationCodeFromRegister();
}),
MyElevatedButton(
kolor: AppColor.yellowColor,
title: "No, I don't have a code".tr,
onPressed: () {
controller.isInviteDriverFound = true;
controller.update();
})
],
),
),
),
)
: const SizedBox();
: 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'.tr,
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<TextToSpeechController>(
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();
}),
)
],
@@ -402,18 +450,28 @@ Important notes:
IconButton(
onPressed: () async {
await ai.allMethodForAI("""
Write a JSON from the following information extracted from the provided Arabic text:
- nationalID(in Latin numerals)
Given the following Arabic text values:
Please create a JSON object with the following fields:
- nationalID (use exactly 14 digits, no more and no less)
- issueDate (in format YYYY-MM-DD using Latin numerals)
- occupation
- gender
- country
- religion
- maritalStatus
- fullNameMarital (if maritalStatus is "أعزب", set this to "none")
- expirationDate (in format YYYY-MM-DD using Latin numerals)
Please ensure all date fields use Latin (Western) numerals (0-9) instead of Arabic numerals. For example, use "2023-04-03" instead of "٢٠٢٣-٠٤-٠٣".
""", AppLink.uploadEgypt, 'id_back'); //egypt
Important notes:
1. Ensure all date fields use Latin (Western) numerals (0-9) instead of Arabic numerals.
2. For the nationalID, use exactly 14 digits from the provided Arabic numeral string, converting to Latin numerals.
3. For issueDate, use the last day of the month since only year and month are provided.
4. Include the country field based on the provided information.
5. Format all string values consistently (e.g., all lowercase or proper case).
Please provide the resulting JSON object. """, AppLink.uploadEgypt,
'id_back'); //egypt
},
icon: const Icon(Icons.refresh),
),
@@ -482,25 +540,28 @@ Please ensure all date fields use Latin (Western) numerals (0-9) instead of Arab
child: InkWell(
onTap: () async {
await ai.allMethodForAI('''
Write a JSON object from the following information extracted from the provided Arabic text:
Given the following Arabic text values:
{
"nationalID": "",//(in Latin numerals)
"issueDate": "", // Format: YYYY-MM-DD using Latin numerals (0-9)
"occupation": "",
"gender": "",
"religion": "",
"maritalStatus": "",
"fullNameMaritial": "", // Set to "none" if maritalStatus is "أعزب"
"expirationDate": "" // Format: YYYY-MM-DD using Latin numerals (0-9)
}
Please create a JSON object with the following fields:
- nationalID (use exactly 14 digits, no more and no less)
- issueDate (in format YYYY-MM-DD using Latin numerals)
- occupation
- gender
- country
- religion
- maritalStatus
- fullNameMarital (if maritalStatus is "أعزب", set this to "none")
- expirationDate (in format YYYY-MM-DD using Latin numerals)
Important notes:
1. Ensure all dates (issueDate and expirationDate) are in the format YYYY-MM-DD using Latin (Western) numerals (0-9), not Arabic numerals.
2. If maritalStatus is "أعزب" (single), set fullNameMaritial to "none".
3. Fill in all fields based on the information provided in the Arabic text.
4. If any information is missing, leave the field as an empty string.
''', AppLink.uploadEgypt, 'id_back'); //egypt
1. Ensure all date fields use Latin (Western) numerals (0-9) instead of Arabic numerals.
2. For the nationalID, use exactly 14 digits from the provided Arabic numeral string, converting to Latin numerals.
3. For issueDate, use the last day of the month since only year and month are provided.
4. Include the country field based on the provided information.
5. Format all string values consistently (e.g., all lowercase or proper case).
Please provide the resulting JSON object. ''', AppLink.uploadEgypt,
'id_back'); //egypt
},
child: Column(
children: [
@@ -817,19 +878,20 @@ Please fill in the JSON object with the extracted information, following these g
final inspectionDate =
ai.responseIdCardDriverEgyptBack['inspection_date'];
final year = int.parse(inspectionDate.split('-')[0]);
// Set inspectionDateTime to December 31st of the given year
final inspectionDateTime = DateTime(year, 12, 31);
// Check if the tax expiry date is before today
String carBackLicenseExpired =
inspectionDateTime.toString().split(' ')[0];
// Get the current date
final today = DateTime.now();
// Try parsing the tax expiry date. If it fails, set it to null.
// 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(year ?? ''), 1, 1);
final isInspectionExpired = inspectionDateTime.isBefore(today);
// Check if the inspection date is before today
bool isInspectionExpired = inspectionDateTime.isBefore(today);
return Card(
elevation: 4.0,
@@ -929,7 +991,7 @@ Please fill in the JSON object with the extracted information, following these g
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Inspection Date'.tr}: $inspectionDate',
'${'Inspection Date'.tr}: $carBackLicenseExpired',
style: TextStyle(
color:
isInspectionExpired ? Colors.red : Colors.green,