This commit is contained in:
Hamza-Ayed
2024-07-15 11:37:06 +03:00
parent 65a8084c92
commit 4ffaa591fa
22 changed files with 739 additions and 42 deletions

View File

@@ -1,5 +1,8 @@
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:flutter/material.dart';
import 'package:get/get.dart';
@@ -814,7 +817,7 @@ 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]);
final inspectionDateTime = DateTime(year, 1, 1);
final inspectionDateTime = DateTime(year, 12, 31);
// Check if the tax expiry date is before today
final today = DateTime.now();

View File

@@ -0,0 +1,210 @@
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/constant/style.dart';
import 'package:SEFER/main.dart';
import 'package:SEFER/views/widgets/my_scafold.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../constant/colors.dart';
import '../../../constant/links.dart';
import '../../../controller/functions/gemeni.dart';
import '../../../controller/functions/tts.dart';
import '../../widgets/elevated_btn.dart';
class CriminalDocumemtPage extends StatelessWidget {
const CriminalDocumemtPage({super.key});
@override
Widget build(BuildContext context) {
Get.put(AI());
return MyScafolld(
title: "Criminal Document".tr,
isleading: false,
body: [
GetBuilder<AI>(builder: (controller) {
return Column(
children: [
Container(
decoration: AppStyle.boxDecoration,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text('You have upload Criminal documents'.tr),
)),
egyptCriminalRecord(),
controller.responseCriminalRecordEgypt.isNotEmpty
? MyElevatedButton(
title: 'Next'.tr,
onPressed: () async {
if (controller
.responseCriminalRecordEgypt['FullName'] !=
box.read(BoxName.nameArabic)) //todo get from server
{
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 drivers 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<TextToSpeechController>()
.speakText(
'The full name on your criminal record does not match the one on your drivers 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 {
await controller.addCriminalDeocuments();
}
})
: const SizedBox(),
],
);
})
],
);
}
GetBuilder<AI> egyptCriminalRecord() {
return GetBuilder<AI>(
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": "" // Format: YYYY-MM-DD
}
Important notes:
1. For the IssueDate, ensure the date is in YYYY-MM-DD format using Latin numerals (0-9).
2. Add appropriate spaces in all text fields to ensure readability.
3. If any information is missing, leave the corresponding field as an empty string.
4. Ensure all text is properly formatted and spaces are used correctly.
5. Convert any Arabic numerals to Latin numerals (0-9) where applicable.
Please fill in the JSON object with the extracted information, following these guidelines.
""",
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": "" // Format: YYYY-MM-DD
}
Important notes:
1. For the IssueDate, ensure the date is in YYYY-MM-DD format using Latin numerals (0-9).
2. Add appropriate spaces in all text fields to ensure readability.
3. If any information is missing, leave the corresponding field as an empty string.
4. Ensure all text is properly formatted and spaces are used correctly.
5. Convert any Arabic numerals to Latin numerals (0-9) where applicable.
Please fill in the JSON object with the extracted information, following these guidelines.
""",
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,
),
],
),
),
);
},
);
}
}

View File

@@ -0,0 +1,122 @@
import 'package:SEFER/constant/colors.dart';
import 'package:SEFER/constant/style.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 '../../../controller/auth/captin/invit_controller.dart';
class InviteDriverScreen extends StatelessWidget {
final InviteController controller = Get.put(InviteController());
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Invite a Driver'.tr)),
body: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Invite another driver and both get a gift after he completes 100 trips!"
.tr,
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
const SizedBox(height: 20),
MyTextForm(
controller: controller.invitePhoneController,
label: 'Enter driver\'s phone'.tr,
hint: 'Enter driver\'s phone'.tr,
type: TextInputType.phone),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
MyElevatedButton(
title: 'Send Invite'.tr,
onPressed: controller.sendInvite,
),
MyElevatedButton(
title: 'Show Invitations'.tr,
onPressed: () async {
controller.fetchDriverStats();
},
),
],
),
const SizedBox(height: 20),
GetBuilder<InviteController>(builder: (controller) {
return SizedBox(
// decoration: AppStyle.boxDecoration,
height: Get.height * .4,
child: controller.driverInvitationData.isEmpty
? Center(
child: Text(
"No invitation found yet!".tr,
style: AppStyle.title,
),
)
: ListView.builder(
itemCount: controller.driverInvitationData.length,
itemBuilder: (context, index) {
// Ensure the 'countOfInvitDriver' key exists and is parseable as an int
int countOfInvitDriver = 0;
if (controller.driverInvitationData[index]
.containsKey('countOfInvitDriver')) {
countOfInvitDriver = int.tryParse(controller
.driverInvitationData[index]
['countOfInvitDriver']
.toString()) ??
0;
}
// Calculate the progress value, ensuring it is between 0 and 1
double progressValue = countOfInvitDriver / 100.0;
if (progressValue > 1.0) progressValue = 1.0;
if (progressValue < 0.0) progressValue = 0.0;
return Container(
margin: const EdgeInsets.symmetric(vertical: 8.0),
child: Stack(
alignment: AlignmentDirectional.center,
children: [
InkWell(
onTap: () async {
controller.onSelectDriverInvitation(index);
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: AppColor.accentColor.withOpacity(
.5), // Background color of the container
),
width: Get.width * .85,
child: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: LinearProgressIndicator(
value: progressValue,
color: AppColor.blueColor,
backgroundColor: AppColor.accentColor
.withOpacity(.3),
minHeight: 35,
),
),
),
),
Text(
'${controller.driverInvitationData[index]['invitorName']} ${controller.driverInvitationData[index]['countOfInvitDriver']} / 100 ${'Trip'.tr}'),
],
),
);
},
),
);
})
],
),
),
);
}
}